akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pi 3.1415926535897932384626433832795
#define fin(a,n)  for(ll i=0;i<n;i++) cin>>a[i];
#define fout(a,n)  for(ll i=0;i<n;i++) cout<<a[i]<<" ";
int N = 1000000007;
using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); cout.tie(NULL);
	ll n,k,ans;
	cin>>n>>k;
	if(n <= k)
	{
		cout<<min(n,k-n)<<'\n';
		return 0;
	}
	ans = min(n%k, abs(n%k - k));
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define NDEBUG
#include <bits/stdc++.h>
//#include <assert.h>

using namespace std;

#define ll long long
#define pb push_back
#define pf push_front
#define loop(i, n) for(int i = 0 ; i < n ; ++i)
#define LOOP(i, a, b) for(int i = a ; i < b ; ++i)
#define max3(a, b, c) max(a, max(b,c))
#define max4(a, b, c, d) max3(a, b, max(c, d))
#define ff first
#define ss second
#define mkp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pii>
#define vvii vector<vii>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define nmbr(c) (int)(c-'0')
#define ltr(c) (int)(c-'a')
#define INF 1e18
#define inf 1e9
#define MOD 1000000007 //check
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int d;
string k;
ll dp[10005][105][2];

ll ways(int i, int sum, int f)
{
	if(i == sz(k) && sum == 0) return 1;
	if(i == sz(k)) return 0;
	ll &ans = dp[i][sum][f];
	if(ans != -1) return ans;
	ans = 0;
	if(f) loop(j, 10)
	{
		ans += ways(i+1, (sum+j)%d, 1);
		ans %= MOD;
	}
	else loop(j, nmbr(k[i])+1)
	{
		if(j != nmbr(k[i])) ans += ways(i+1, (sum+j)%d, 1);
		else ans += ways(i+1, (sum+j)%d, 0);
		ans %= MOD;
	}
	return ans%MOD;
}
int main() {
	_69e27;
	memset(dp, -1, sizeof(dp));
	cin >> k >> d;
	assert(d == 4);
	debug() << imie(k);
	cout << (ways(0, 0, 0)-1+MOD)%MOD;
	return 0;
}

Measured memory_bytes: 17408
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}
 
// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}
 
var inf int = 1e9
 
// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.next()
	ans := "Yes"
	for i := 0; i < len(n)/2; i++ {
		j := len(n) - i - 1
		if n[i] != n[j] {
			ans = "No"
			break
		}
	}
 
	fmt.Println(ans)
}
 
// ---------------------------------------------------------
 
// Pair is liked C++ pair
type Pair struct {
	a, b int
}
 
// Pairs is sorted by []Pair struct
type Pairs []Pair
 
func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}
 
// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}
 
func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}
 
func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}
 
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
 
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
 
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
 
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
 
// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}
 
func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

Measured memory_bytes: 640
#include<cstdio>

#include<cstring>
using namespace std;

int main(){

    char str0[200];
    char str1[100];
    char str2[100];
    scanf("%s %s",str0,str2);
    int i = strlen(str0);
    strcpy(str1,str0);
    strcat(str0,str1);
    if(strstr(str0,str2)==NULL)printf("No\n");
    else printf("Yes\n");
    

    return 0;
    
}


Measured memory_bytes: 2740
n=int(input())
s=input()
d=[0]*n
lcount=0
rcount=0
for i in range(len(s)):
  if s[i]=="(":
    lcount+=1
  else:
    if lcount>=1:
      lcount-=1
    else:
      rcount+=1

print("("*rcount+s+")"*lcount)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W, N;
    cin >> H >> W >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];

    ll i = 0, k = 0, c = 0, cnt = 0;
    while(cnt < H * W) {
        i = 0;
        while(i < W) {
            if(c < A[k]) {
                ++i;
                ++c;
                PS(k+1);
                ++cnt;
            }
            else {
                ++k;
                c = 0;
            }
        }
        PR("");

        if(cnt >= H * W) break;

        vec B(N);
        i = W - 1;
        while(i >= 0) {
            if(c < A[k]) {
                --i;
                ++c;
                B.pb(k+1);
                ++cnt;
            }
            else {
                ++k;
                c = 0;
            }
        }
        REV(B);
        REP(i,0,W) PS(B[i]);
        PR("");
        
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3696
import sys

n, m, *ab = map(int, sys.stdin.read().split())
ab = sorted(zip(*[iter(ab)] * 2))

def main():
    r = ab[0][1]
    cnt = 0
    for a, b in ab[1:]:
        if a < r:
            if b < r:
                r = b
            continue
        else:
            cnt += 1
            r = b
    cnt += 1
    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 25132
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  int n;cin>>n;
  string s;
  for(int i=0;i<n;i++)
  {
    cin>>s;
    
    if(s=="Y")
    {
      cout<<"Four"<<endl;
      break;
    }
    else if(i==n-1)
    {
     cout<<"Three"<<endl;
    }
  }
}

    


    

    
      
    


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

