akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

template<typename T> inline void // i & j should be *strictly* more than zero
inc(size_t i, const size_t j, const T val, vector<vector<T>> & fen)
{
    for(const auto n = fen.size(), m = fen.front().size(); i < n; i += i & -i)
        for(size_t k = j; k < m; k += k & -k)
            fen[i][k] += val;
}

template<typename T> inline T  // i or j may be zero (if so, will return zero)
acc(size_t i, const size_t j, const vector<vector<T>> & fen)
{
    T out = 0;
    for(; i; i -= i & -i)
        for(size_t k = j; k; k -= k & -k)
            out += fen[i][k];

    return out;
}

void print_matrix(const size_t n, const size_t m,
                  const vector<vector<int64_t>> & fen)
{
#ifdef BUG
  cout << '\n';
  for(size_t i = 0; i < n; ++i)
    for(size_t j = 0; j < m; ++j)
    {
      const auto v = acc(i + 1, j + 1, fen)
        - acc(i, j + 1, fen) - acc(i + 1, j, fen)
        + acc(i, j, fen);
      cout << v << " \n"[j + 1 == m];
    }
#endif
}

void argc016_c()
{
  size_t n, m, x, y;
  cin >> n >> m >> x >> y;

  if(x * y == 1)
  {
    cout << "No";
    return;
  }

  const int64_t ub = (1000000000 - 1) / (x * y - 1);
  vector<vector<int64_t>> fen(n + 1, vector<int64_t>(m + 1));

  for(size_t i = 1; i < n + 1; ++i)
    for(size_t j = 1; j < m + 1; ++ j)
      if(i < x || j < y)
        inc(i, j, (int64_t) ub, fen);
      else
      {
        const auto v = acc(i, j, fen)
          - acc(i - x, j, fen) - acc(i, j - y, fen)
          + acc(i - x, j - y, fen);

        inc(i, j, -1 - v, fen);
      }

  print_matrix(n, m, fen);

  if(acc(n, m, fen) < 1)
  {
    cout << "No";
    return;
  }

  cout << "Yes" << '\n';
  for(size_t i = 0; i < n; ++i)
    for(size_t j = 0; j < m; ++j)
    {
      const auto v = acc(i + 1, j + 1, fen)
        - acc(i, j + 1, fen) - acc(i + 1, j, fen)
        + acc(i, j, fen);
      cout << v << " \n"[j + 1 == m];
    }

}

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

  return EXIT_SUCCESS;
}


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

int main() {
    int cards[4][14] = {0};
    int count, cardNum, simbolNum;
    int i, j;
    char simbol;
    
    cin >> count;
    for(i = 0; i < count; i++){
        cin >> simbol >> cardNum;
        if('S' == simbol){
            simbolNum = 0;
        }else if('H' == simbol){
            simbolNum = 1;
        }else if('C' == simbol){
            simbolNum = 2;
        }else if('D' == simbol){
            simbolNum = 3;
        }else{
            return 0;
        }
        cards[simbolNum][cardNum] = 1;
    }

    for(i = 0; i < 4; i ++){
        for(j = 1; j < 14 ; j++){
            if(cards[i][j] == 0){
                if(0 == i){
                    cout << "S" << " " << j << endl;
                }else if(1 == i){
                    cout << "H" << " " << j << endl;
                }else if(2 == i){
                    cout << "C" << " " << j << endl;
                }else if(3 == i){
                    cout << "D" << " " << j << endl;
                }
            }
        }
    }
	return 0;
}



