akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    int q;
    cin  >> n >> k >> q;

    vector<int> V(n, 0);
    rep(i,q){
        int tmp;
        cin >> tmp;
        V[tmp-1]++;
    }
    int cnt=0;
    rep(i,n){
        if(k-q+V[i]<=0){
            cout << "No" << endl;
        }
        else{
            cout <<"Yes" << endl;
        }
    }
    // cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    multiset<int,greater<int>> st;
    rep(i,n) {
        int x; cin >> x;
        st.insert(x);
    }
    int ans = 0;
    while (!st.empty()) {
        int x = *st.begin();
        st.erase(st.begin());
        for (int i = 1; i <= 30; i++) {
            int y = 1<<i;
            if (x < y && y <= 2*x) {
                if (st.count(y-x)) {
                    ans++;
                    st.erase(st.find(y-x));
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12960
#include<iostream>
#include<algorithm>
using namespace std;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  int n,a[100010],b,c;
  cin>>n;
  fr(i,n) cin>>a[i];
  sort(a,a+n);
  if(a[n-1]-a[0]>1){
    cout<<"No"<<endl;
    return 0;
  }
  b=a[0];
  if(a[0]==a[n-1]){
    if(b<=n/2 || b==n-1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
  }
  fr(i,n){
    if(a[i]>b){
      c=i;
      break;
    }
  }
  if(b-c+1<=0 || 2*(b-c+1)>n-c) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<vector<int>> a(26);
	rep(i,s.size()) a[ s[i] - 'a' ].emplace_back(i);

	set<char> st;
	vector<int> c;
	for(int i = s.size() - 1; i >= 0; i--){
		st.emplace(s[i]);
		if(st.size() == 26){
			st.clear();
			c.emplace_back(i);
		}
	}
	reverse(all(c));

	if(c.size() == 0){
		rep(i,26){
			if(not st.count(i + 'a')){
				printf("%c\n", i + 'a');
				return 0;
			}
		}
	}

	int pos = -1;
	string ans;
	rep(_,c.size() + 1){
		rep(i,26){
			auto p = lower_bound(all(a[i]), pos);
			if(p == a[i].end() or lower_bound(all(c), pos) - c.begin() == lower_bound(all(c), *p + 1) - c.begin() - 1){
				ans += 'a' + i;
				pos = *p + 1;
				break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,p,ans = 0;
  cin >> n;
  p = sqrt(n);
  for(long long i = 1 ; i <= p ; ++i) 
    if(n % i == 0) {
      if(i != 1 && n/(i-1)*i == n) ans += i-1;
      if(i*i != n) {
        long long k = n/i;
        if(n/(k-1)*k == n) ans += k-1;
      }
    }
  cout << ans << endl;
  return 0;
}

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

class Program {
  static void Main() {
    var s = new string(Console.ReadLine().Distinct().ToArray());
    if (s.Any(x => x == 'N') == s.Any(x => x == 'S') && s.Any(x => x == 'E') == s.Any(x => x == 'W')) {
      Console.WriteLine("Yes");
    } else {
      Console.WriteLine("No");
    }
  }
}

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


def main():
    N = int(input())
    S = input().strip()

    if N % 2 != 0:
        print("No")
        exit()
    for i in range(N // 2):
        if S[i] != S[i + N // 2]:
            print("No")
            exit()

    print("Yes")

if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include<iostream>

using namespace std;

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

long long mem[10][102][1001];

long long solve(int a, int b, int c) {
  if (mem[a][b][c] != -1) return mem[a][b][c];
  if (a == 0) return 0;
  mem[a][b][c] = 0;
  rep (i, b) mem[a][b][c] += solve(a - 1, i, c - i);
  return mem[a][b][c];
}

int main() {
  int n, s;
  while (cin >> n >> s, n) {
    rep (i, n + 1) rep (j, 102) rep (k, s + 1) mem[i][j][k] = -1;
    rep (i, 102) mem[0][i][0] = 1;
    cout << solve(n, 101, s) << endl;
  }
  return 0;
}

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


using namespace std;

#ifdef CLION
ifstream ifs("/home/kyuridenamida/CLionProjects/project/input.txt");
#define cin ifs
#define scanf DONT_USE_SCANF
#endif

int main() {
    int N;
    cin >> N;
    set<int> S;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        S.insert(A);
    }
    if (S.size() == N) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    int res = 0;
    rep(i,n){
        ll x;
        cin >> x;
        while(x%2==0){
            x/=2;
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  ll ans = 1;

  while(true) {
    if (ans * x % 360 == 0) break;
    ans++;
  }


  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3672
var
 a:array[0..1000] of ansistring;
 n,m,i,j:longint;
 t:ansistring;
begin
 readln(n,m);
 for i:=1 to n do
  readln(a[i]);
 for i:=1 to n-1 do
  for j:=i+1 to n do
   if a[i]>a[j] then begin
    t:=a[i]; a[i]:=a[j]; a[j]:=t; end;
 for i:=1 to n do
  write(a[i]);
end.

Measured memory_bytes: 128
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll h=in();
    ll ans=1;while(ans<h)ans=ans<<1|1;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from math import sqrt
n, m = [int(x) for x in input().split()]

def getDiviser(x):
  result = []
  for i in range(1, int(sqrt(x))+2):
    if x % i == 0:
      result.append(i)
      result.append(x//i)
  result.sort()
  result.reverse()
  return result

for x in getDiviser(m):
  if m//x >= n:
    print(x)
    break
else:
  print(0)
  

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
typedef pair<int, vector<int> > P;
map<P, int> memo;
int dfs(int k, vector<int>& cur, const vector<int>& s, map<int, int>& cnt){
  int L = cur.size(), N = s.size();
  P p(k, cur);
  if(memo.count(p)) return memo[p];
  int& res = memo[p];
  res = INF;
  int S = s[k];
  for(int i = L - 1; i >= 0; i--){
    if(S >> i & 1) break;
    if(cur[i] != 0) return res;
  }
  if(k + 1 == N) return res = 0;
  int use = cnt[S];
  for(int i = 0; i < L; i++) if(S >> i & 1) use = min(use, cur[i]);
  for(int i = 0; i <= use; i++){
    vector<int> tmp = cur;
    for(int j = 0; j < L; j++) if(S >> j & 1) cur[j] -= i;
    res = min(res, dfs(k + 1, cur, s, cnt) + i);
    cur = tmp;
  }
  //printf("dfs(S = %d) : ", S); REP(i, L) cout << cur[i] << " "; cout << endl;
  return res;
}
int main(){
  int H, W;
  while(cin >> H >> W && H){
    memo.clear();
    map<int, int> cnt;
    vector<int> s;
    vector<string> grid(H);
    REP(y, H) cin >> grid[y];
    vector<int> mx, my;
    vector<int> cur;
    REP(y, H)REP(x, W)if(isdigit(grid[y][x])){
      mx.push_back(x);
      my.push_back(y);
      cur.push_back(grid[y][x] - '0');
    }
    int L = mx.size();
    REP(y, H)REP(x, W)if(grid[y][x] != '.'){
      int S = 0;
      REP(i, L)if(abs(mx[i] - x) <= 1 && abs(my[i] - y) <= 1){
        S |= 1 << i;
      }
      cnt[S] += 1;
      if(cnt[S] == 1) s.push_back(S);
    }
    s.push_back(0); //last
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    cout << dfs(0, cur, s, cnt) << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	sort(h.begin(), h.end());
	long long ans = 0;
	for (int i = 0; i < n - k; ++i)
		ans += h[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    map<int, int> a;
    int sum = 0;
    a[0] = 1;
    for (int i = 1; i <= n; i++) {
        int b; scanf(" %d", &b);
        sum = (sum + b) % m;
        if (a.find(sum) == a.end()) a[sum] = 1;
        else a[sum]++;
    }
    long long ans = 0;
    for (map<int, int>::iterator it = a.begin(); it != a.end(); it++) {
        long long x = it->second;
        ans += x * (x - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
 
signed main()
{
  int k;
  string s;
  cin >> k >> s;
  if(s.length() <= k){
      cout << s << "\n";
      return 0;
  }else{
      cout << s.substr(0,k) << "..." << "\n";
  }
}

Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;


class Hoge{
		
		public:
		int A,B,H,M;
		double danswer;
		const double PI=3.14159265358979323846;
		string s0,s1;		
		Hoge(string);
		void angle();
		};

Hoge::Hoge(string s):s1(s){}

void Hoge::angle(){
		
			if (s1[0]>='a'&&s1[0]<='z'){cout<<"a"<<endl;}
			else{cout<<"A"<<endl;}
		}




int main(){
		int A,B,H,M;
		string s0;		
		cin>>s0;
		Hoge hoge(s0);
		hoge.angle();
		
		}

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

int ring(char s[101],char p[101]){
	int i=0;
	int n = strlen(s),count;
	while (i<=2*n){
		count = 0;
		if (p[0] == s[i]){
			while (p[0 + count] == s[(i + count) % n]){
				count++;
				if (count == strlen(p))
					return 1;
			}
		}
		i++;
	}
		return 0;
}

int main(void){
	char s[101];
	char p[101];
	int i = 0;
	while (1){
		scanf("%c", &s[i]);
		if (s[i] == '\n')
			break;

		i++;
	}
	s[i] = '\0';

	i = 0;
	while (1){
		scanf("%c", &p[i]);
		if (p[i] == '\n')
			break;

		i++;
	}
	p[i] = '\0';

	if (ring(s, p) == 1)
		printf("Yes\n");
	else if (ring(s, p) == 0)
		printf("No\n");
	else
		; //何もしない


	return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#include<chrono>
#define ll long long
#define ld long double
#define eb emplace_back
#define pb push_back
#define mt make_tuple
#define tc  ll t; cin>>t; while(t--)
#define io ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define vi vector<ll>
#define pii pair<ll,ll>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define vii vector<pair<ll,ll>>
ll gcd(ll n,ll m)
{
    if(n==0)
            return m;
    return gcd(m%n,n);
}
bool ifprime(ll n)
{
if(n==1)
return false;
    ll i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
return false;
 
}
return true;
}
void disp(vi v)
{
    for(auto u:v)
    cout<<u<<" ";
    cout<<"\n";
}
void remleadzero(vector<int> &v)
{
    vector<int> u;
    int i=0;
    while(v[i]==0)
        i++;
    while(i<v.size())
    {
        u.push_back(v[i]);
        i++;
    }
    v=u;
}
#define mod 1000000007LL
/*
void myscanf(long long *n)
{
    register long long c=getchar_unlocked();
    *n=0;
    for(;(c<48 ||c>57);c=getchar_unlocked())
        ;
    for(;(c>47 && c<58);c=getchar_unlocked())
    {
        *n=(*n<<1)+(*n<<3)+(c&15);
    }
 
}
void fastscan(long long &number)
{
    bool negative = false;
    register long long c;
 
    number = 0;
 
    c = getchar_unlocked();
    if (c=='-')
    {
 
        negative = true;
 
        c = getchar_unlocked();
    }
 
 
    for (; (c>47 && c<58); c=getchar_unlocked())
        number = number *10 + c - 48;
 
 
    if (negative)
        number *= -1;
}
*/
ll fast_expo(ll n,ll m, ll md)
{
    ll a=1;
    while(m>0)
    {
        if(m&1) a=(a*n)%md;
        n=(n*n)%md;
        m/=2;
    }
    return a%md;
}
// checks if a number is a perfect square in almost O(1) time
long long sqroot(long long n){
    long double N = n;
    N = sqrtl(N);
    long long sq = N-2;
    sq = max(sq,0LL);
    while(sq*sq<n){
        sq++;
    } 
    if((sq*sq)==n)
        return sq;
    return -1;
}
int dig_sum(ll n){
    int ret=0;
    while(n>0){
        ret+=(n%10);
        n/=10;
    }
    return ret;
}


int main()
{
    io;
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4]==s[5])
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

fn main() {
    input! {
        a: i64, b: i64
    }

    let p = a + b;
    let q = a - b;
    let r = a * b;
    println!("{}", std::cmp::max(std::cmp::max(p,q),r));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define debug(x) std::cout << #x << ": " << x << '\n';
#define pb push_back
const int N = 2e5 + 10, LOG = 25;
int a[N];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, k;
    std::cin >> n >> k;
    FOR(i, n) {
    	std::cin >> a[i];
    }
    std::set<int> kek;
    ll answ = 1;
    FOR(i, k) {
    	kek.insert(a[i]);
    }
    int cnt = 0;
    FOR(i, k - 1) {
    	cnt += a[i] < a[i + 1];
    }
    bool fl = (cnt == k - 1);
    for (int i = k; i < n; ++i) {
    	bool ck = kek.find(a[i - k]) == kek.begin();
    	kek.erase(a[i - k]);
    	kek.insert(a[i]);
    	ck &= kek.find(a[i]) == (std::prev(kek.end()));
    	cnt -= a[i - k] < a[i - k + 1];
    	cnt += a[i - 1] < a[i];
    	if (!ck && cnt == k - 1 && !fl) {
    		fl = true;
    		answ++;
    	}
    	else if (!ck && cnt != k - 1) {
    		answ++;
    	}
    }
    std::cout << answ;
}


Measured memory_bytes: 10368
import sys
N = int(input()) 
A = [int(sys.stdin.readline()) for _ in range(N)]
b = 0
for i, a in enumerate(A):
    if i + b < a:
        print(-1)
        sys.exit()
    else:
        b = a - i
ans = 0
pre = -1
for a in A[::-1]:
    if pre - 1 != a:
        ans += a
    pre = a

print(ans)

Measured memory_bytes: 12584
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define ll long long
#define rn(i,n) for(int i=1;i<=n;i++)



int main (){
  int n;
  cin>>n;
  vector<int> a(n),b;
  r(i,n)cin>>a.at(i);
  reverse(a.begin(),a.end());

  for(int i=0;i<n;i++){
    //int tmp=(n-1)%2;
    if(i%2==0){
      b.insert(b.begin()+i/2,a.at(i));
      //r(j,b.size())cout<<b.at(j)<<" ";
      //cout<<endl;
    }else{
      b.insert(b.end()-i/2,a.at(i));
      //r(j,b.size())cout<<b.at(j)<<" ";
      //cout<<endl;
    }
  }
  r(i,n){
    cout<<b.at(i)<<" ";
  }
  cout<<endl;

  return 0;
}


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

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

    const char *s = nullptr;
    switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        s = "hon";
        break;

    case 0:
    case 1:
    case 6:
    case 8:
        s = "pon";
        break;

    case 3:
        s = "bon";
        break;
    }

    cout << s;
    return 0;
}


Measured memory_bytes: 3596
N, T = map(int, input().split())
dp = [[0 for j in range(T)] for i in range(N)]
W = []
V = []
for i in range(N):
    w, v = map(int, input().split())
    W += [w]
    V += [v]
    
W, V = zip(*sorted(zip(W, V), key=lambda x: x[0]))
for i in range(N-1):
    for j in range(T):
        if j - W[i] < 0 :
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-W[i]] + V[i])
ans = 0
for i in range(N):
    ans = max(ans, dp[i][-1] + V[i])
print(ans)


Measured memory_bytes: 155216
x,y = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(0,101):
  no = x-i
  if ps.count(no) == 0 & (no > 0):
    print(no)
    exit()
  no = x+i
  if ps.count(no) == 0 & (no < 101):
    print(no)
    exit()

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

int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 1);//葉の数
  
  int64_t D = 0;//Dは分岐点の数
  int64_t T = 0;//深さiの頂点数
  int64_t P = 1;//深さi+1の頂点数
  bool imp = false;//２分木がつくれないときtrue
  
  for(int i = 0; i < N + 1; i++)
  {
    cin >> A.at(i);
    D += A.at(i);
  }
  
  D--;
  
  //ここまでOK
  
  for(int j = 0; j < N + 1; j++)
  {
    T += P;
    P -= A.at(j);//深さjで分岐できる頂点の数
    if(P < 0)
    {
      imp = true;
      break;
    }
    if(D >= P)
    {
      D -= P;
      P *= 2;
    }
    else if(D < P && P != 0)
    {
      P += D;
      D = 0;
    }
  }
  
  if(imp){cout << "-1" << endl;}
  else{cout << T << endl;}
}

Measured memory_bytes: 3724
#include <iostream>
#include <list>
#include <string>
#include<algorithm>
using namespace std;

std::list<int> intList;

void insertFirst(int num) {
	intList.push_front(num);
}

void deleteNum(int num) {
	/*
	for(std::list<int>::iterator itr = intList.begin(); itr != intList.end(); *itr++) {
		if (*itr == num) {
			intList.erase(itr);
			break;
		}
	}*/

	std::list<int>::iterator itr = find(intList.begin(),intList.end(), num);
	if(itr != intList.end()) {
		intList.erase(itr);
	}
}

void deleteFirst() {
	intList.pop_front();
}

void deleteLast() {
	intList.pop_back();
}

int main(int argc, char const* argv[])
{
	ios::sync_with_stdio(false); 
	int n;
	cin >> n;
	for (int i=0; i<n; i++) {
		int inputNum;
		string command;
		cin >> command;
		if (command == "insert") {
			cin >> inputNum;
			insertFirst(inputNum);
		} else if (command == "delete") {
			cin >> inputNum;
			deleteNum(inputNum);
		} else if (command == "deleteFirst") {
			deleteFirst();
		} else if (command == "deleteLast") {
			deleteLast();
		}
	}

	for(std::list<int>::iterator itr = intList.begin(); itr != intList.end(); *itr++) {
		cout << *itr;
		if (itr == --intList.end()) {
			cout << "\n";
		} else {
			cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 32480
def main():
    S = input()
    wi = 0
    lo = 0
    g = 0
    p = 0
    for s in S:
        if s == "g":
            if p < g:
                p += 1
                wi += 1
            else:
                g += 1
        else:
            if p < g:
                p += 1
            else:
                g += 1
                lo += 1
    print(wi - lo)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39792
n=int(input())
l=list(map(int,input().split()))
a=0
for i in range(len(l)):
    if a<=l[i]:
        a,l[i]=l[i],l[i]-a
    else:
        a=l[i]
        l[i]=0
ans=0
for i in l:
    ans+=i
print(ans)

Measured memory_bytes: 3064
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

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;  }
template<class T>void put_double(T a){cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int main(void) {
    string s, t; cin >> s >> t;
    t.pop_back();
    if(s == t) {
        println("Yes");
    } else {
        println("No");
    }

    return 0;
}


Measured memory_bytes: 3636
import sys
def I():
    return int(sys.stdin.readline().rstrip())

N = I()

L = []
for i in range(N+1):
    if i == 0:
        L.append(2)
    elif i == 1:
        L.append(1)
    else:
        L.append(L[-1]+L[-2])
print(L[-1])

Measured memory_bytes: 61700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll d;
vector<vl> s;
vl c(26);
vector<set<ll>> st(26, {-1});
ll score;

void add(ll i, ll k) {  // i日目(0-index)、テストk（0-index）
  st[k].insert(i);
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score += c[k] * (i - prev) * (next - i) + s[i][k];
}

void rm(ll i, ll k) {
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score -= c[k] * (i - prev) * (next - i) + s[i][k];
  st[k].erase(i);
}

void eval(vl &t) {
  rep(i, d) {
    ll k = t[i];
    add(i, k);
  }
}

int main() {
  double limit = double(clock()) / double(CLOCKS_PER_SEC) + 1.95;
  // 入力をもらう
  cin >> d;
  rep(i, 26) cin >> c[i];
  s.resize(d, vl(26));
  rep(i, d) rep(j, 26) cin >> s[i][j];

  //// 入力を作るデバッグ用
  // d = 365;
  // s.resize(d, vl(26));
  // rep(i, 26) c[i] = rand() % 101;
  // rep(i, d) rep(j, 26) s[i][j] = rand() % 20001;

  // 初期解をランダムに作って評価、scoreに反映
  score = -accumulate(all(c), 0LL) * d * (d + 1) / 2;
  vl t(d);
  rep(i, d) t[i] = max_element(all(s[i])) - s[i].begin();
  eval(t);

  vl ans = t;
  ll mx = 0;

  while(double(clock()) / double(CLOCKS_PER_SEC) < limit) {
    ll xd = rand() % d;
    ll xt = rand() % 26;
    ll old_score = score;
    ll old_test = t[xd];
    if(xt == t[xd]) xt = (xt + 1) % 26;
    rm(xd, t[xd]);
    add(xd, xt);
    ll e = rand() % 100;
    if(score < old_score || e < 5) {
      rm(xd, xt);
      add(xd, old_test);
    } else {
      t[xd] = xt;
      if(score > mx) {
        ans = t;
        mx = score;
      }
    }
  }
  rep(i, d) cout << ans[i] + 1 << '\n';
}

Measured memory_bytes: 3800
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()

l = []
for i in range(5):
    l.append(I())

min_value = min(l)
hoge = math.ceil(N / min_value)
#  print(hoge)
print(hoge+4)
#  counts = [N,0,0,0,0,0]
#  result = 0
#  while counts[-1] != N:
#      tmp = [_ for _ in counts]
#      for c in reversed(range(1, 6)):
#          if counts[c-1] > 0:
#              change = min(l[c-1], counts[c-1])
#              counts[c-1] -= change
#              counts[c] += change
#      print(counts)
#      result += 1
#  print(result)


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);

    int n, l;
    cin >> n >> l;

    int sum = (l-1)*n;
    int mi = l;
    for(int i = 1;i <= n; i++){
        sum += i;
        if (abs(l +i + -1) < abs(mi)) mi = l+i-1;
    }
    cout << sum - mi << endl;
}


Measured memory_bytes: 256
we = str(input())
r = we.split(" ", -1)

A = r[0]
B = r[1]
C = r[2]
K = r[3]
A = int(A)
B = int(B)
C = int(C)
K = int(K)

def max_sum(A, B, C, K):
	if ((A and B and C and K) >= 0) and (A + B + C >= K):   
		if A >= K:
			print(K)
		elif A < K:
			R = K - A
			if B >= R:
				print(A)
			elif B < R:
				S = R - B
				print(A + S*(-1))
max_sum(A, B, C, K)
    

Measured memory_bytes: 9220
#include <iostream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};

int W, H;

inline bool inrect(int x, int y){
    return 0 <= x && x < H && 0 <= y && y < W;
}

int dfs(vector<string>& room, int x, int y){
    room[x][y] = '#';
    int res = 1;
    rep(i, 4){
        int nx = x + dx[i], ny = y + dy[i];
        if(!inrect(nx, ny) || room[nx][ny] == '#')continue;
        res += dfs(room, nx, ny);
    }
    return res;
}

int main(){
    while(cin >> W >> H, W|H){
        vector<string> room(H);
        int sx = -1, sy = -1;
        rep(i, H){
            cin >> room[i];
            rep(j, W)if(room[i][j] == '@')sx = i, sy = j;
        }
        cout << dfs(room, sx, sy) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>

int main() {
    int N,M;
    cin >> N >> M;
    vector<P> A(M);
    for(int i=0; i<M; ++i) cin >> A[i].second >> A[i].first;
    sort(A.begin(), A.end());

    int prev = A[0].first - 1;
    int ans = 1;
    for(int i=1; i<M; ++i) {
        if(A[i].second <= prev) continue;
        else {
            prev = A[i].first - 1;
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
// abc098_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B;
    cin >> A >> B;

    int ans = max(A + B, A - B);
    ans = max(ans, A * B);

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;
    int X[N];
    int Y[N];
    for(int i= 0;i<N;i++){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(X,X+N);
    int ans1 = X[N/2 -1];
    int ans2 = X[N/2];
    for(int i = 0;i<N;i++){
        if(Y[i] <= ans1) cout << ans2 << endl;
        else cout << ans1 << endl;
    }
    return 0;
}


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

using namespace std;
#define ull unsigned long long
#define ll long long
const double inf = 2e9;
const int MAXN = 2e5 + 10;
ll mod = 998244353;
vector<vector<pair<int, int>>> data(15, vector<pair<int, int>>());
bool check(int k, int n){
    for(int i=0;i<n;i++){
        if(((k>>i)&1)!=1) continue;
        for(auto &p:data[i]){
            if(p.second==0 && ((k>>p.first)&1)!=0) return false;
            if(p.second==1 && ((k>>p.first)&1)==0) return false;
        }
    }
    return true;

}
void solve() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        for (int j=0;j<d;j++){
            int x,y;
            cin>>x>>y;
            data[i].push_back({--x,y});
        }
    }
    int ans=0;
    for(int i=0;i<=((1<<N)-1);i++){
        if(check(i, N)){
            int tmp=i;
            int res=0;
            for(int j=0;j<N;j++){
                res+=(tmp&1);
                tmp>>=1;
            }
            ans=max(ans, res);
        }
    }
    cout<<ans;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n = 1;
    for (int i = 0; i < n; i++) solve();
    return 0;
}

Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bits (shiftR)

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print $ shiftR (pred n) 1

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N = int(input())
    W = list(map(int, input().split()))

    l, r = 0, sum(W)
    ans = abs(r - l)
    for i in range(N):
        l += W[i]
        r -= W[i]
        ans = min(ans, abs(r - l))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include<iostream>
#include<string>

using namespace std;

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

	if (s == "A") {
		cout << "T" << endl;
	}
	else if (s == "T") {
		cout << "A" << endl;
	}
	else if (s == "C") {
		cout << "G" << endl;
	}
	else {
		cout << "C" << endl;
	}
}

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

ULL mpow(ULL a,ULL i,ULL M) {
 if(i==0) return 1;
 ULL r=mpow(a*a%M,i>>1,M);
 if(i&1) r=r*a%M;
 return r;
}

void NTT(vector<ULL>& A,ULL M,ULL g){
 int N=A.size();
 for(int i=0,j=0; j<N; j++){
  if(i<j) swap(A[i],A[j]);
  for(int k=N>>1; k>(i^=k); k>>=1);
 }
 for(int i=1; i<N; i<<=1){
  ULL q=mpow(g,(M-1)/i/2,M), qj=1;
  rep(j,i){
   for(int k=j; k<N; k+=i*2){
    ULL l=A[k],r=A[k+i]*qj%M;
    A[k]=(l+r); if(A[k]>=M) A[k]-=M;
    A[k+i]=(l+M-r); if(A[k+i]>=M) A[k+i]-=M;
   }
   qj=qj*q%M;
  }
 }
}

struct Fuse{ ULL M,G; };

vector<ULL> TNT(const vector<ULL>& A,const vector<ULL>& B,Fuse F) {
 int Z=1; while(Z<A.size()+B.size()) Z<<=1;
 vector<ULL> Ax(Z),Bx(Z);
 ULL iZ=mpow(Z,F.M-2,F.M);
 rep(i,Z) Ax[i]=Bx[i]=0;
 rep(i,A.size()) Ax[i]=A[i];
 rep(i,B.size()) Bx[i]=B[i];
 NTT(Ax,F.M,F.G);
 NTT(Bx,F.M,F.G);
 rep(i,Z) Ax[i]=Ax[i]*Bx[i]%F.M;
 NTT(Ax,F.M,mpow(F.G,F.M-2,F.M));
 rep(i,Z) Ax[i]=Ax[i]*iZ%F.M;
 return move(Ax);
}

const Fuse fuse = {998244353,3};

int zA,zB;
vector<ULL> A,B;
vector<ULL> ans;

int main(){
 scanf("%d%d",&zA,&zB);
 A.resize(zA); B.resize(zB);
 rep(i,zA) scanf("%llu",&A[i]);
 rep(i,zB) scanf("%llu",&B[i]);
 ans = TNT(A,B,fuse);
 rep(i,zA+zB-1){
  if(i) printf(" ");
  printf("%llu",ans[i]);
 }printf("\n");
 return 0;
}


Measured memory_bytes: 27816
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;

#define M 1046527

long long T[M];
//???????????\??¢??°
int h1(long long key) { return key % M; }

int h2(long long key) { return 1 + (key % (M - 1)); }

int h(long long key, int i) { return ((h1(key)) + i*h2(key)) % M; }

void insert(long long key)
{
	int i = 0;
	while (1) {
		int j = h(key, i);
		if (!T[j]) {
			T[j] = key;
			return;
		}
		else i++;
	}
}

bool find(long long key)
{
	int i = 0;
	while (1) {
		int j = h(key, i);
		if (T[j] == key) return 1;
		else if (!T[j]) return 0;
		else i++;
	}
}

long long getKey(char *p)
{
	long long key = 0;
	for (int i = (strlen(p) - 1); i >= 0; i--) {
		long long x;
		switch (p[i])
		{
		case 'A':
			x = 1; break;
		case 'C':
			x = 2; break;
		case 'G':
			x = 3; break;
		case 'T':
			x = 4; break;
		default:
			break;
		}
		key += x * pow(10, i);
	}
	return key;
}

int main()
{
	int n;
	char order[10], word[15];
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%s %s", order, word);
		if (order[0] == 'i') insert(getKey(word));
		else if (find(getKey(word))) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 9396
MOD = 10 **9 + 7
INF = 10 ** 10
from heapq import heapify,heappop,heappush

def main():
    k,t = map(int,input().split())
    A = list(map(int,input().split()))
    if t == 1:
        print(k - 1)
        return
    A = [(-A[i],i) for i in range(t)]
    heapify(A)
    
    before = -1
    ans = 0
    for _ in range(k):
        p,i = heappop(A)
        if i != before:
            p += 1
            before = i
            heappush(A,(p,i))
        else:
            q,j = heappop(A)
            if q < 0:
                q += 1
                before = j
                heappush(A,(q,j))
                heappush(A,(p,i))
            else:
                p += 1
                ans += 1
                heappush(A,(p,i))
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; string a,b,c; cin >> N>>a>>b>>c;

    int ans = 0;
    rep(i,N) {
      if(a[i] != b[i] and b[i] != c[i] and c[i] != a[i]) ans += 2;
      else if(a[i] == b[i] and b[i] != c[i]) ans++;
      else if(a[i] != b[i] and b[i] == c[i]) ans++;
      else if(a[i] == c[i] and a[i] != b[i]) ans++;
      else continue;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
 int count=0;
 while(n--){
    long long int a,b;
  cin>>a>>b;
 long double c=sqrt(a*a+b*b);
  if(c<=d){
      count++;
  }
}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 3684
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>

using namespace std;

typedef pair<int, int> II;
typedef pair<double, II> DII;

vector<DII> v;

void solve(long long n) {
	double x = 4.0 / n;
	double diff = 1e9;
	int p, q, r;
	for (int i = 1; i <= 3500; ++i) {
		double y = 1.0 / i;
		vector<DII>::const_iterator it = lower_bound(v.begin(), v.end(), DII(x - y - 1e-7, II(0, 0)));
		for (; it != v.end(); ++it) {
			if (it->first > (x-y+1e-7)) {
				break;
			}
			II k = it->second;
			double hnw = 1.0 * k.first * k.second * i;
			double d = fabs(hnw / k.first + hnw / k.second + hnw / i - (hnw * 4.0) / n);
			if (d < diff) {
				p = i, q = k.first, r = k.second;
				diff = d;
			}
		}
	}
	cout << p << " " << q << " " << r << endl;
}

int main(int argc, char *argv[])
{
	for (int i = 1; i <= 3500; ++i) {
		for (int j = i; j <= 3500; ++j) {
			v.push_back(DII((1.0 / i) + 1.0 / j, II(i, j)));
		}
	}
	sort(v.begin(), v.end());
	long long n;
	cin >> n;
	solve(n);
}



Measured memory_bytes: 133352
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = new int[n];
        for(int i=0; i<n; i++) {
            aa[i] = int.Parse(input.ReadLine());
        }

        Array.Sort(aa);

        Func<int, int ,long> sum = (s, e) => {
            long y = 0;
            for(int i=s; i<=e; i++) y+= aa[i];
            return y;
        };


        if(n % 2 == 0) {
            int ss = 0;
            int se = n/2 -1;
            int bs = n/2;
            int be = n-1;

            long y = -2 * sum(ss, se) + 2 * sum(bs, be);
            long y1 = y + aa[se] - aa[bs];
            return y1;
        } else {
            int ss = 0;
            int se = n / 2;
            int bs = n / 2 + 1;
            int be = n - 1;

            long y = -2 * sum(ss, se) + 2 * sum(bs, be);
            long y1 = y + aa[se] + aa[se - 1];

            ss = 0;
            se = n / 2 - 1;
            bs = n / 2;
            be = n - 1;

            long z = -2 * sum(ss, se) + 2 * sum(bs, be);
            long z1 = z - aa[bs] - aa[bs + 1];

            return Math.Max(y1, z1);
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 15452
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl
#warning do not forget to change size of N and M  and -01 to -02
typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10;
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS; }
char str[N];

int main()
{
  int n,x=0,ans=0;
  scanf("%d",&n);
  scanf("%s",str);
  for(int i=0;i<n;++i)
  {
    if(str[i]=='I') x++;
    else x--;
    ans = max(ans,x);
  }
  printf("%d",ans);
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//入力

int main(){
    ll n,d;
    cin >> n >> d;
    ll ans = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d)ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
//srandom((unsigned long)time(NULL));
string s;
cin>>s;
bool cafe=true;
if(s[2]!=s[3] || s[4]!=s[5])cafe=false;

if(cafe)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(50)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double L;
    cin >> L;
    double T = 2.0 * L / 3.0;

    double ans = T * (L - T) * (L - T) / 2.0;
    cout << OF64 << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::i64;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let mut n: i64 = read();
    let k: i64 = read();
    let mut sum: i64 = 0;
    while n!=0{
	sum+=1;
	n /= k;
    }
    println!("{}",sum);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
int main(){
	size_t len;
	string str,code;
	int time,pro1,pro2;
	cin>>str>>time;
	for(int abc=0;abc<time;abc++){
		string damy;
		cin>>code>>pro1>>pro2;
		if(code=="print"){
			cout<<str.substr(pro1,pro2-pro1+1)<<endl;
		}else{
			if(code=="replace"){
				cin>>damy;
			}else{
				for(int abcd=pro2;abcd>=pro1;abcd--){
					damy+=str[abcd];
				}
			}
			str=str.substr(0,pro1)+damy+str.substr(pro2+1);
		}
	}
	return 0;
}

Measured memory_bytes: 1228
import math
a,b,x=map(int,input().split())
if(x > a*a*b/2):
    tanr=(2*b)/a - (2*x)/(a**3)
    print(math.degrees(math.atan(tanr)))
else:
    tanr=(a*b*b)/(2*x)
    print(math.degrees(math.atan(tanr)))

Measured memory_bytes: 3060
h,w,m=map(int,input().split())
row=[0 for i in range(h)]
col=[0 for i in range(w)]
a=[]
for i in range(m):
    r,c=map(lambda x:int(x)-1,input().split())
    a.append([r,c])
    row[r]+=1
    col[c]+=1
rmax=max(row)
cmax=max(col)
ans=rmax+cmax
flag=row.count(rmax)*col.count(cmax)
for i,j in a:
    if(row[i]==rmax and col[j]==cmax):
        flag-=1
if(flag==0):
    ans-=1
print(ans)

Measured memory_bytes: 58820