namespace AtCoder
{
    class Program
    {
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static double ReadDouble()
        {
            return double.Parse(Console.ReadLine());
        }

        static double[] ReadDoubles()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static string[] ReadStringSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        static void A()
        {
            var N = ReadLong();
            Console.WriteLine((double)((N + 1) / 2) / (double)N);
        }

        static void B()
        {
            var NK = ReadLongs();
            var N = NK[0];
            var K = NK[1];
            var hs = ReadLongs();
            var ans = 0;
            foreach (var h in hs) {
                if (h >= K)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void Main(string[] args)
        {
            //A();
            B();
            //C();
            //D();
        }
    }
}


Measured memory_bytes: 35048
import math

x, y = map(int,input().split())
mod = 10**9+7 #出力の制限

def cmb(n, k,MOD):
    if k > n - k:
        k = n - k
    ans = 1
    for i in range(1, k + 1):
        ans *= n + 1 - i
        ans *= pow(i, MOD - 2, MOD)
        ans %= MOD
    return ans

if (x+y)%3 != 0:
    ans = 0
else:
    m = (2*x - y) //3
    n = x - 2*m
    # print(m,n)
    if m <0 or n < 0 :
        ans = 0
    else:
        ans = cmb(n+m, m, mod)
print(ans)

Measured memory_bytes: 40172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll mn = min({a, b, c, d, e});
    //cout << 5 + (n - 1) / min({a, b, c, d, e}) << endl;
    cout << 4 + (n + mn - 1)/ mn << endl;
    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 2 * 1e5;
  int a[max_n+1];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  long long ans = 0;
  bool flag = 0;
  int now = 1;
  for(int i = 0; i < n; i++){
    if(a[i] == now){
      flag = 1;
      now ++;
      ans ++;
    }
  }
  if(!flag) cout << -1 << endl;
  else cout << n - ans << endl;

  return 0;
}

Measured memory_bytes: 4420
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var N, W int
	fmt.Scan(&N, &W)

	w := make([]int, N+1)
	v := make([]int, N+1)
	for i := 1; i <= N; i++ {
		fmt.Scan(&w[i], &v[i])
	}

	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int, W+1)
	}

	for i := 1; i <= N; i++ {
		for j := 0; j <= W; j++ {
			if j-w[i] < 0 {
				dp[i][j] = dp[i-1][j]
				continue
			}
			dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i])
		}
	}

	var result int
	for i := 0; i <= W; i++ {
		result = max(result, dp[N][i])
	}
	fmt.Println(result)
}

Measured memory_bytes: 81792
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define int long long
#define ll long long
#define ac() cout<<"Yes"<<endl;
#define wa() cout<<"No"<<endl;
#define dd cout<<"---debug---"<<endl;
#define ff(a,b)  for(int (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(int (a)=0;(a)<(b);(a)++)
#define re read()
#define pr(a) print(a)
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1;while(b){if(b&1)ans=ans*a%mod;
a=a*a%mod;b>>=1;}return ans;}
int read(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void print(int x){if(x>=10){print(x/10);}//
putchar(x%10+'0');}
//
const int maxm=1e5+5;
const int mod=1e9+7;
int a[maxm],b[maxm];


signed main(){
    ff(i,3)a[i]=re;
    sort(a+1,a+1+3);
    if(a[1]==a[2]&&a[1]!=a[3]){
        ac();
    }else if(a[2]==a[3]&&a[1]!=a[2]){
        ac();
    }else{
        wa();
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  long long int X,i,ans;
  scanf("%lld",&X);
  if(X%11 == 0){
    ans=2*(X/11);
  }else if(X%11<7){
    ans=2*(X/11)+1;
  }else{
    ans=2*(X/11)+2;
  }
  printf("%lld\n",ans);
  return 0;

}

Measured memory_bytes: 128
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(N)]
ab.sort(reverse=True)
cd.sort()
p = 0
for c in cd:
    ac = [-1, -1]
    for a in ab:
        if c[0] > a[0] and c[1] > a[1] and ac[1] < a[1]:
            ac = a
    if ac != [-1, -1]:
        p += 1
        ab.remove(ac)

print(p)


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

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int64_t> A(N);
	int64_t sum{};
	for (auto& e: A)
	{
		scanf("%lld", &e);
		sum += e;
	}
	sum /= 2;
	std::vector<int64_t> sum_table(2 * N + 1);
	for (int i{1}; i <= 2 * N; i++)
		sum_table[i] = A[(i - 1) % N];
	for (int i{2}; i <= 2 * N; i++)
		sum_table[i] += sum_table[i - 2];
	for (int i{1}; i <= N; i++)
		printf("%lld%c", 2 * (sum - (sum_table[i - 2 + N] - sum_table[i - 1])), i == N? '\n': ' ');

	return 0;
}

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

