akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()
    S = iss()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K]+'...')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10100
#include<stdio.h>
int main(){
  char s[100010]={};
  int i,d[100010]={};
  int c[2]={};
  scanf("%s",s);
  for(i=0;s[i];i++){
    if(s[i]=='R'){
      c[i%2]++;
      if(s[i+1]=='L'){
	d[i  ]+=c[  i%2];
	d[i+1]+=c[1-i%2];
	c[0]=c[1]=0;
      }
    }
  }
  while(i--){
    if(s[i]=='L'){
      c[i%2]++;
      if(i&&s[i-1]=='R'){
	d[i  ]+=c[  i%2];
	d[i-1]+=c[1-i%2];
	c[0]=c[1]=0;
      }
    }
  }
  for(i=0;s[i];i++)printf("%d%c",d[i],s[i+1]?' ':'\n');
  return 0;
}
    
		


Measured memory_bytes: 896
k,n = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
max = 0
(n-1).times do |i|
  max = a[i+1] - a[i] if max < a[i+1] - a[i]
end
max = a[0] + k - a[n-1] if max < a[0] + k - a[n-1]
puts k - max

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

int main() {
  
  int N;
  int A;
  int B;
  
  cin >> N;
  cin >> A;
  cin >> B;
  
  if ( N * A > B ) {
    cout << B << endl;
  }
  
  if ( N * A == B ) {
    cout << B << endl;
  }
  
  if ( N * A < B ) {
    cout << N * A << endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	char c[10][10];

	for (int i = 0;i < 3;i++){
		for (int j = 0;j < 3;j++){
			cin >> c[i][j];
		}
	}

	for (int i = 0;i < 3;i++){
		cout << c[i][i];
	}

	cout << endl;

	return 0;

}


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

int main()
{

   int n;
   cin>>n;
   string s;
   cin>>s;
   int r=0,w=0;

   for(int i=0;i<n;i++)
   {
    if(s[i]=='R')r++;
    else w++;
   }
   int no=0;
   for(int i=0;i<r;i++)
   {
       if(s[i]=='R')no++;
   }
   cout<<r-no<<endl;

   }



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

int main(void){
	int inp, value[4] = {10,50,100,500}, bill, a[4], k[4], sum, i, j;
	scanf("%d",&bill);
	while(bill){
		sum = 0;
		for(i = 0;i < 4;i++){
			scanf("%d",&a[i]);
			for(j = 0;j < a[i];j++)
				sum += value[i];
		}
		sum -= bill;
		memset(k,0,sizeof(k));
		for(i = 3;i >= 0;i--){
			while(value[i] <= sum){
				sum -= value[i];
				k[i]++;
			}
		}
		for(i = 0;i < 4;i++)
			if(a[i] - k[i] > 0) printf("%d %d\n",value[i],a[i] - k[i]);
		scanf("%d",&bill);
		if(bill)
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1032
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
c = 0 
maxl = 0
for i in set(s):
    c = s.count(i) - t.count(i)
    maxl = max(maxl, c)
print(maxl)

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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            int L = int.Parse(Console.ReadLine());
            double length = (double)L / 3;
            Console.WriteLine(Math.Pow(length, 3));
        }

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
typedef long long int ll;
int main(){
    int N;
    cin>>N;
    vector<int>A(N);
    int count=0;
    rep(i,N){
        cin>>A.at(i);
        if(A.at(i)%2==0){
            if(A.at(i)%3!=0&&A.at(i)%5!=0){
                count++;
            }
        }
    }

    if(count!=0){
        cout<<"DENIED"<<endl;
    }else{
        cout<<"APPROVED"<<endl;
    }

    return 0;
}

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

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

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

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

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

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

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

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

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap};
use std::io::{Write, BufWriter, stdout};
fn main() {
    input! {
        Q: usize,
        query: [(usize, usize); Q],
    }

    let like2017_countsum = eratosthenes_variant(100_000);
    let stdout = stdout();
    let mut out = BufWriter::with_capacity(4*Q, stdout.lock());
    for &(l, r) in query.iter() {
        let ans = like2017_countsum[r] - like2017_countsum[l-1];
        writeln!(out, "{}", ans).unwrap();
    }
}

fn eratosthenes_variant(max: usize) -> Vec<usize> {
    let search_bound = (max as f64).sqrt().ceil() as usize;
    let mut like2017_countsum = vec![0; max+1];
    let mut is_primes = vec![true; max+1];
    is_primes[0] = false;
    is_primes[1] = false;

    let mut count = 0;
    for candidate in 2..max+1 {
        if is_primes[candidate] {
            let prime = candidate;
            if prime <= search_bound {
                let mut no_prime = prime*prime;
                while no_prime <= max {
                    is_primes[no_prime] = false;
                    no_prime += prime;
                }
            }
            if is_primes[(prime+1)/2] { count += 1; }
        }
        like2017_countsum[candidate] = count;
    }

    like2017_countsum
}


Measured memory_bytes: 6780
#include<bits/stdc++.h>
using namespace std;
#if defined __has_include
# if __has_include(<bits/debug_aamir.h>)
#  define dbg(...) DEBUG(#__VA_ARGS__, __VA_ARGS__);
#  include<bits/debug_aamir.h>
# else
#  define dbg(...)
# endif
#endif

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> pll;
#define sz(x) int(x.size())
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define rep(i, begin, end) for(__typeof(end) i=begin; i<end; i++)
#define per(i, begin, end) for(__typeof(end) i=begin; i>=end; i--)
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;


template<typename T>
T gcd(T a, T b){	return b ? gcd(b, a%b): a; }
template<typename T>
T lcm(T a, T b){	return a/gcd(a, b) * b;		}


int main()
{
	fastio;
	int n;
	cin >> n;
	vector<vi> gain(n, vi(3)), dp(n, vi(3));
	rep(i, 0, n){
		rep(j, 0, 3)
			cin >> gain[i][j];
	}
	rep(i, 0, 3)	dp[0][i] = gain[0][i];
	rep(i, 1, n){
		rep(j, 0, 3){
			rep(k, 0, 3)	if(k != j){
				dp[i][j] = max(dp[i][j], dp[i-1][k]+gain[i][j]);
			}
		}
	}
	printf("%d\n", max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])));
}