Measured memory_bytes: 3080
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・適当な部分空間なので、達成可能でありさえすれば数え上げは簡単
・対角成分に関して向かい側はまとめる。「必ず0」「必ず1」「free」
・対角から遠いところについては調整不可能。「必ず1」がここにあると死亡
・そうでない場合、対角～対角+2までを矛盾なく作れれば勝ち
"""

import itertools

MOD = 998244353

N,M = map(int,readline().split())
m = map(int,read().split())
ABC = list(zip(m,m,m))

# ある：10点
from collections import defaultdict
counter = defaultdict(int)
for a,b,c in ABC:
    if a>b:
        a,b = b,a
    counter[(a,b)] += 10+c

diag0 = [-1] * N
diag1 = [-1] * N # 後ろに足す
diag2 = [-1] * N # 前後に足す
free = N*(N-1)//2 # （盤面に対して対角ごとの和をとったもの）ごとの自由度
other = []
for (x,y),n in counter.items():
    if x>y:
        x,y = y,x
    d = y-x
    if d == 0:
        diag0[x-1] = n-10
        continue
    n = -1 if n<20 else n&1 # 未確定(-1) or 確定(0,1)
    if d >= 3:
        other.append(n)
    elif d == 1:
        diag1[x-1] = n
    elif d == 2:
        diag2[x-1] = n
    else:
        raise Exception

if 1 in other:
    print(0)
    exit()

for i,x in enumerate(diag2[:-2]):
    if x == -1:
        continue
    y = diag0[i+1]
    if y == -1:
        diag0[i+1] = x # 対角成分が強制される
        continue
    # どちらも強制されている
    if x != y:
        print(0)
        exit()

"""
diag0, diag1 の状態を元に、完成図の通り数を数える。
列ごとに処理。対角成分に書き込まれるのが、0のときa通り、1のときb通り
"""

if diag0[0] == -1:
    dp = [1,1]
elif diag0[0] == 0:
    dp = [1,0]
else:
    dp = [0,1]
for x0,x1 in zip(diag0[1:],diag1[:-1]):
    it0 = ([0],[1],[0,1])[x0]
    it1 = ([0],[1],[0,1])[x1]
    prev = dp
    dp = [0,0]
    for y0,y1 in itertools.product(it0,it1):
        dp[y0] += prev[y0^y1]
    if dp[0] > MOD: dp[0] -= MOD
    if dp[1] > MOD: dp[1] -= MOD

x = dp[0] + dp[1] # 完成盤面+transepose(完成盤面)が何通りあるか

# あとは、指定状態を固定したときの自由度
free = N*(N-1)//2
for (r,c),n in counter.items():
    if r == c:
        continue
    if n >= 10:
        free -= 1

answer = x * pow(2,free,MOD) % MOD
print(answer)

Measured memory_bytes: 23056
// Author : Epsilon573
// If it works, don't touch it.

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  
    ll n;
    cin >> n;

    switch(n%10)
    {
        case 0: cout << "pon";
        break;
        case 1: cout << "pon";
        break;
        case 2: cout << "hon";
        break;
        case 3: cout << "bon";
        break;
        case 4: cout << "hon";
        break;
        case 5: cout << "hon";
        break;
        case 6: cout << "pon";
        break;
        case 7: cout << "hon";
        break;
        case 8: cout << "pon";
        break;
        case 9: cout << "hon";
        break;

    }

    return 0;
} 

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start, i<n, i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_s_down(i, start, n) for(int i = n-1; i>=start; i--)


int main(){
  ll N, A;
  priority_queue<ll> q;
  
  cin >> N;
  rep (i, N) {
    cin >> A;
    q.push(A);
  };
  int flag=0;
  ll a, b, height, width;

  while(flag <= 2){
   
   a = q.top();
   
   q.pop();
   if (q.empty()) {
     //cout <<"q is empty " << endl;
     cout << 0 << endl;
     return 0;
   }
   b = q.top();
   //cout <<"a: " << a << ",  b:" << b << endl;
   if (a == b) {
     q.pop();
     if (flag == 0){
       height = a;
     } else {
       width = b;
       cout << height*width << endl;
       return 0;
     }
     flag++;
   } 
  }
  cout << 0 << endl;
  return 0;
  
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

int n;
int a[100010];
int cnt[100010];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cnt[a[i]]++;
    int best = 0;
    for(int i = 1; i < 100000; i++){
        int t1 = i - 1;
        int t2 = i;
        int t3 = i + 1;
        best = max(best, cnt[t1] + cnt[t2] + cnt[t3]);
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 1024
//g++ -std=c++11 -Wall test.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
using namespace std;
#define sws                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define qi queue<int>
#define si stack<int>
#define s string
#define ll long long;

int main()
{
    sws;
    int a, b, x;
    cin >> a >> b >> x;
    s ans = (x > a + b || x < a) ? "NO" : "YES";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll N, fX = 0;
  string s;
  cin >> N;
  s = to_string(N);
  for (auto c : s) {
    fX += c - '0';
  }

  cout << (N % fX == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std; //or std::cin et al.

int main() {
	int a,b,tmp;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		if (a > b) {
		    tmp = a;
		    a = b;
		    b = tmp;
		}
		cout << a << " " << b << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
ll n;
ll dp[3001][3001];
bool vis[3001][3001];
ll a[3001];
ll solve(int l,int r){
    if(vis[l][r]){
        return dp[l][r];
    }
    vis[l][r]=true;
    if(l==r){
        return dp[l][r]=a[l];
    }
    dp[l][r]=max(a[l]-solve(l+1,r),a[r]-solve(l,r-1));
    return dp[l][r];
}
int main() {
    FIO;
    //test
    {
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        memset(vis,false,sizeof(vis));
        cout<<solve(1,n)<<endl;
    }
	return 0;
}


Measured memory_bytes: 58712
def check(dest,start):
    ll = dest[1] - start[1] + dest[2]-start[2]
    if ll < 0:
        ll = -ll
    time = dest[0] - start[0]
    tmp = ll - time
    if tmp <= 0 and tmp%2 == 0 :
        return True
    else:
        return False

n = int(input())
start = [0,0,0]
for i in range(n):
    dest = list(map(int, input().split()))
    if check(dest,start):
        start = dest
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 9124
// 2019/05/02 Tazoe

#include <iostream>
using namespace std;

int cnt;

void DFS(int n, int s, int m)
{
	if(n==0 && s==0){
		cnt++;
		return;
	}

	if(n<=0)
		return;
	if(s<0)
		return;
	if(m>9)
		return;

	DFS(n-1, s-m, m+1);
	DFS(n, s, m+1);

	return;
}


int main()
{
	while(true){
		int n, s;
		cin >> n >> s;

		if(n==0 && s==0)
			break;

		cnt = 0;

		DFS(n, s, 0);

		cout << cnt << endl;
	}

	return 0;
}



Measured memory_bytes: 2996
#include "atcoder/lazysegtree"
#include "atcoder/modint"
#include <cstdio>

using namespace std;
using namespace atcoder;

using mint = modint998244353;
struct S {
	mint value;
	mint size;
};
using F = long long;
const F ID = 8e18;

S op(S a, S b) { return { a.value + b.value, a.size + b.size };}
S e() { return { 0, 0 }; }
S mapping(F f, S x) {
	if (f != ID) x.value = f * x.size;
	return x;
}
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

int main() {
	int N, Q;
	cin >> N >> Q;
	vector<S> a(N);
	mint p = 1;
	for (int i = N - 1; i >= 0; i--) {
		a[i] = S{ 1, p };
		p *= 10;
	}
	atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
	seg.apply(0, N, 1);
	for (int i = 0; i < Q; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		l--;
		r--;
		seg.apply(l, r + 1 , d);
		cout << seg.all_prod().value.val() << endl;
	}
}


Measured memory_bytes: 10892
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, k;
    cin >> a >> b >> k;
    if (a + b <= k)
        cout << "0 0" << endl;
    else
    {
        if (a >= k)
            cout << a - k << " " << b << endl;
        else
            cout << 0 << " " << b - (k - a) << endl;
    }
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == 7 && b == 5 && c == 5) ||
        (a == 5 && b == 7 && c == 5) ||
        (a == 5 && b == 5 && c == 7)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
//#define MOD 998244353

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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 main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll N, A, B;
	cin >> N >> A >> B;

	cout <<min( A * N , B) << endl;

	return 0;
}



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

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

int main(){
	//input
	ll N,Z,W; cin>>N>>Z>>W;
	vector<ll> A(N);
    rep(i,N) cin>>A[i];

	if(N==1) cout<<abs(A[0]-W);
    else{
        cout<<max(abs(A[N-1]-W),abs(A[N-2]-A[N-1]));
    }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    int N;
    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        N = int.Parse(line[1]) * 10 + int.Parse(line[2]);
    }

    public void Solve()
    {
        Scan();
        Console.WriteLine(N % 4 == 0 ? "YES" : "NO");
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main(void){
	int a, b,k;
	char op='a',q=' ',w=' ';
	while (op != '?'){
		a = 0;
		b = 0;
		k = 0;
		op = 'a';
		scanf("%d", &a);
		scanf("%c", &q);
		scanf("%c", &op);
		scanf("%c", &w);
		scanf("%d", &b);
		if (op == '+'){
			k = a+b;
		}
		else if (op == '-') {
			k = a-b;
		}
		else if (op == '*'){
			k = a*b;
		}
		else if (op == '/'){
			k = a/b;
		}
		 if (op != '?'){
			printf("%d\n", k);
		}
	}
	return 0;
}

Measured memory_bytes: 2748
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut a:String = read!();
    let mut v:Vec<char> = a.chars().collect();
    for i in 0..v.len() {
        v[i] = 'x';
    }
    let k:String = v.into_iter().collect();
    println!("{}",k);
}

Measured memory_bytes: 2144
#include<iostream>
typedef long long ll;
const ll INF=1e12;
using namespace std;

ll F(ll a,ll b){
    ll cnt_a=0;
    ll cnt_b=0;
    while(true){
        if(a==0&&b==0) break;
        if(a>0) cnt_a++;
        a/=10;
        if(b>0) cnt_b++;
        b/=10;
    }
    ll ans=max(cnt_a,cnt_b);
    return ans;
}

int main(){
    ll n;
    cin >> n;
    ll ans=INF;
    for(ll i=1;i*i<=n;i++){
        ll a=i;
        ll b;
        if(n%a==0){
            b=n/a;
            ll res=F(a,b);
            ans=min(ans,res);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 300
#define INF 0x3f3f3f3f3f3f3f3fll
#define B 233
const ll mod=1000000007;
ll n,p,mx,ans,a[N],c[N];
map<ll,vector< pair<ll,ll> > > mp;
struct node
{
    ll b,c;
    int i;
    bool operator<(const node&o)const
    {
        return b<o.b;
    }
}b[N];
ll popcount(ll x,ll y)
{
    if (x>=y)
        return INF;
    ll ret=0;
    for (ll i=60; i>=0; i--)
        if (((x>>i)&1)!=((y>>i)&1))
        {
            ret++;
            return ret;
        }
        else
            ret+=(x>>i)&1;
    return INF;
}

int main()
{
    scanf("%lld%lld",&n,&p);
    for (ll i=1; i<=n; i++)
        scanf("%lld",&a[i]);
    ll s=1;
    for(int i=0;i<=60;i++,s<<=1)
    {
        memset(b,0,sizeof b);
        for(int j=1;j<=n;j++)
            b[j].b=a[j]%s,b[j].c=a[j]/s,b[j].i=j;
        sort(b+1,b+n+1);
        for (ll j=0; j<n; j++)
        {
            ll k=((j==0)?0:popcount(b[j].b,b[j+1].b)),hsh=0;
            ll mn=p-k-i;
            bool fl=0;
            b[j].c--;
            if(mn<0) continue;
            if(j!=0&&b[j].c<0)
                break;
            b[n+1].b=s-1;
            for (ll k=1; k<=n; k++)
                mn=min(mn,b[k].c);
            for (ll k=1; k<=n; k++)
                c[b[k].i]=b[k].c;
            for (ll k=2; k<=n; k++)
                hsh=((hsh*B+(c[k]-c[k-1]))%mod+mod)%mod;
            mp[hsh].push_back(make_pair(max(c[1]-mn,0ll),c[1]));
        }
    }
    for (map<ll,vector< pair<ll,ll> > >::iterator i=mp.begin(); i!=mp.end(); i++)
    {
        vector< pair<ll,ll> > &vec=i->second;// puts("-----");
        sort(vec.begin(),vec.end());
        mx=0;
        ll l=vec[0].first,r=vec[0].second;
        for(int j=1; j<vec.size(); j++)
            if(vec[j].first>r)
            {
                ans=(ans+(r-l+1)%mod)%mod;
                l=vec[j].first;
                r=vec[j].second;
            }
            else
                r=max(r,vec[j].second);
        ans=(ans+(r-l+1)%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}



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

using namespace std;

vector<string> rotate45(const vector<string>& vs){
    const int H = vs.size();
    const int W = vs[0].size();
    vector<string> res(H+W-1, string(H+W-1, '.'));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            res[i-j+W-1][i+j] = vs[i][j];
        }
    }
    return res;
}

vector<string> flip(const vector<string>& vs){
    const int H = vs.size();
    const int W = vs[0].size();
    vector<string> res(W, string(H, '.'));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            res[j][i] = vs[i][j];
        }
    }
    return res;
}

pair<long long, long long> solve(const vector<string>& vs){
    const int H = vs.size();
    const int W = vs[0].size();
    vector<vector<long long>> sumH(H, vector<long long>(W+1, 0));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            sumH[i][j+1] = sumH[i][j] + (vs[i][j] == '#' ? 1 : 0);
        }
    }
    long long res = 0;
    long long corner = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(vs[i][j] != '#') continue;
            for(int d=2;j+d<H;d+=2){
                if(vs[i][j+d] != '#') continue;
                for(int sgn=-1;sgn<=1;sgn+=2){
                    int ni = i + sgn * d;
                    if(0 <= ni && ni < H){
                        res += sumH[ni][j+d+1] - sumH[ni][j];
                        if(vs[ni][j] == '#') ++corner;
                        if(vs[ni][j+d] == '#') ++corner;
                    }
                }
            }
        }
    }
    return make_pair(res, corner);
}

int main(){
    int H, W;
    while(cin >> H >> W){
        vector<string> vs(H);
        for(auto& s : vs) cin >> s;
        auto board = rotate45(vs);
        auto r1 = solve(board);
        auto r2 = solve(flip(board));
        cout << (r1.first + r2.first - (r1.second + r2.second)/2) << endl;
    }
}

Measured memory_bytes: 4000
#include <iostream>

using namespace std;

bool ans = true;
string str;

// [a, b] の閉区間
bool IsPalindrome(int a, int b) {
    int i = (a + b + 1) / 2;
    for(int j = 0; j < i && ans; ++j) {
        ans = (str.at(j) == str.at(b-j));
    }

    return ans;
}

int main() {
    cin >> str;
    int n; n = str.length();

    ans = IsPalindrome(0, n-1) && IsPalindrome(0, (n-3)/2) && IsPalindrome((n+3)/2, n-1);
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int ans = 0;
	int sum = 0, sum2 = 0;
	
	cin>>N>>K;
	
	for(int i = 1; i <= N+1; i++){
		sum += N - i + 1;
		sum2 += i - 1;
		sum %= MOD;
		sum2 %= MOD;
		if(i >= K) {
			ans += (sum + MOD - sum2)%MOD + 1;
		}
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;

	vector<int> a(n);

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

	int ans = 0;
	for (int i = 1; i < n-1; i++) {
		bool f = a[i]<a[i + 1] && a[i]>a[i - 1];
		bool g = a[i]<a[i-1] && a[i]>a[i + 1];
		if (f || g) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int64_t gcd(int64_t a, int64_t b) {
	if (!b) return a;
	else return gcd(b, a % b);
}

int64_t lcm(int64_t a, int64_t b) {
	int64_t g = gcd(a, b);
	return a / g * b;
}

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

	int64_t ans = 1;
	int64_t n;
	for (int i = 0; i < N; i++) {
		cin >> n;
		ans = lcm(ans, n);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}



int main() {
	int n, a, t=0, t2=1000000000;
	cin >> n;
	vector<int>vec(n);
	for(int i=0; i<n; i++) {
		cin >> vec[i];
	}
	sort(all(vec));

	if (n % 2 == 1) {
		a = vec[n / 2];
		for (int j = 0; j < 105; j++) {
			t = 0;
			for (int i = 0; i < n; i++) {
				t += (vec[i] - a - 52 + j) * (vec[i] - a - 52 + j);
			}
			t2 = min(t, t2);
		}
		cout << t2 << endl;
	}

	else {
		a = (vec[n / 2] + vec[n / 2 + 1]) / 2;
		for (int j = 0; j < 105; j++) {
			t = 0;
			for (int i = 0; i < n; i++) {
				t += (vec[i] - a - 52 + j) * (vec[i] - a - 52 + j);
			}
			t2 = min(t, t2);
		}
		cout << t2 << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a[205],n;
	int i,flag=0;;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	int count=0;
	while(flag==0)
	{
		for(i=0;i<n;i++)
		{
			if(a[i]%2!=0)
			{
				flag=1;
				break;
			}
			else
			{
				a[i]=a[i]/2;
			}
		}
		if(flag==0)
			count++;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)

	n, _ := nextInt()
	x := make([]int, n)
	y := make([]int, n)

	for i := 0; i < n; i++ {
		x[i], _ = nextInt()
	}
	for i := 0; i < n; i++ {
		y[i], _ = nextInt()
	}

	d1 := 0.0
	d2 := 0.0
	d3 := 0.0
	dinf := 0.0
	for i := 0; i < n; i++ {
		xi := float64(x[i])
		yi := float64(y[i])

		absi := math.Abs(xi - yi)
		d1 += absi
		d2 += math.Pow(absi, 2)
		d3 += math.Pow(absi, 3)
		dinf = math.Max(dinf, absi)
	}

	fmt.Println(d1)
	fmt.Println(math.Sqrt(d2))
	fmt.Println(math.Pow(d3, 1.0/3.0))
	fmt.Println(dinf)
}



Measured memory_bytes: 1128
#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;
typedef long long ll;

// UnionFind (Disjoint set)
struct unionfind {
	vector<int> d;	// 親：連結のサイズ×(-1)、子：親のID（非負）
	unionfind(int n = 0): d(n, -1) {}
	int find(int x) {
		if(d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if(x == y) return false;
		if(d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }
};

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	unionfind uf(n);
	vector<vector<int>> tomo(n), block(n);
	vector<int> koho(n, -1);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		tomo[a].push_back(b);
		tomo[b].push_back(a);
		uf.unite(a, b);
	}
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		block[a].push_back(b);
		block[b].push_back(a);
	}
	rep(i, n){
		int ans = uf.size(i) - 1 - tomo[i].size();
		for(int u: block[i]) {
			if (uf.same(i, u)) ans--;
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	string a;
  cin >> a;
  int sum = 0;
  int b = a.length();
  froop1(0,b){
    int c = a[i] - '0';
    sum += c;
  }
  if(sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3740
x, y = [int(i) for i in input().split()]

mod = 10 ** 9 + 7
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, 670000):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


# 以下のcom関数を用いて組み合わせを計算
def com(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


if (2*x-y) % 3 == 0 and (2*y-x) % 3 == 0:
    a = (2*x-y) // 3
    b = (2*y-x) // 3
    #a+bC(min(a,b))
    ans = 0
    n = a + b
    r = min(a, b)
    print(com(n, r, mod))

else:
    print(0)


Measured memory_bytes: 82864
import java.util.*

object MainKt {
	@JvmStatic
	fun main(args: Array<String>) {
		val scanner = Scanner(System.`in`)
		val n = scanner.nextInt()
		val balls = arrayOfNulls<Pair<Int, Int>>(n)
		val map = mutableMapOf<Pair<Int, Int>, Int>()
		var max = 0
		for (i in 0..n-1) {
			balls[i] = Pair(scanner.nextInt(), scanner.nextInt())
			for (k in 0..i-1){
				var dx = balls[i]!!.first-balls[k]!!.first
				var dy = balls[i]!!.second-balls[k]!!.second
				if (dx<0) {
					dx*=-1
					dy*=-1
				}else if (dx==0 && dy<0) dy*=-1
				val d = Pair(dx, dy)
				map.put(d, (map[d]?:0)+1)
				max = Math.max(max, map[d]!!)
			}
		}
		println(n-max)
	}
}

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

int main() {
  long long n, k;
  cin >> n >> k;
    
  long long y = 0, i=0, z;
  while (n > 0) {
    z = n % k;
    y += z * pow(10, i);
    n = n / k;
    i++;
  }
  
  cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long r, wrong = 0, c = 0;
    string s;
    cin >> s;
    map<char, int> cnt;
    for (int i = 0; i < s.size(); i++) {
        cnt[s[i]]++;
        if (cnt[s[i]] > 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    if (cnt.size() == 2) {
        yes();
    } else {
        no();
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1)
#define N 100005 
#define bitscount 32

using namespace std;

int a[N];

int main()
{
__

int n,k,q,v;

cin >> n >> k >> q;

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

for(int i=1;i<=n;i++){

if(k > (q-a[i])) cout << "Yes\n";

else cout << "No\n";

}

return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	var A [3][3]int
	for i := 0; i < 3; i++ {
		A[i][0] = nextInt()
		A[i][1] = nextInt()
		A[i][2] = nextInt()
	}

	N := nextInt()
	for i := 0; i < N; i++ {
		b := nextInt()
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if A[j][k] == b {
					A[j][k] = 0
				}
			}
		}
	}
	bingo := false
	for i := 0; i < 3; i++ {
		if A[i][0] == A[i][1] && A[i][1] == A[i][2] {
			bingo = true
		}
		if A[0][i] == A[1][i] && A[1][i] == A[2][i] {
			bingo = true
		}
	}
	if A[0][0] == A[1][1] && A[1][1] == A[2][2] {
		bingo = true
	}
	if A[0][2] == A[1][1] && A[1][1] == A[2][0] {
		bingo = true
	}

	if bingo {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 200030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int n,m;
int arr[N],a[N];
bool b[N];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
int cnt=0;
for(int i=0;i<m;i++)
{
	int x;
	string s;
	cin>>x>>s;
	if(s=="AC")
	b[x]=true;
	else
	{
		if(!b[x])
	   a[x]++;

	}
}
int sum=0;
rep(i,1,n+1)
{
	if(b[i])
	sum++,cnt+=a[i];
}
cout<<sum<<" "<<cnt;

}

Measured memory_bytes: 768
from collections import deque

h, w = map(int, input().split())
s = [0] * h
for i in range(h):
    s[i] = list(input())

start_black_cnt = 0
for i in s:
    for j in i:
        if j == '#':
            start_black_cnt += 1

que = deque([[0, 0]])
y, x = 0, 0
s[0][0] = 1
flg = True
while not (y == h-1 and x == w-1):
    if len(que) == 0:
        flg = False
        break

    now = que.popleft()
    y, x = now[0], now[1]
    # UP
    if y != 0 and s[y-1][x] == '.':
        que.append([y-1, x])
        s[y-1][x] = s[y][x] + 1
    # DOWN
    if y != h-1 and s[y+1][x] == '.':
        que.append([y+1, x])
        s[y+1][x] = s[y][x] + 1
    # LEFT
    if x != 0 and s[y][x-1] == '.':
        que.append([y, x-1])
        s[y][x-1] = s[y][x] + 1
    # RIGHT
    if x != w-1 and s[y][x+1] == '.':
        que.append([y, x+1])
        s[y][x+1] = s[y][x] + 1

if flg:
    print(h*w - start_black_cnt - int(s[h-1][w-1]))
else:
    print(-1)

Measured memory_bytes: 3316
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

nx = x2
ny = y2

l = []

for i in range(2):
    dx, dy = -dy, dx

    nx = nx + dx
    ny = ny + dy

    l.append(nx)
    l.append(ny)

print(l[0], l[1], l[2], l[3])


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

int b[200007] = { };

int main(){
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        b[arr[i]]++;
    }
    int u = 0, r = 0;
    for(int i = 1; i <= n; i++) if(b[i]) u++;
    sort(b+1, b+n+1);
    for(int i = 1; i <= n; i++){
        if(u <= k){
            cout << r << '\n';
            return 0;
        }
        if(b[i]){ 
            u--;
            r += b[i];
        }
        if(u <= k){
            cout << r << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
// mod. m での a の逆元 a^{-1} を計算する
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 割り算MOD
ll divmod(ll a, ll b){
    a %= MOD;
    return a * modinv(b, MOD) % MOD;
}

const int MAX = 10100;
// fac: n! %mod, finv: (1/n!) %mod, inv: 1/n %mod
ll fac[MAX], finv[MAX], inv[MAX];

ll powa[MAX], powb[MAX], powab[MAX];

// テーブルを作る前処理
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

void powinit(ll a, ll b){
    a %= MOD;
    b %= MOD;
    powa[0] = powb[0] = powab[0] = 1;
    repr(i, 1, MAX){
        powa[i] = powa[i-1] * a % MOD;
        powb[i] = powb[i-1] * b % MOD;
        powab[i] = powab[i-1] * (a+b) % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    COMinit();
    ll n, k;
    cin >> n >> k;
    ll b = k;
    ll r = n-k;
    repr(i, 1, k+1){
        if(i > r+1 || i-1 > b-1) cout << 0 << endl;
        else cout << (COM(r+1, i)*COM(b-1, i-1))%MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 512
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    row = [int(x) for x in input().rstrip().split(" ")]

    a = row[0]
    b = row[1]
    c = row[2]

    count = 0
    while(a%2==0 and b%2==0 and c%2==0):
        if(a==b and b==c):
            count = -1
            break
        count += 1
        tmpa = b//2 + c//2
        tmpb = a//2 + c//2
        tmpc = b//2 + a//2

        a = tmpa
        b = tmpb
        c = tmpc

    print(count)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9116
#include<stdio.h>

#define INF 1000000010

int binary_search(int x, int l, int r, int *array){
  while(l < r){
    int m = (r + l) / 2;
    if(array[m] < x) r = m;
    else l = m + 1;
  }
  return l;
}

int main(){
  int n;
  scanf("%d", &n);
  
  int a[n];
  int dp[n];
  
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    dp[i] = -1;
  }
  
  int right = 1;
  dp[0] = a[0];
  for(int i = 1; i < n; i++){
    if(dp[right - 1] >= a[i]){
      dp[right] = a[i];
      right++;
    }else{
      dp[binary_search(a[i], 0, right, dp)] = a[i];
    }
  }
  
  int len;
  for(len = 0; len < n; len++) if(dp[len] == -1) break;
  
  printf("%d", len);
  
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  double v[n];
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v, v + n);
  for(int i = 1; i < n; i++){
    v[i] =  (v[i - 1] + v[i]) / 2 ;
  }
  cout << v[n - 1] << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if(N % 2 == 0){
      System.out.println(N / 2);
    } else {
      System.out.println((N / 2) + 1);
    }
  }
}


Measured memory_bytes: 23892
program ec12;
var 
	a:array[1..200001] of longint;
	queue:array[-100001..100001] of longint;
	n,m,i,j,dis,head,tail:longint;
begin 
	readln(n);
	for i:=1 to n do 
	read(a[i]);
	head:=1;
	tail:=1;
	dis:=1;
	queue[head]:=a[1];
	for i:=3 to n*2 do 
	begin 
		if i mod 2=1 then 
		begin
			if dis=1 then 
			begin 	
				inc(tail);
				queue[tail]:=a[i div 2+1];
			end
			else
			begin 
				dec(head);
				queue[head]:=a[i div 2+1];
			end;
		end
		else
		dis:=3-dis;
	end;
	if dis=1 then 
	begin 
		for i:=head to tail do 
		write(queue[i],' ');
	end
	else
	begin
		for i:=tail downto head do 
		write(queue[i],' ');
	end;
end. 

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

namespace ConsoleApp2
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int cnt = 0;

            for (int i = 1; i <= N; i++)
            {
                if (0 < i && i < 10)
                    cnt++;
                else if (99 < i && i < 1000)
                    cnt++;
                else if (9999 < i && i < 100000)
                    cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 26912
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); // people
        int d = sc.nextInt(); // number of days
        int x = sc.nextInt(); // remainder

        int chocolates = 0;
        for (int i = 0; i < n; ++i) {
            int ai = sc.nextInt(); // frequency
            chocolates += Math.ceil(d / (float)(ai));
        }
        System.out.print(chocolates += x);
    }
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1 and b != 1 or ((a != 1 and b != 1) and a > b)){
    cout << "Alice" << endl;
  }
  else if(a != 1 and b == 1 or ((a != 1 and b != 1) and a < b)){
    cout << "Bob" << endl;
  }
  else{
    cout << "Draw" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

#define PI 3.14159265

struct Matrix
{
	Matrix(float angle)
	{
		float radian = (float)(angle / 180.0f * PI);
		m11 = cos(radian);
		m12 = -sin(radian);
		m21 = sin(radian);
		m22 = cos(radian);
	}

	float m11, m12, m21, m22;
};

struct Vector
{
	Vector() {}
	Vector(float x, float y) :x(x), y(y) {}

	friend ostream& operator<<(ostream& os, const Vector& vector)
	{
		os << vector.x << " " << vector.y << endl;
		return os;
	}

	friend Vector operator+(const Vector& left, const Vector& right)
	{
		Vector result;
		result.x = left.x + right.x;
		result.y = left.y + right.y;
		return result;
	}

	friend Vector operator-(const Vector& left, const Vector& right)
	{
		Vector result;
		result.x = left.x - right.x;
		result.y = left.y - right.y;
		return result;
	}

	friend Vector operator*(const Vector& left, float right)
	{
		Vector result;
		result.x = left.x * right;
		result.y = left.y * right;
		return result;
	}

	friend Vector operator/(const Vector& left, float right)
	{
		Vector result;
		result.x = left.x / right;
		result.y = left.y / right;
		return result;
	}

	friend Vector operator*(const Vector& left, const Matrix& right)
	{
		Vector result;
		result.x = left.x * right.m11 + left.y * right.m12;
		result.y = left.x * right.m21 + left.y * right.m22;
		return result;
	}

	float x, y;
};

Matrix g_m(60);
void KochCurve(int n, const Vector& head, const Vector& tail)
{
	if (0 == n)
	{
		//cout << tail.x << " " << tail.y << endl;
		cout << tail;
		return;
	}

	Vector s = (tail - head) / 3.0f + head;
	Vector t = tail - (tail - head) / 3.0f;
	Vector u = (t - s) * g_m + s;

	KochCurve(n - 1, head, s);
	KochCurve(n - 1, s, u);
	KochCurve(n - 1, u, t);
	KochCurve(n - 1, t, tail);
}

void KochCurve(int n, float p1x, float p1y, float p2x, float p2y)
{
	if (0 == n)
	{
		//cout << p1x << " " << p1y << endl;
		cout << p2x << " " << p2y << endl;
		return;
	}

	float sx = (p2x - p1x) / 3.0f + p1x;
	float sy = (p2y - p1y) / 3.0f + p1y;
	float tx = (p2x - p1x) / 3.0f * 2 + p1x;
	float ty = (p2y - p1y) / 3.0f * 2 + p1y;

	float radian = (float)(60.0f / 180.0f * PI);
	float ux = (tx - sx) * cos(radian) - (ty - sy) * sin(radian) + sx;
	float uy = (tx - sx) * sin(radian) + (ty - sy) * cos(radian) + sy;

	KochCurve(n - 1, p1x, p1y, sx, sy);
	KochCurve(n - 1, sx, sy, ux, uy);
	KochCurve(n - 1, ux, uy, tx, ty);
	KochCurve(n - 1, tx, ty, p2x, p2y);
}

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

	/*cout << 0 << " " << 0 << endl;
	KochCurve(n, 0, 0, 100, 0);*/
	Vector head(0.0f, 0.0f);
	Vector tail(100.0f, 0.0f);
	cout << head;
	KochCurve(n, head, tail);

	return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <cmath>

int count_digits(long number)
{
	int result = 1;
	while (number >= 10) {
		number /= 10;
		++result;
	}
	return result;
}

int main()
{
	long a, b;
	while (std::cin >> a >> b) {
		std::cout << count_digits(a + b) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
int n,m,head[100100],cnt=0,parent[100100],dfn[100100],low[100100],vis[100100],tag=0,book[100100],count=0;
struct node{
    int to,next;
}e[100000*2+100];//无向?
void addedge(int u,int v){
    cnt++,e[cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
}
void dfs(int current,int previous){//?置 dfn[] low[] 
    int next,b;//next点 b? 
    vis[current]=1;
    //parent[current]=previous;//1 此句?除 
    tag++;
    dfn[current]=low[current]=tag;
    for(b=head[current];b;b=e[b].next){
        next=e[b].to;
        if(vis[next]==0){
            parent[next]=current;//1 添加此句 
            dfs(next,current);
            low[current]=low[current]>low[next]?low[next]:low[current];
        }else if(next!=previous){
            low[current]=low[current]>dfn[next]?dfn[next]:low[current];
        }
    }
} 
void art_point(){
    int i,p,p_num=0;
    for(i=0;i<n;i++){
        p=parent[i];
        if(p==0)p_num++;
        else if(p>0&&dfn[p]<=low[i])book[p]=1;
    }
    if(p_num>1)book[0]=1;
}
int main(){
    int i,u,v;
    memset(vis,0,sizeof(vis));
    memset(head,0,sizeof(head));
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++){
        scanf("%d%d",&u,&v);
        addedge(u,v);
        addedge(v,u);
    }
    parent[0]=-1;
    dfs(0,-1);
    art_point();
    for(i=0;i<n;i++)
        if(book[i])
            printf("%d\n",i);
    return 0;
} 

Measured memory_bytes: 3780