int main() {
    int H,W,a[3000],b[3000];
    int j=0;

	while(cin>>H>>W){
	    if(H==0 && W ==0){
	        break;
	    }
	char result;
	a[j] = H;
	b[j] = W;
	
    for(int i=0;i<a[j];i++){
      string ret = "";
      for(int i=0;i<b[j];i++) ret += "#";
      cout << ret << endl;

    }
    cout<<endl;
    j++;
	}
	return 0;
}


Measured memory_bytes: 3176
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

int gcd(int x, int y) {
    if(y == 0) return x;
    return gcd(y, x % y);
}

void solve() {
	int x, y; cin >> x >> y;
    if(x % y != 0) {
        cout << x << endl;
    } else {
        cout << -1 << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

vi num;
int d, k;
int DP[110][110][2];

int call(int pos, int cnt, int f){
	if(cnt > k) return 0;
	if(pos == num.size()){
		if(cnt == k) return 1;
		return 0;
	}
	if(DP[pos][cnt][f] != -1) return DP[pos][cnt][f];
	int res = 0;
	int LMT;
	if(f == 0){
		LMT = num[pos];
	} else {
		LMT = 9;
	}
	for(int dgt = 0; dgt<=LMT; dgt++){
		int nf = f;
		int ncnt = cnt;
		if(f == 0 && dgt < LMT) nf = 1;
		if(dgt == d) ncnt++;
		if(ncnt <= k) res += call(pos+1, ncnt, nf);
	}
	return DP[pos][cnt][f] = res;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	string s;
	cin >> s >> k;
	for(auto it : s) {
		num.pb(it - '0');
	}
	k = num.size() - k;
	d = 0;
	memset(DP, -1, sizeof(DP));
	int ans = call(0, 0, 0);
	if(k == 1) {
		ans--;
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
//#include <vector> 

static void st_Calc( long m, long aa[], long* piMax, long* piCountMax, long* piCountSec )
{
    long  iCountMax = 0, iCountSec = 0;
    long  iMax = -1;
    std::sort( aa + 0, aa + m );
    long i = 0;
    while(i<m) {
        long val = aa[i];
        long k;
        for(k=i; i<m; k++) {
            if(val != aa[k])
                break;
        }
        long count = k -i;
        if(iCountMax < count) {
            iCountSec = iCountMax;
            iCountMax = count;
            iMax = val;
        }
        else if(iCountMax == count) {
            iMax = -1;
        }
        else if(iCountSec < count) {
            iCountSec = count;
        }
        i = k;
    }

    (*piMax) = iMax;
    (*piCountMax) = iCountMax;
    (*piCountSec) = iCountSec;
}

int main(int argc, char* argv[])
{
	long n;
    scanf("%ld", &n);
	long m = n / 2;

    long aa[50000] = {0};
    long bb[50000] = {0};
	long i;
	for(i=0; i<m; i++) {
        scanf("%ld", &(aa[i]));
        scanf("%ld", &(bb[i]));
	}

    long max_a = 0, max_a_count = 0, sec_a_count = 0;
    st_Calc( m, aa, &max_a, &max_a_count, &sec_a_count );

    long max_b = 0, max_b_count = 0, sec_b_count = 0;
    st_Calc( m, bb, &max_b, &max_b_count, &sec_b_count );

    if(max_a<0 || max_b<0 || max_a != max_b) {
        printf("%d\n", (m - max_a_count) + (m - max_b_count));
    }
    else {
        long val0 = (m - max_a_count) + (m - sec_b_count);
        long val1 = (m - sec_a_count) + (m - max_b_count);
        printf("%d\n", (val0>val1? val1: val0));
    }

    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll MOD = 1000000007;

int main()
{
    int n;cin>>n;
    vector<double> d(n + 1);
    d[0] = 1;
    double u;
    for(int i = 0 ; i < n ;i ++)
    {
        cin>>u;
        for(int j = i + 1 ; j >= 0 ; j--)
        {
            d[j] = d[j] * (1 - u);
            if(j > 0)
            {
                d[j] += d[j - 1] * u;
            }
        }
    }
    double ans = 0;
    for(int i = n / 2 + 1 ; i < n + 1; i++)
    {
        ans += d[i];
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    
}

Measured memory_bytes: 256
<?php
list($N, $X, $Y) = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

$distance = [];
for ($i = 0; $i < $N - 1; $i++) {
    $distance[$i + 1] = 0;
}

$X -= 1;
$Y -= 1;

for ($from = 0; $from < $N; $from++) {
    for ($to = $from + 1; $to < $N; $to++) {
        // 出発が環の入り口以前で、目的地も入り口以前 || 両方出口以降
        if (($from < $X && $to < $X) || ($from > $Y && $to > $Y)) {
            $distance[$to - $from] += 1;
        }
        // 出発が環の入り口以前で、目的地が環内
        if ($from < $X && $to >= $X && $to <= $Y) {
            $distance[$X - $from + min($to - $X, 1 + $Y - $to)] += 1;
        }
        // 出発が環の入り口以前で、目的地が環の出口以降
        if ($from < $X && $to > $Y) {
            $distance[$X - $from + 1 + $to - $Y] += 1;
        }
        // 出発が環内で、目的地も環内
        if ($from >= $X && $from <= $Y && $to >= $X && $to <= $Y) {
            $distance[min($to - $from, 1 + $Y - $to + $from - $X)] += 1;
        }
        // 出発が環内で、目的地は環外
        if ($from >= $X && $from <= $Y && $to > $Y) {
            $distance[min($Y - $from, 1 + $from - $X) + $to - $Y] += 1;
        }
    }
}

foreach ($distance as $d) {
    echo $d . "\n";
}

Measured memory_bytes: 4728
n = int(input())
ans = []

for _ in range(n):

    l = list(map(int, input().split()))
    l.sort()
    a = l[0]
    b = l[1]
    c = l[2]

    if c**2 == a**2 + b**2:
        ans.append("YES")
    else:
        ans.append("NO")


for a in ans:
    print(a)



Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch NotDivisible | diff NotDivisible.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address NotDivisible.cpp && ./a.out

/*

 6/14/2020

 5:11-

 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

vector<LL> divisors(LL N) {
  assert(N>=1);
  vector<LL> res;
  for(LL p=1; p*p<=N; ++p) if(N%p==0) {
    res.push_back(p);
    if(p!=N/p) res.push_back(N/p);
  }
  sort(res.begin(),res.end());
  return res;
}
void solve() {
  map<int,int> cnt;
  REP(i,N) cnt[A[i]]++;
  int res=0;
  REP(i,N) {
    int a=A[i];
    cnt[a]--;
    vector<LL> ds=divisors(a);
    bool ok=true;
    FORR(d,ds) if(cnt.count(d)&&cnt[d]>0) ok=false;
    //if(ok) dump(i,a);
    res+=ok;
    cnt[a]++;
  }
  cout<<res<<endl;
}

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

  cin>>N;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


Measured memory_bytes: 13816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,a=0, b=0, c=0, d=0,ans=0,ans2=0;
string s;
signed main() {
    cin >> a >> b >> c;
  if(a==b&&b==c){
    if(c%2==0){
  cout <<"-1";
      return 0;
    }
  }if(a%2!=0||b%2!=0||c%2!=0){
  cout << "0";
      return 0;
    }
    REP2(i,1000000010){
         int ba=a ,bb=b,bc=c;
      b=(ba+bc)/2;
      c=(ba+bb)/2;
      a=(bb+bc)/2;
        if(a%2!=0||b%2!=0||c%2!=0){
            cout << i;
            return 0;
        }
   
    }
 
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int m[500][500];

void solve(int mn, int mx, int v) {
	int X = mx - mn + 1;
	if (X == 1) {
		return;
	}
	if (X == 2) {
		m[mn][mx] = v;
		m[mx][mn] = v;
		return;
	}
	int md = (mn + mx) / 2;
	
	for (int i = mn;i <= md;i++) {
		for (int j = md + 1;j <= mx;j++) {
			m[i][j] = v;
			m[j][i] = v;
		}
	}

	solve(mn, md, v + 1);
	solve(md + 1, mx, v + 1);
}

int main(){
	int N;
	cin >> N;
	solve(1, N, 1);

	for (int i = 1;i < N;i++) {
		for (int j = i + 1;j <= N;j++) {
			cout << m[i][j] << " ";
		}
		cout << endl;
	}
}

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

int main(void){
    ll n, m;
    cin>>n>>m;
    ll ans;
    if(n==1&&m==1) ans=1;
    else if(n==1) ans=m-2;
    else if(m==1) ans=n-2;
    else {
        ans=n*m;
        ans-=(n*2+m*2-4);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class A {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        System.out.println((N - 2) * 180);
    }
}
public class Main {
    public static void main(String...args) {
        A.main();
    }
}


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

int H,W,N;
int a[10010],c[110][110];

int main(){
  queue<int>q;
  cin>>H>>W>>N;
  for(int t=1;t<=N;t++){
    cin>>a[t];
  }
  for(int t=1;t<=N;t++){
    for(int l=1;l<=a[t];l++){
      q.push(t);
    }
  }

  for(int h=1;h<=H;h++){
    if(h%2==1){
      for(int w=1;w<=W;w++){
        c[h][w]=q.front();
        q.pop();
      }
    }else{
      for(int w=W;1<=w;w--){
        c[h][w]=q.front();
        q.pop();
      }
    }
  }

  for(int h=1;h<=H;h++){
    for(int w=1;w<=W;w++){
      if(w!=1)cout<<" "<<c[h][w];
      if(w==1)cout<<c[h][w];
    }
    cout<<"\n";
  }

  cout<<"\n";
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF ((ll)1<<31)-1
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int gcd(int a,int b){
	if(!a)return b;
	return gcd(b%a,a);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
signed main(){
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	cout<<n-a-b+c<<endl;
    return 0;
}




Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int m; cin >> m;
	
	int n = 2;
	for(; n * (n - 1) / 2 < m; n++);
	if(n * (n - 1) / 2 != m){
		cout << "No" << endl;
		return 0;
	}
	vector<pi> e;
	rep(i, n) rep(j, i) e.emplace_back(j, i);
	sort(all(e));
	
	cout << "Yes" << endl;
	cout << n << endl;
	rep(i, n){
		cout << n - 1;
		rep(j, n) if(i != j){
			int idx = lower_bound(all(e), pi(min(i, j), max(i, j))) - e.begin();
			cout << " " << idx + 1;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2292
N=int(input())
s=[input() for i in range(N)]
a=[i.count("AB") for i in s]
X=[0 for i in range(N)]
Y=[0 for i in range(N)]
for i in range(N):
    if s[i][0]=="B":
        X[i]+=1
    if s[i][-1]=="A":
        Y[i]+=1
flag=0
tmp=0
for i in range(N):
    if (X[i]+Y[i])%2==1:
        flag=1
        break
    if (X[i]+Y[i]==2):
        tmp+=1
if flag==1:
    print(sum(a)+min(sum(X),sum(Y)))
else:
    if tmp==0:
        print(sum(a))
    else:
        print(sum(a)+tmp-1)

Measured memory_bytes: 3956
#include <cstdio>
#include <vector>
#include <stack>
#include <algorithm>

#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)
#define ALL(c) (c).begin(), (c).end()
using namespace std;

typedef vector<vector<int> > Graph;

void visit(const Graph &g, int v, vector< vector<int> >& scc,
    stack<int> &S, vector<bool> &inS,
    vector<int> &low, vector<int> &num, int& time) {
  low[v] = num[v] = ++time;
  S.push(v); inS[v] = true;
  FOR(e, g[v]) {
    int w = *e/*->dst*/;
    if (num[w] == 0) {
      visit(g, w, scc, S, inS, low, num, time);
      low[v] = min(low[v], low[w]);
    } else if (inS[w])
      low[v] = min(low[v], num[w]);
  }
  if (low[v] == num[v]) {
    scc.push_back(vector<int>());
    while (1) {
      int w = S.top(); S.pop(); inS[w] = false;
      scc.back().push_back(w);
      if (v == w) break;
    }
  }
}
void stronglyConnectedComponents(const Graph& g,
    vector< vector<int> >& scc) {
  const int n = g.size();
  vector<int> num(n), low(n);
  stack<int> S;
  vector<bool> inS(n);
  int time = 0;
  REP(u, n) if (num[u] == 0)
    visit(g, u, scc, S, inS, low, num, time);
}

int main(){
	int V,E,s,t;
	scanf("%d%d",&V,&E);
	Graph g(V);
	vector< vector<int> > scc;
	for(;E--;)scanf("%d%d",&s,&t),g[s].push_back(t);
	stronglyConnectedComponents(g,scc);
	scanf("%d",&E);
	for(;E--;){
		scanf("%d%d",&s,&t);
		for(V=0;V<scc.size();V++)if(find(scc[V].begin(),scc[V].end(),s)!=scc[V].end()&&find(scc[V].begin(),scc[V].end(),t)!=scc[V].end())break;
		printf("%d\n",V<scc.size());
	}
}

Measured memory_bytes: 3388
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long LL;
const int INF = 999999999;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    set<int> an, o;
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    rep(i, n) o.insert(a[i]);
    rep(i, m){
        if(o.find(b[i]) != o.end()){
            an.insert(b[i]);
        }
    }
    rep(i, m) o.insert(b[i]);
    cout << an.size() << " " << o.size() << endl;
    for(auto &x: an) cout << x << endl;
    for(auto &x: o) cout << x << endl;

}


Measured memory_bytes: 15080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	set<string> sset;
	string p;
	cin >> p;
	sset.insert(p);
	FOR(i,0,n-1){
		string s;
		cin >> s;
		if(sset.count(s)==1||s[0]!=p[p.size()-1]){
			cout << "No" << endl;
			return 0;
		}
		sset.insert(s);
		p = s;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int n,m[50];
bool prime[1000000],c[1000000];

void saiki(int total){
	int i;
	
	c[total]=1;
	
	for( i=total ; i>=0 ; i--){
		if(c[i]==1){
			for(int j=0;j<n;j++){
				if(i-m[j]>=0){
					c[i-m[j]]=1;
				}
			}
		}
	}
}


int main(void)
{
	int i,j;
	//f
	prime[0]=1;
	prime[1]=1;
	for(i=3;i<1000000;i++){
		if(i%2==0){
			prime[i]=1;
		}
	}
	for(i=3;i<1000000;i+=2){
		if(prime[i]==0){
			for(j=(i+i);j<1000000;j+=i){
				prime[j]=1;
			}
		}
	}
	//
	while(1){
		int x;
		int flg=0;
		scanf("%d%d",&n,&x);
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d",&m[i]);
		}
		saiki(x);
		//
		for(i=0;i<x;i++){
			if(c[i]==1 && prime[x-i]==0){
				flg=1;
				break;
			}
		}
		if(flg==1){
			printf("%d\n",x-i);
		}
		else puts("NA");
		for(i=0;i<1000000;i++){
			c[i]=0;
		}
		for(i=0;i<50;i++){
			m[i]=0;
		}
		//
	}
	return 0;
}

Measured memory_bytes: 2712
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>

template <class T>
constexpr T inf=(T(1)<<(8*sizeof(T)-3));

template <class Weight>
struct Edge {
  size_t src, dst;
  Weight cost;

  Edge(size_t src, size_t dst, Weight cost=1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(const Edge<Weight> &rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <class Weight>
using Graph=std::vector<std::vector<Edge<Weight>>>;
int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<std::vector<int>> g(N, std::vector<int>(N, inf<int>));
  for (size_t i=0; i<N; ++i)
    g[i][i] = 0;

  std::vector<Edge<int>> es;
  for (size_t i=0; i<M; ++i) {
    size_t a, b;
    int c;
    scanf("%zu %zu %d", &a, &b, &c);
    --a;
    --b;

    g[a][b] = g[b][a] = c;
    es.emplace_back(a, b, c);
  }
  
  std::vector<std::vector<int>> d=g;
  for (size_t k=0; k<N; ++k)
    for (size_t i=0; i<N; ++i)
      for (size_t j=0; j<N; ++j)
        d[i][j] = std::min(d[i][j], d[i][k]+d[k][j]);

  auto is_cand=[&](const Edge<int> &e)->bool {
    for (size_t i=0; i<N; ++i)
      for (size_t j=0; j<N; ++j)
        if (d[i][e.src] + e.cost + d[e.dst][j] == d[i][j])
          return true;

    return false;
  };

  int res=M;
  for (const auto &e: es)
    if (is_cand(e))
      --res;

  printf("%d\n", res);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  ll i,sum=0,mini=1e9+7;
  for(i=0;i<=n-k;i++){
    sum=a.at(i+k-1)-a.at(i);
    if(a.at(i+k-1)>0 && a.at(i)<0){
      ll p=min(a.at(i+k-1),abs(a.at(i)));
      sum+=p;
    }else{
      sum=max(abs(a.at(i+k-1)),abs(a.at(i)));
    }
    mini=min(mini,sum);
  }
  cout << mini;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());

    int cnt = 0;
    for(int k = 0; k <= 200000; k++) {
        auto itr = lower_bound(a.begin(), a.end(), k);
        if(itr - a.begin() == a.end() - itr)cnt++;
    }
    cout << cnt << endl;
}

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

  int ans = 700;
  rep(i,3){
    if (str[i] == 'o') ans += 100;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3584
// 解き直し.
// https://img.atcoder.jp/agc010/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
LL a[101010], d[101010];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    LL k = 0, one = (LL)(N + 1) * (LL)N / 2;
    rep(i, N){
        scanf("%lld", &a[i]);
        k += a[i];
    }
    
    // 2. 操作回数を計算.
    if(k % one){
        puts("NO");
        return 0;
    }
    k /= one;
    
    // 3. 差分を計算.
    a[N] = a[0];
    rep(i, N) d[i] = a[i + 1] - a[i];
    
    // 4. (d[i] - k) を チェック.
    bool ans = true;
    rep(i, N){
        LL t = d[i] - k;
        if(t > 0 || t % N != 0){
            ans = false;
            break;
        }
    }
    
    // 5. 出力.
    printf("%s\n", ans ? "YES" : "NO");
    return 0;
    
}

Measured memory_bytes: 5204
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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

ll mp[500][500];
pair<ll, ll> par[500][500];
ll kosu[500][500];
bool used[500][500];
int main()
{
  ll H, W;
  cin >> H >> W;
  vector<pair<ll, ll>> pB;
  REP(i, H) REP(j, W) {
    char c; cin >> c;
    if (c == '#') {
      mp[i][j] = 1;
      pB.PB(MP(i, j));
    } else mp[i][j] = -1;
  }

  ll dx[] = {-1, 0, 1, 0};
  ll dy[] = {0, -1, 0, 1};
  ll ans = 0;
  REP(i, 500) REP(j, 500) par[i][j] = MP(i, j);

  REP(i, pB.size()) {
    if (used[pB[i].FI][pB[i].SE]) {
      pair<ll, ll> pos = par[pB[i].FI][pB[i].SE];
      ans += kosu[pos.FI][pos.SE];
      continue;
    }
    queue<pair<ll, ll>> q;
    q.push(MP(pB[i].FI, pB[i].SE));
    used[pB[i].FI][pB[i].SE] = true;
    ll cnt = 0;
    while (! q.empty()) {
      pair<ll, ll> pos = q.front(); q.pop();
      ll y = pos.FI;
      ll x = pos.SE;
      REP(j, 4) {
        ll ny = y + dy[j];
        ll nx = x + dx[j];
        if (0 <= ny && ny < H && 0 <= nx && nx < W
            && !used[ny][nx]
            && mp[y][x] * mp[ny][nx] == -1) {
          par[ny][nx] = MP(pB[i].FI, pB[i].SE);
          used[ny][nx] = true;
          q.push(MP(ny, nx));
          if (mp[ny][nx] == -1) cnt++;
        }
      }
    }
    ans += cnt;
    kosu[pB[i].FI][pB[i].SE] = cnt;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11628
#include<stdio.h>
int main(void)
{
	int n,nai[5][4][11]={0};
	int b,f,r,v,i;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		nai[b][f][r]+=v;
	}
	for(b=1;b<5;b++){
		for(f=1;f<4;f++){
			for(r=1;r<11;r++){
				printf(" %d",nai[b][f][r]);
			}
			printf("\n");
		}
		if(b!=4){
			printf("####################\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
n = int(input())

L = [int(i) for i in input().split()]

Answer = int(0)
for i in range(n-2):
     if L[i]<L[i+1] and L[i+1]<L[i+2]:
             Answer = Answer + 1
             continue
     if L[i+2]<L[i+1] and L[i+1]<L[i]:
             Answer = Answer + 1
             continue
print(Answer)


Measured memory_bytes: 2940
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<stack>
#include<vector>
#include<map> 
#define maxn 1005
#define INF 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;


string s;
int main()
{
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;

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


int main()
{
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  vector<char> v(int(s.size()), 'a');
  for (int i = 0; i < int(s.size()); i++){
    v[i] = s[i];
  }
  set<char> set(v.begin(), v.end());
  vector<char> v2(set.begin(), set.end());
  // for(char c : v2) cout << c;
  // cout << endl;
  if (int(v2.size()) == 26) {
    cout << "None" << endl;
    return 0;
  }

  string tmp = "abcdefghijklmnopqrstuvwxyz";

  for (int i = 0; i < 26; i++){
    if (v2[i] != tmp[i]) {
      cout << tmp[i] << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int h[112345];
    rep(i, n) cin >> h[i];
    int dp[112345];
    rep(i, n) dp[i] = MOD;
    dp[0] = 0;
    for (int i = 0; i < n;i++){
        if(i+1<n)
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if(i+2<n)
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

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

using namespace std;

ll sum(ll x){
    ll ss = 0;
    string s = to_string(x);
    for(int i = 0; i < s.size(); ++i)
        ss += (s[i] - '0');
    return ss;
}

//bool check(ll x){
//    string s = to_string(x);
//    for(int i = 0; i < s.size(); ++i)if(s[i] != '9')return false;
//    return true;
//}

bool check(ll a, ll b){
    //if a/s(a) >= b/s(b) return true else false

    long double ans1 = a*1.0/sum(a);
    long double ans2 = b*1.0/sum(b);

    return ans1 >= ans2;
}

int main(){

    cout << fixed << setprecision(6);

//    long double array[511112] = {0.0};

    ll i, j, k;
    cin >> k;

    ll ct = 1;
    ll p = 1;
    ll p2 = 10;

//    cout << check(18, 9) << endl;

    for(i = 0; i < k; ++i){
        cout << ct << endl;
        if(check(ct + p2, ct + p)){
            ct = ct + p;
        }
        else{
            ct = ct + p2;
            p2 = p2 * 10;
            p = p * 10;
        }
    }

//    for(i = 1; i <= 511111; ++i){
////        cout << i << " " << sum(i) << " -- ";
//        long double x = i*1.0/sum(i);
//        array[i] = x;
//
////        cout << x << endl;
//    }
//
//    for(i = 1; i <= 511111; ++i){
//        for(j = i + 1; j <= 511111; ++j){
//            if(array[i] > array[j])break;
//        }
//        if(j > 511111)cout << i << endl;
//    }
//
//    ll ct = 1;
//
//    ll p = 1;
//
//    for(ll i = 0; i < k; ++i){
//        cout << ct << endl;
//        if(check(ct)){
//            p = p * 10;
//        }
//        ct = ct + p;
//    }


    return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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);
  char a;
  cin >> a;
  if('a' <= a && a <= 'z'){
    ANS('a');
  }else{
    ANS('A');
  }
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pipii;
typedef long long ll;
typedef pair<ll,ll> pll;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e18;
const ll MOD=1e9+7;
struct edge{
    int to;
    int cost;
};
int main(){
    int N,Q;cin>>N>>Q;
    string S;cin>>S;
    vector<int> C(N,0);
    for(int i=1;i<N;++i){
        C[i]+=C[i-1];
        if(S[i-1]=='A'&&S[i]=='C'){
            C[i]++;
        }
    }
    for(int i=0;i<Q;++i){
        int l,r;cin>>l>>r;
        l--;r--;
        cout<<C[r]-C[l]<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int64_t i = 0;
  for(auto it = s.begin();
      it != s.end();
      ++it, ++i)
    {
      if((i % 2) == 0)
        {
          if(*it == 'L')
            {
              cout << "No" << endl;
              return 0;
            }
        }
      else
        {
          if(*it == 'R')
            {
              cout << "No" << endl;
              return 0;
            }
        }
    }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256