Measured memory_bytes: 14268
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] a = new int[n];

        int[] max = new int[2];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            if (max[0] <= a[i]) {
                max[1] = max[0];
                max[0] = a[i];
            } else if (max[1] < a[i]) {
                max[1] = a[i];
            }
        }

        for (int i = 0; i < n; i++) {
            if (max[0] == a[i])
                System.out.println(max[1]);
            else
                System.out.println(max[0]);
        }
    }
}

Measured memory_bytes: 90104
for i in range(int(input())):
    px0,py0,px1,py1,px2,py2,px3,py3 = map(lambda x:int(x),input().split(" "))  
    print(1 if (px1-px0)*(px3-px2) == -(py1-py0)*(py3-py2) else(2 if (px1-px0)*(py3-py2) == (py1-py0)*(px3-px2) else 0))


Measured memory_bytes: 5616
import bisect

n = int(input())
a = list(map(int, input().split( )))
a.sort()
q = int(input())
for _ in range(q):
    k = int(input())
    i = bisect.bisect_left(a,k)
    if  (i == n) or (i == 0 and a[0] > k):
        print(0)
    elif a[i] > k and k > a[i-1]:
        print(0)
    else:
        print(1)


Measured memory_bytes: 17220
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

//先ほどの1msの解法は嘘解法だった

bool func(const vll &v, ll num){
  ll n = v.size();
  if(n == 0){
    if(num == 0) return true;
    else return false;
  }
  vector<vector<bool>> dp(n, vector<bool>(16001, false));
  dp.at(0).at(v.at(0)+8000) = true;
  dp.at(0).at(-1 * v.at(0)+8000) = true;
  for(int i = 1; i < n; i++){
    for(int j = -8000; j <= 8000; j++){
      ll x = v.at(i);
      if(j - x >= -8000 && j - x <= 8000) if(dp.at(i-1).at(j-x+8000)) dp.at(i).at(j+8000) = true;
      if(j + x >= -8000 && j + x <= 8000) if(dp.at(i-1).at(j+x+8000)) dp.at(i).at(j+8000) = true;
    }
  }
  return dp.at(n-1).at(num+8000);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  ll N = s.size();
  ll x, y;
  cin >> x >> y;
  int count = 0;
  if(s.at(0) == 'F'){
    int i = 0;
    while(i < N && s[i] == 'F'){
      count++;
      i++;
    }
    x -= count;
  }
  vll xbox(0), ybox(0);
  ll tcount = 0, fcount = 0;
  for(int i = count; i < N; i++){
    if(s.at(i) == 'F'){
      while(i < N && s[i] == 'F'){
        fcount++;
        i++;
      }
      i--;
      if(tcount % 2 == 0) xbox.push_back(fcount);
      else ybox.push_back(fcount);
      fcount = 0;
    }
    else tcount++;
  }
  sort(ALL(xbox), greater<ll>()); sort(ALL(ybox), greater<ll>());
  if(func(xbox, x) && func(ybox, y)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

class Main  {
	public static void main(String[] args)throws Exception{
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        int a = Integer.parseInt(br.readLine());
        int b = Integer.parseInt(br.readLine());
        int h = Integer.parseInt(br.readLine());
        int S = (a+b)*h/2;
        System.out.print(S);
	}
}

Measured memory_bytes: 19796
#include <iostream>
#include <cctype>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin >> s;
	bool ans = false;

	if (s[0] == 'A') {
		int count = 0;
		for (int i = 2; i < s.size() - 1; i++) {
			if (s[i] == 'C')
				count++;
		}
		if (count == 1) {
			for (int i = 1; i < s.size(); i++) {
				if (s[i] == 'C' || islower(s[i])) {
					if (i == s.size() - 1) {
						ans = true;
					}
				}
				else
					break;
			}
		}
	}
	if (ans)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

signed main() {
    SS(int,N,M);
    SS(string,S);
    vector<int> ans;

    while(N!=0){
        int l=(N-M>0?N-M:0);
        while(S[l]=='1'){
            l++;
            if(l==N){cout<<-1;return 0;}
        }
        ans.push_back(N-l);
        N=l;
    }
    for(int j=ans.size()-1;j>=0;j--)cout<<ans[j]<<" ";

}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

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

int bfs(const vector<string>& s, int st_x, int st_y){
    int ret = 0;
    int h = s.size();
    int w = s[0].size();
    queue<pair<int,int>> q;
    q.push({st_x, st_y});
    vector<vi> seen(h, vi(w,-1));
    seen[st_x][st_y] = 0;
    while(q.size()){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();

        if(ret < seen[x][y]){
            ret = seen[x][y];
        }

        rep(i,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx<0 || nx>=h || ny<0 || ny>=w || seen[nx][ny] != -1 || s[nx][ny] == '#') continue;
            seen[nx][ny] = seen[x][y] + 1;
            q.push({nx, ny});
        }
    }

    return ret;
}

int main(){
    int h,w;cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    int ans = 0;
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '#') continue;
            chmax(ans, bfs(s, i, j));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
answer = 0
li = []
for i in range(m):
    li.append(list(map(int,input().split())))
li1 = list(map(int,input().split()))
for i in range(2**n):
    b = "0"*(n-len(bin(i))+2)+bin(i)[2:]
    libi = [int(b[s]) for s in range(n)]
    c = 0
    for j in range(m):
        c1 = 0
        for k in range(li[j][0]):
            if libi[li[j][k+1]-1] == 1:
                c1 += 1
        if c1 % 2 == li1[j]:
            c += 1
    if c == m:
        answer += 1
print(answer)

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

int main() {
	int n;
	long long sum, max;

	while (true) {
		sum = 0;
		max = -10000000;
		cin >> n;
		if (n == 0) break;

		int a[n];

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

		for (int i = 0; i < n; i++) {
			sum = 0;
			for (int j = 1; j <= n; j++) {
				if (i + j - 1 < n) {
					sum += a[i + j - 1];
					if (sum > max)	max = sum;
				}
			}
		}

		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int n;
  cin >> n;

  int x = n % 10;
  int y = n / 10;
  if (x == 9 || y == 9){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3548
n, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0
for index, i in enumerate(a):
  if index+2 > len(a):
    continue
  total = i + a[index+1]
  if total <= x:
    continue
  m = total - x
  count += m
  if i >= a[index+1]:
    i -= m
    if i < 0:
      i = 0
      m = m - i
    a[index] = i  
    if m > 0:
      a[index+1] -= m
      
  if a[index+1] > i:
    a[index+1] -= m
    if a[index+1] < 0:
      a[index+1] = 0
      m = m - a[index+1]
      if m > 0:
        a[index] -= m

print(count)

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  int x = c-a,y = d-b;

  cout << c-y <<" " <<d+x<<" " << a-y<<" " << b+x <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string>
#include<sstream>
using namespace std;
 
int main()
{
int m,n,i;
set<int> player;
set<int>::iterator it;
string s,right;
stringstream ss;
while(cin>>m>>n,m|n){
 player.clear();
 for(i=1;i<=m;i++)player.insert(i);
 it=player.begin();
 
 for(i=1;i<=n;i++){
  cin>>s;
  if(player.size()==1)continue;
  right="";
  if(i%3&&i%5){
   ss.str("");
   ss<<i;
   right=ss.str();
  }else{
   if(!(i%3))right+="Fizz";
   if(!(i%5))right+="Buzz";
  }
  if(s!=right)player.erase(it++);
  else it++;
  if(it==player.end())it=player.begin();
 }
 for(it=player.begin();it!=player.end();it++){
  if(it!=player.begin())cout<<" ";
  cout<<*it;
 }
 cout<<endl;
}
}

Measured memory_bytes: 972
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int dp[4003][4003] = {0};
int main(){
  
  
  
  char a[4002],b[4002];
  
  while(cin >> a >> b){
  int ans = 0;
  memset(dp,0,sizeof(dp));
 // scanf("%s%s",&a,&b);
  
  int alen = strlen(a);
  int blen = strlen(b);
  
  for(int i = 1;i <= alen;i++){
    for(int j = 1;j <= blen;j++){
      if(a[i-1] == b[j-1]){
	dp[i][j] = dp[i-1][j-1] + 1;
	ans = max(ans,dp[i][j]);
      }
    }
  }
  
  
  printf("%d\n",ans);
  
  }
  
  return 0;
  
}
  


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


int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b*2) {
    cout << 0 << endl;
  } else {
    cout << a - b*2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-9
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 1002;
int n,k,a[N];
ll acc[N];

int main(){
    read2i(n,k);
    lp(i,1,n) readi(a[i]), acc[i] = acc[i-1] + a[i];

    multiset<ll> st;
    lp(i,1,n) lp(j,i,n) st.insert(acc[j] - acc[i-1]);

    ll ans = 0;
    lpd(j,40,0){
        int cnt = 0;
        for(ll y : st) if(y & (1ll<<j)) ++cnt;
        if(cnt >= k){
            ans |= 1ll << j;
            multiset<ll> nxt;
            for(ll y : st) if(y & (1ll<<j)) nxt.insert(y);
            st = nxt;
        }
    }
    cout <<ans;
}

/*
uniform_int_distribution<type>(l, r)(rng)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
*/


Measured memory_bytes: 29056
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

typedef struct CONVTABLE {
	char bfr;
	char afr;
}CnvTbl;

int main(void) {
	int n;
	vector<string> out;

	while (cin >> n) {
		if (n == 0) {
			break;
		}

		vector<CnvTbl> vc;
		for (int i = 0; i < n; i++) {
			char ch_a, ch_b;
			CnvTbl wk;

			cin >> ch_a >> ch_b;

			wk.bfr = ch_a;
			wk.afr = ch_b;

			vc.push_back(wk);
		}

		int m;
		cin >> m;

		stringstream ss;
		for (int j = 0; j < m; j++) {
			char cnvch;

			cin >> cnvch;

			for (int x = 0; x < vc.size(); x++) {
				if (cnvch == vc[x].bfr) {
					cnvch = vc[x].afr;
					break;
				}
			}
			ss << cnvch;
		}
		out.push_back(ss.str());
	}

	for (int y = 0; y < out.size(); y++) {
		cout << out[y] << endl;
	}

	return 0;
}

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

using namespace std;

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

int a[50];
int main()
{
    int x,n;
    ll sum=0;
    cin >> n >> x;
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        sum+=a[i];
        if(sum>=x||i==n-1)
        {
            if(sum==x) i++;
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int x,y;
    cin >>x>>y;
    
    rep(i,x+1){
        int a=0;
        a+=i*2;
        a+=(x-i)*4;
        if(a==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define int long long
#define lb lower_bound
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}
#define abs(x) ((x) < 0 ? (-1 * (x)) : (x))
#define max(x, y) (((x) < (y)) ? (y) : (x))

typedef vector<int> vint;
typedef pair<int, int> pii;

#define N 2001
int dp[N][N];


void printDp(int n) {
    cout << endl;
    rep(i, n + 1) {
        rep(j, n + 1) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

signed main(void){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pii> as = vector<pii>();
    rep(i, n) {
        int a;
        cin >> a;
        as.push_back(pii(a, i));
    }
    sort(as.begin(), as.end(), [](pii& a, pii& b) { return a.first > b.first; });
    rep(i, N) rep(j, N) dp[i][j] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; i + j < n; ++j) {
            pii cur = as[i + j];
            int dis = (n - j - 1) - cur.second;
            dp[i][j + 1] = max(dp[i][j] + cur.first * abs(dis), dp[i][j + 1]);

            dis = i - cur.second;
            dp[i + 1][j] = max(dp[i][j] + cur.first * abs(dis), dp[i + 1][j]);
        }
    }
//  printDp(n);
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans = max(ans, dp[i][n - i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 34944
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

string s;

int main(){
    cin>>s;
    for(int i=0; i<s.size(); i++){
        if(s[i]==',')s[i]=' ';
    }
    cout<<s<<endl;
}

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

using namespace std;

int main(){
    int s;
    cin>>s;
    map<int,int> mp;
    for (int i = 1; i <= s; ++i) {
        int ini=(1+i)*i/2;
        if(ini*ini>s)break;
        while(ini*ini<=s) {
            //cout<<ini<<endl;
            ++mp[ini];
            ini+=i;
        }
    }
    long long ans=0;
    for(auto i:mp){
        if(s%i.first==0){
            for (int j = 1; j <= s/i.first; ++j) {//区間の長さ
                int ini=(1+j)*j/2;
                if(s/i.first<ini)break;
                if((s/i.first-ini)%j==0){
                    //cout<<i.first<<" "<<j<<endl;
                    ans+=i.second;
                    if(i.first*i.first!=s)ans+=i.second;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;
		static T MIN<T>(params T[] args) => args.Min();
		static T MAX<T>(params T[] args) => args.Max();

		static void Main(string[] args)
		{
			var n = RI;
			var a = RIs;
			var b = RIs;
			var sa = new List<long>(a.Length);
			for(int i = 0;i < a.Length;i++)
			{
				sa.Add(a[i] - b[i]);
			}
			var sum = sa.Where(x => x < 0).Sum();
			var count = sa.Count(x => x < 0);
			if (Math.Abs(sum) > sa.Where(x => x > 0).Sum())
			{
				Out("-1");
				return;
			}
			sa.Sort();
			sa.Reverse();
			for(int i = 0;i < sa.Count;i++)
			{
				if (sum >= 0) break;
				count++;
				sum += sa[i];
			}
			Out(count);
		}
	}
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    ans=0
    for i in range(N):
        l,r=MI()
        ans+=(r-l)+1
        
    print(ans)

main()


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

typedef long long ll;

ll n,m;

int main(){
    cin >> n >> m;
    if(n * 2 >= m) cout << min(n, m / 2);
    else{
        m -= (n * 2);
        ll Add = m / 4;
        cout << n + Add << endl;
    }
    return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

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

int dp[2005][2] = {};

void Main()
{
    int n = in(), z = in(), w = in();
    vint a = in(n);

    for (int i = n - 1; i >= 0; --i)
    {
        dp[i][0] = -INF;
        int y = (i == 0 ? w : a[i - 1]);
        chmax(dp[i][0], abs(y - a[n - 1]));
        REP(j, i + 1, n)
        {
            chmax(dp[i][0], dp[j][1]);
        }

        dp[i][1] = INF;
        int x = (i == 0 ? z : a[i - 1]);
        chmin(dp[i][1], abs(x - a[n - 1]));
        REP(j, i + 1, n)
        {
            chmin(dp[i][1], dp[j][1]);
        }
    }
    cout << dp[0][0] << endl;
}

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


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <valarray>
#include <string>
#include <algorithm>
#include <set>
typedef unsigned long long ull;
typedef long long ll;
#define fst first
#define snd second
#define rep(i,n) for(ull i = 0;i<(n);i++)
#define rep1(i,n) for(ull i = 1;i<=(n);i++)
#define revrep(i,n) for(ull i = (n-1);i>=0;i--)
#define all(n) (n).begin(),(n).end()
#define show(x) cout << "debug " << #x << ":" << x << endl;
#define showvec(x) cout << endl << "debug " << #x << ";" << endl; \
    for(ull __i = 0;__i < x.size();__i++){ \
        for(ull __j = 0;__j<x[0].size();__j++){ \
            cout << x[__i][__j] << " "; \
        } \
        cout << endl; \
    } \
    cout << endl;
using namespace std;

int BIT[1000010], bit_size;
void bit_init(int n){
	rep(i,n){
		BIT[i] = 0;
	}
	bit_size = n;
}

int bit_sum(int n){
	int ans = 0;
	while(n > 0){
		ans += BIT[n];
		n &= n-1;
	}
	return ans;
}

void bit_add(int n, int v){
	while(n <= bit_size){
		BIT[n] += v;
		n += n & (-n);
	}
}

int N,Q;

int main(){
	cin >> N >> Q;
	bit_init(N);
	rep(_q,Q){
		int com,x,y;
		cin >> com >> x >> y;
		if(com == 1){
			int l,r;
			if(x == 0){
				l = 0;
			}else{
				l = bit_sum(x-1);
			}
			r = bit_sum(y);
			cout << r - l << endl;
		}else{
			bit_add(x,y);
		}
	}
}

Measured memory_bytes: 1548
import sys
s = list(input())
t = list(input())
if s == t:
    print('Yes')
    sys.exit()
for si in range(len(s)+1):
    before = s[0:si+1]
    after = s[si+1:len(s)+1]
    if after + before == t:
        print('Yes')
        sys.exit()
print('No')

Measured memory_bytes: 3060
n = gets.to_i
a = gets.chomp.split.map(&:to_i).sort.reverse

ans = a[0]
a = a[1..-1]

if n != 2
  i = 0
  cnt = 0
  loop {
    ans += a[i]
    cnt += 1
    break if cnt >= a.size - 1
    ans += a[i]
    cnt += 1
    break if cnt >= a.size - 1
    i += 1
  }
end

puts ans

Measured memory_bytes: 33436
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        string a = Cin.Next();
        string b = Cin.Next();
        string c = Cin.Next();

        Console.WriteLine(a.Last() == b.First() && b.Last() == c.First() ? "YES" : "NO");
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
char readChar()
{
    char result = getchar();
    while (isspace(result)) {
        result = getchar();
    }
    return result;
}
int arr[] = {0, 1, 1, 2, 3, 6, 11};
int get(int n)
{
    return arr[n];
}
int lagrange(int n)
{
    int need = n + 1;
    int res = 0;
    for (int i = 1; i <= n; i++) {
        int num = 1, den = 1;
        for (int j = 1; j <= n; j++) {
            if (i == j) continue;
            num *= (need - j);
            den *= (i - j);
        }
        res += get(i) * num / den;
    }
    return res;
}
vector<int>g;
int sum[1234567];
bool re()
{
    int sz=g.size();
    int s1=0,s2=0;
    for(int i=0;2*i+1<sz;i++){
        s1+=g[i];
        if(s1<=s2)return false;
        s2+=g[sz-i-1];
    }
    return true;
}
void go(int cnt=0,int s=0)
{
    if (cnt==4) {
        sum[s]++;
        if(re()&&sum[s]==1){
            for(int it:g)cout<<it<<" ";
            exit(0);
        }
        return;
    }
    for(int j=3+cnt;j<=7;j++){
        g.push_back(j);
        go(cnt+1,s+j);
        g.pop_back();
        go(cnt,s);
    }
}
int euler(int n)
{
    int res=n;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0)n/=i;
            res-=res/i;
        }
    }
    if(n>1){
        res-=res/n;
    }
    return res;
}
int dp[303][303][303];
main() {
    int s=0;
    int n=readInt();
    while(n--){
        int x=readInt();
        s^=x;
    }
    puts((s==0)?"Yes":"No");
}
/**
**/




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

int max(int a, int b, int c) {
    return max(max(a, b), c);
}

int main() {

    int n;
    cin >> n;
    int a[n], b[n], c[n];
    int ba[n], bb[n], bc[n];
    for (int i=0; i<n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    ba[0] = a[0];
    bb[0] = b[0];
    bc[0] = c[0];
    for (int i=1; i<n; i++) {
        ba[i] = max(bb[i-1], bc[i-1]) + a[i];
        bb[i] = max(ba[i-1], bc[i-1]) + b[i];
        bc[i] = max(bb[i-1], ba[i-1]) + c[i];
    }
    cout << max(ba[n-1], bb[n-1], bc[n-1]);

}

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

int main() {
    int n, W;
    cin>>n>>W;
    vector<int> w(n),v(n);
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    vector<long long> dp(W+1,0);
    
    for(int i=1;i<=n;i++) {
        for(int j=W;j>=1;j--) {
            if(j>=w[i-1]) 
                dp[j] = max(dp[j], dp[j-w[i-1]] + v[i-1]);
        }
    }
    cout<<dp[W];
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;
using pint = pair<int, int>;

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

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

int main()
{
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))
now = A[0]
kind = 0
ans = 0
for i in range(1,N):
    if kind == 0:
        if now < A[i]:
            kind = 1
        elif now > A[i]:
            kind = 2
    elif kind == 1: # 増加
        if now > A[i]:
            ans += 1
            kind = 0
    else: # 減少
        if now < A[i]:
            ans += 1
            kind = 0
    now = A[i]
print(ans+1)


Measured memory_bytes: 14252
x,y = map(int,input().split())

group1 = [1,3,5,7,8,10,12]
group2 = [4,6,9,11]

if x in group1 and y in group1:
  print('Yes')
elif x in group2 and y in group2:
  print('Yes')
elif x == y == 2:
  print('Yes')
else:
  print('No')

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

using namespace std;

vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define ANTHRO(args...) {__anthro_begin(__LINE__); __anthro(split(#args, ',').begin(), args);}

inline void __anthro_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __anthro_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __anthro_out_var(T* val) { cerr << arrStr(val,2); } //Change the values in case you want to debug something
template<typename T> inline void __anthro_out_var(T val) { cerr << val; }
inline void __anthro(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __anthro(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __anthro_out_var(a);
    cerr << "; ";
    __anthro(++it, args...);
}
//Simple Debugger

#define ll long long
#define MOD 1000000007
#define EPS 1e-9
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
/*
    This is B.Digits
    ABC 156
*/

int main(){
    ll n,k; cin>>n>>k;
    ll an=0;
    while(n){
        n/=k;
        an++;
    }
    cout<<an;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15){
		cout<<"+"<<endl;
	}else if(a*b==15){
		cout<<"*"<<endl;
	}else{
		cout<<"x"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
import sys
import math
input=sys.stdin.readline
from heapq import heappop, heappush, heapreplace

n,m=map(int,input().split())
a=list(map(int,input().split()))
hq=[]
for i in a:
    heappush(hq,-i)    
for j in range(m):
    b=math.ceil(heappop(hq)/2)
    heappush(hq,b)
ans=0
for k in hq:
    ans-=k
print(ans)

Measured memory_bytes: 14380
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break;
            boolean[][] dist = new boolean[26][26];
            int[] deg = new int[26];
            boolean[] used = new boolean[26];
            for(int i=0; i<n; i++){
                char[] in = sc.next().toCharArray();
                int first = (int)(in[0] - 'a');
                int last = (int)(in[in.length-1] - 'a');
                dist[first][last] = true;
                deg[first]++;
                deg[last]--;
                used[first] = used[last] = true;
            }

            boolean boo = true;
            for(int i=0; i<26; i++){
                if(deg[i]!=0) boo = false;
            }
            if(!boo){
                System.out.println("NG");
                continue;
            }

            for(int k=0; k<26; k++)
                for(int i=0; i<26; i++)
                    for(int j=0; j<26; j++)
                        dist[i][j] |= dist[i][k] && dist[k][j];

            for(int i=0; i<26; i++){
                if(!used[i]) continue;
                for(int j=0; j<26; j++){
                    if(!used[j]) continue;
                    if(!dist[i][j]) boo = false;
                }
            }
            if(!boo) System.out.println("NG");
            else System.out.println("OK");
        }
    }

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

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

int main() {
	int a, b, d, r;
	double f;

	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;

	cout << d << ' ' << r << ' ';
	printf("%.6lf\n", f);

	return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;


int main() {
    char s;
    int sum = 0;
    for(int i = 0;i < 4;i++){
        cin >> s;
        if(s == '+')
            sum = sum + 1;
        if(s == '-')
            sum = sum - 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let h: i64 = input();
    let w: i64 = input();
    let a: i64 = input();
    let b: i64 = input();

    let mut factorial = vec![0; (h + w + 1) as usize];
    factorial[0] = 1;
    factorial[1] = 1;
    for i in 1..h + w + 1 {
        factorial[i as usize] = factorial[i as usize - 1] * i % MOD;
    }

    let mut ans = 0;
    let mut i = 0;
    loop {
        let (p, q) = (h - a - i, b + 1 + i);
        if p < 1 || q > w {
            break;
        }
        ans += comb(p - 1 + q - 1, p - 1, &factorial) * comb(h - p + w - q, h - p, &factorial);
        ans %= MOD;
        i += 1;
    }

    println!("{}", ans);
}

const MOD: i64 = 1000000007;

fn comb(n: i64, k: i64, factorial: &Vec<i64>) -> i64 {
    let mut ans = factorial[n as usize];
    ans *= inverse(factorial[(n - k) as usize]);
    ans %= MOD;
    ans *= inverse(factorial[k as usize]);
    ans %= MOD;
    ans
}

fn inverse(n: i64) -> i64 {
    power(n, MOD - 2)
}

fn power(n: i64, p: i64) -> i64 {
    if p == 0 {
        1
    } else if p % 2 == 0 {
        let t = power(n, p / 2);
        t * t % MOD
    } else {
        power(n, p - 1) * n % MOD
    }
}


Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
using namespace std;
#define N (1000000000+7)
typedef pair<int,int> P;
typedef long long ll;

int h,w;
char board[30][30];
bool board1[30][30];
bool check(int i,int j){
    return (i>=1)&&(i<=h)&&(j>=1)&&(j<=w)&&((board[i][j]=='.')||(board[i][j]=='@'))&&(!board1[i][j]);
}

int dfs(int i,int j){
    if(check(i,j)){
        board1[i][j]=true;
        return dfs(i+1,j)+dfs(i-1,j)+dfs(i,j+1)+dfs(i,j-1)+1;
    }
    else return 0;
}

int main(void){
    while(true){
        cin>>w>>h;
        int sx=0,sy=0;
        if((h==0)&&(w==0))break;
        for(int i=0;i<30;i++){
            for(int j=0;j<30;j++){
                board1[i][j]=false;
            }
        }
        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                cin>>board[i][j];
                if(board[i][j]=='@'){
                    sx=i;
                    sy=j;
                }
            }
        }
        cout<<dfs(sx,sy)<<endl;
    }

    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans=0;
  int tmp=0;
  for (int i=0;i<S.size();++i){
    if (S[i]=='I'){
      tmp+=1;
    }
    else tmp-=1;
    if (ans<tmp){
      ans=tmp;
    }
  }
  cout<<ans<<endl;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d;
    string s1;
    cin>>n;
    if(n==0){s1.push_back('0');}
    while(n!=0)
    {
        if(n%-2!=0)
        {
            s1.push_back('1');
            n--;

        }
        else
        {
            s1.push_back('0');
        }
        n=n/(-2);
       // cout<<n<<endl;
    }
    reverse(s1.begin(),s1.end());
    cout<<s1<<endl;
}


Measured memory_bytes: 256