akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll N=100005;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll pow1(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1){
        	res=(res*a)%M;
		}
        a=(a*a)%M;
        b>>=1;
    }
    return res%M;
}

// struct segtree{
//     ll x,y;
//     ll tree[4*N];

//     void build_tree(vector<ll>&v , ll ind,ll l, ll r)
//     {
//         if(l==r)
//         {
//             tree[ind]=v[l];
//             return;
//         }
//         ll mid=(l+r)/2;
//         build_tree(v,2*ind,l,mid);
//         build_tree(v,2*ind+1,mid+1,r);
//         tree[ind]=max(tree[2*ind],tree[2*ind+1]);
//     }

//     ll query(ll ind, ll l, ll r)
//     {
//         // cout<<l<<" "<<r<<" "<<endl;
//         if(x>r || y<l)return -LLONG_MAX;
//         if(l>=x && r<=y)return tree[ind];
//         ll mid=(l+r)/2;
//         return max(query(2*ind,l,mid),query(2*ind+1,mid+1,r));
//     }
// }obj;

int main()
{
    fast;

    #ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
    #endif
    
    ll T=1;
//     cin>>T;
    while(T--)
    {
        string s;
        cin>>s;
        ll num=0;
        for(auto it:s)
        {
            num+=(it-'0');
        }
        if(num%9)
        cout<<"No";
        else 
        cout<<"Yes"<<endl;
    }

}

Measured memory_bytes: 3768
#include <stdio.h>
#include <map>
using namespace std;
char s[250002];
pair<int,int> pw[500001],prefix[250001];
int pos[250001];
const int MOD=1002068539;
int qpow(int a,int b)
{
    int ret=1;
    for (;b;a=(long long)a*a%MOD,b>>=1)
        if (b&1)
            ret=(long long)ret*a%MOD;
    return ret;
}
void madd(int &a,int b)
{
    a+=b;
    if (a>=MOD)
        a-=MOD;
}
void madd(pair<int,int> &a,pair<int,int> b)
{
    madd(a.first,b.first);
    madd(a.second,b.second);
}
void msubtract(int &a,int b)
{
    a-=b;
    if (a<0)
        a+=MOD;
}
void msubtract(pair<int,int> &a,pair<int,int> b)
{
    msubtract(a.first,b.first);
    msubtract(a.second,b.second);
}
void mmultiply(pair<int,int> &a,pair<int,int> b)
{
    a.first=(long long)a.first*b.first%MOD;
    a.second=(long long)a.second*b.second%MOD;
}
int main()
{
    int n;
    scanf("%d%s",&n,s+1);
    pw[0]=make_pair(1,1);
    for (int i=1;i<=500000;++i)
    {
        pw[i]=pw[i-1];
        mmultiply(pw[i],make_pair(35748299,19260817));
    }
    pos[0]=0;
    for (int i=1;i<=n;++i)
    {
        prefix[i]=prefix[i-1];
        pos[i]=pos[i-1];
        if (s[i]=='<')
            --pos[i];
        else if (s[i]=='>')
            ++pos[i];
        else if (s[i]=='+')
            madd(prefix[i],pw[pos[i]+250000]);
        else
            msubtract(prefix[i],pw[pos[i]+250000]);
    }
    long long ans=0;
    map<pair<int,int>,int> mp;
    for (int i=n;i>=1;--i)
    {
        pair<int,int> tmp=prefix[n];
        msubtract(tmp,prefix[i]);
        ++mp[tmp];
        tmp=prefix[n];
        if (pos[i-1]>0)
            mmultiply(tmp,make_pair(pw[pos[i-1]].first,pw[pos[i-1]].second));
        else if (pos[i-1]<0)
            mmultiply(tmp,make_pair(qpow(pw[-pos[i-1]].first,MOD-2),qpow(pw[-pos[i-1]].second,MOD-2)));
        pair<int,int> search=prefix[n];
        msubtract(search,tmp);
        msubtract(search,prefix[i-1]);
        ans+=mp[search];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 38528
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long solve(long n)
{
  long result = 0;
  for (long i = 2; i * i <= n; ++i) {
    if (n % i != 0) continue;

    for (int j = 1; n % i == 0; ++j) {
      bool ok = true;
      for (int k = 0; k < j; ++k) {
        if (n % i != 0) {
          ok = false;
          break;
        }
        n /= i;
      }
      if (!ok) break;
      ++result;
    }
  }

  if (n != 1) ++result;

  return result;
}

int main()
{
  long n;
  std::cin >> n;

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
long long R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  long long n,l,p,h,i,a,b[400010],c[400010],d,ans=0;
  scanf("%lld %lld %lld",&n,&l,&p);
  for(i=0;i<n;i++){
    scanf("%lld %lld",&a,&b[R]);
    c[R]=0;
    hin(a*2);
  }
  d=0;
  while(C-1){
    i=hout();
    if(c[i]==0){
      if(d<b[i]){
	a=(b[i]-d-1)/p+1;
	d+=a*p;
	b[R]=a*p;
	c[R]=1;
	hin(N[i]+l+l+l+l+1);
	ans+=a;
      }
    }
    else d-=b[i];
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int X[N];
  int count=0;
  while(count<N){
    cin >> X[count] ;
    count++;
  }
  sort(X,X+N);
    int Xmax,Xmin;
  Xmax = X[N-1];
  Xmin = X[0];
  int sum=0;
  int comper = 10000000;
  int answer = Xmax+1;
  while(Xmin<=Xmax){
    for(int i = 0; i<N; i++)
       sum +=pow((X[i]-Xmin),2);
    if(comper>sum){
      comper=sum;
      answer = Xmin;
    }
    Xmin++;
    sum=0;
  }
  
  cout << comper << endl;
  
  
}

Measured memory_bytes: 256
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) when x < y -> Node (y, doit l, r)
    | Node (y, l, r) -> Node (y, l, doit r)
  in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (f x; doit l; doit r)
  in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (doit l; f x; doit r)
  in
  doit t

let print t =
  let f e = print_string " "; print_int e in
  inorder f t;
  print_newline ();
  preorder f t;
  print_newline ()

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> read (i + 1) (insert (int_of_string n) t)
      | _ -> (print t; read (i + 1) t)
    end
  in
  read 0 (create ())

Measured memory_bytes: 31856
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x,y;
		x = sc.nextInt();
		y = sc.nextInt();
		if( x < y) {
			System.out.println("a < b");
		} else if( x > y ) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");

		}
	}

}



Measured memory_bytes: 26160
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        S: String,
    }

    if S.len() == 1 {
        println!("{}", S);
        return;
    }

    let mut ans: i64 = 0;

    // (N - 1) 個のスペースに '+' を入れられる。2^(N-1)
    let bits = S.len() - 1;
    for i in 0..1 << bits {
        let mut cur: usize = 0;
        let mut cand = 0;

        for j in 0..bits {
            // j番目ビットが立っているか
            if i & (1 << j) != 0 {
                let num: i64 = S[cur..=j].parse().unwrap();
                cand += num;
                cur = j + 1;
            }
        }
        let num: i64 = S[cur..S.len()].parse().unwrap();
        cand += num;

        ans += cand;
    }

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


Measured memory_bytes: 2152
#include<cstdio>
#include<cstring> 
#include<algorithm>
using namespace std;

int n,x,a[101],s;

int main()
{
	scanf("%d%d",&n,&x);
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	s=0;
	for (int i=1; i<=n; i++) 
	{
		s+=a[i];
		if (s>x) break;
	}
	if (s==x) {printf("%d\n",n); return 0;}
	if (s<x) {printf("%d\n",n-1); return 0;}
	sort(a+1,a+1+n);
	s=0;
	for (int i=1; i<=n; i++)
	{
		s+=a[i];
		if (s>x) {printf("%d\n",i-1); return 0;}
	}
	return 0;
}

Measured memory_bytes: 128
import sys
from collections import defaultdict as dd
import heapq
input = sys.stdin.readline
n, m, s, t = map(int, input().split())
e = dd(list)
money = 10 ** 15
for _ in range(m):
  u, v, a, b = map(int, input().split())
  e[u].append((v, a))
  e[v].append((u, a))
  e[u + n].append((v + n, b))
  e[v + n].append((u + n, b))
"""
for i in range(1, n + 1):
  e[i].append((i + n, 0))
"""
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 15)
      v0 = v // (10 ** 15)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 15) + p[0])
    return d
d = dijkstra(2 * n + 1, e)
x = d.path(s, 2 * n + 1)
y = d.path(t + n, 2 * n + 1)
#print(x)
#print(y)
paths = [float("inf")] * (n + 1)
minpaths = [float("inf")] * (n + 1)
for i in range(1, n + 1):
  paths[i] = x[i] + y[n + i]
#print(paths)
minpaths[-1] = paths[-1]
for i in range(n - 1, -1, -1):
  minpaths[i] = min(minpaths[i + 1], paths[i])
#print(minpaths)
for i in range(1, n + 1):
  print(money - minpaths[i])

Measured memory_bytes: 143364
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int cnt[100010];

signed main()
{
    int N,K; cin>>N>>K;
    REP(i,N){
        int a,b; cin>>a>>b;
        cnt[a]+=b;
    }
    
    int sum=0;
    for(int i=1;i<=100000;i++){
        sum+=cnt[i];
        if(sum>=K){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1024
main = do
 li <- getLine
 let n = read li
 let ans = compute n
 putStrLn ans

compute :: Int -> String
compute n
  | d == 3 = "bon"
  | d `elem` [0,1,6,8] = "pon"
  | True = "hon"
  where
    d = n `mod` 10

Measured memory_bytes: 3876
#include<bits/stdc++.h>
using namespace std;
int h,w,m,a[300001],b[300001],p1,p2;
typedef pair<int,int> pi;
set<pi>st;
int main(){
	int i,j,x,y;
	cin>>h>>w>>m;
	vector<int>l,r;
	for(i=1;i<=m;++i){
		cin>>x>>y;
		st.insert(make_pair(x,y));
		a[x]++;
		b[y]++;
		if(a[x]>p1){
			l.clear();
			p1=a[x];
		}
		if(a[x]==p1)l.push_back(x);
		if(b[y]>p2){
			r.clear();
			p2=b[y];
		}
		if(b[y]==p2)r.push_back(y);
	}
	for(i=0;i<l.size();++i){
		for(j=0;j<r.size();++j){
			if(st.find(make_pair(l[i],r[j]))==st.end()){
				cout<<p1+p2;
				return 0;
			}
		}
	}
	cout<<p1+p2-1;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  string ans = "";
  for(int i = 0; i < S.length(); i++){
    ans += S[i];
    ans += T[i];
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 384
//  Created by Sengxian on 2017/6/30.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
//  AGC016F 博弈 + 状压 DP
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MAX_N = 15, MOD = 1000000007;
int n, m, G[MAX_N], popCount[1 << MAX_N], cnt[MAX_N][1 << MAX_N];
int dp[1 << MAX_N];

inline bool check(int s) {
	return (s & 3) == 0 || (s & 3) == 3;
}

void prepare() {
	popCount[0] = 0;
	for (int s = 1; s < (1 << n); ++s)
		popCount[s] = popCount[s >> 1] + (s & 1);
	for (int s = 0; s < (1 << n); ++s)
		for (int i = 0, t = s; i < n; ++i, t &= ~(1 << i))
			cnt[i][s] = popCount[t & G[i]];
}

void solve() {
	dp[0] = 1;
	for (int s = 1; s < (1 << n); ++s) if (check(s)) {
		int t = s;
		for (int u = s; u; u = (u - 1) & s) {
			int t = s ^ u, res = dp[t];
			if (!check(t)) continue;
			// u all zero
			// t all non-zero
			// u -> t
			for (int i = 0; i < n; ++i) if (u >> i & 1)
				res = (ll)res * (1 << cnt[i][t]) % MOD;
			// t -> u
			for (int i = 0; i < n; ++i) if (t >> i & 1)
				res = (ll)res * ((1 << cnt[i][u]) - 1) % MOD;
			(dp[s] += res) %= MOD;	
		}
	}
	
	int res = 1;
	for (int i = 0; i < m; ++i) (res *= 2) %= MOD;
	printf("%d\n", (res - dp[(1 << n) - 1] + MOD) % MOD);
}

int main() {
	n = readInt(), m = readInt();
	for (int i = 0; i < m; ++i) {
		int u = readInt() - 1, v = readInt() - 1;
		G[u] |= 1 << v;
	}
	
	prepare();
	solve();
	
	return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a,z;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A') {
      a=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='Z'){
      z=i;
      break;
    }
  }
 cout <<z-a+1<<endl;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int solve(int n, vector<string> &mp) {
  bool ok = false;
  for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (mp[i][j] == '#') ok = true;
  if (!ok) {
    return -1;
  }
  int ans = n * 2;
  bool full = false;
  int hok = 0;
  for (int i = 0; i < n; i++) {
    bool ok = true;
    for (int j = 0; j < n; j++) if (mp[j][i] == '.') ok = false;
    if (ok) hok++;
  }
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 0; j < n; j++) if (mp[i][j] == '#') c++;
    bool ok = false;
    for (int j = 0; j < n; j++) if (mp[j][i] == '#') ok = true;
    if (ok) {
      ans = min(ans, 2 * n - c - hok);
    } else {
      ans = min(ans, 2 * n - c - hok + 1);
    }
    if (c == n) full = true;
  }
  if (full) {
    int c = 0;
    for (int i = 0; i < n; i++) {
      bool ng = false;
      for (int j = 0; j < n; j++) {
        if (mp[j][i] == '.') ng = true;
      }
      if (!ng) c++;
    }
    ans = min(ans, n - c);
  }
  return ans;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> mp(n);
  for (int i = 0; i < n; i++) cin >> mp[i];
  cout << solve(n, mp) << endl;

  /*
  for (int i = 0; i < (1 << 9); i++) {
    i = 6;
    for (int j = 0; j < 9; j++) if ((i >> j) & 1) mp[j / 3][j % 3] = '#'; else mp[j / 3][j % 3] = '.';
    cout << solve(n, mp) << endl;
    for (auto &s : mp) cerr << s << endl;
    break;
  }
   */

  return 0;
}


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

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

    int x[200100];
    int y[200100];
    int z;
    for ( int i = 0; i < n; i++){
         cin >> z;
         x[i] = z;
         y[i] = z;
    }

    sort(x, x + n);
    int ans1 = x[n / 2 - 1];
    int ans2 = x[n / 2];


    for ( int i = 0; i < n; i++){
        if (y[i] <= ans1) cout << ans2 << endl;
        else cout << ans1 << endl;
    }
}

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

int main(){
    long long n,i,x=1;
    long long inf = 1e18;

    cin >> n;
    vector<long long> vec(n);
    for(int i=0;i<n;i++) cin >> vec[i]; 
    for(int i=0;i<n;i++){
        if (vec[i]==0){
            cout << 0;
            return 0;
        }
        
    }

    for(int i=0;i<n;i++){
        if (x > inf/vec[i]){
            cout << -1;
            return 0;
        }
        else x *= vec[i];
    }
    cout << x;

    
    return 0;
}

Measured memory_bytes: 3928
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x = x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x = x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key){
    return u;
  }
  if(k < u->key){
    return treeSearch(u->left, k);
  }
  else{
    return treeSearch(u->right, k);
  }

}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL){
    return (Node)treeMinimum(x->right);
  }

  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL){
    y = z;
  }
  else{
    y = (Node)treeSuccessor(z);
  }
  
  if(y->left != NIL){
    x = y->left;
  }
  else{
    x = y->right;
  }
  
  if(x != NIL){
    x->parent = y->parent;
  }
  
  if(y->parent == NIL){
    root = x;
  }
  else if(y == y->parent->left){
    y->parent->left;
  }
  else{
    y->parent->right = x;
  }
  
  if(y != z){
    z->key = y->key;
  } 
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }

}

void inorder(Node u){
  
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d", u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
  
}
void preorder(Node u){
  
  printf(" %d", u->key);
  if(u->left != NIL){
    preorder(u->left);
  }
  if(u->right != NIL){
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

using namespace std;
using ll = long long;

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

int main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  rep(i, h) cin >> s[i];
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) {
    int l = 0, r = 0;
    rep(j, w) {
      if (s[i][j] == '.')
        ++l;
      else
        l = 0;
      if (s[i][w - 1 - j] == '.')
        ++r;
      else
        r = 0;
      a[i][j] += l;
      a[i][w - j - 1] += r;
    }
  }

  rep(j, w) {
    int l = 0, r = 0;
    rep(i, h) {
      if (s[i][j] == '.')
        ++l;
      else
        l = 0;
      if (s[h - i - 1][j] == '.')
        ++r;
      else
        r = 0;
      a[i][j] += l;
      a[h - i - 1][j] += r;
    }
  }

  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, a[i][j]);
  cout << ans - 3 << endl;
  return 0;
}


Measured memory_bytes: 26400
#include<iostream>
using namespace std;
int main(void) {
	//入力
	int n;
	cin >> n;
	int a[10000];
	for (int i(0); i < n; i++) {
		cin >> a[i];
	}
	//処理
	int total(0);
	for (int i(0); i < n; i++) {
		while (a[i]%2==0) {
			total++;
			a[i] /= 2;
		}
	}
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline #文字列入力はするな！！

n=int(input())
a=list(map(int,input().split()))

def f(x):
    z=[0]*40
    i=1
    while x>0:
        z[-i]=x%2
        x=x//2
        i+=1
    return z

for i in range(n):
    a[i]=f(a[i])

y=[0]*40
for i in range(40):
    y[i]=sum(a[j][i] for j in range(n))%2
ans=[]
for i in range(n):
    p=0
    for j in range(40):
        if y[-j-1]!=a[i][-j-1]:
            p+=2**j
    ans.append(p)
for i in range(n):
    print(ans[i], end=" ")



Measured memory_bytes: 182988
import itertools

N, M = map(int, input().split())
XYZ = [tuple(map(int, input().split())) for _ in range(N)]

ans = 0
for xs, ys, zs in itertools.product([1, -1], repeat=3):
    S = sorted([(xs * x + ys * y + zs * z) for x, y, z in XYZ], reverse=True)
    ans = max(ans, sum(S[:M]))
print(ans)


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

using namespace std;

int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, 1, -1};
char ans[55][55];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  char grid[h][w];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> grid[i][j];
    }
  }
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(grid[i][j] == '#') ans[i][j] = '#';
      else{
        int cnt = 0;
        for(int k=0; k<8; k++){
          int nx = dx[k] + i;
          int ny = dy[k] + j;
          if(nx >= 0 && nx < h && ny >= 0 && ny < w && grid[nx][ny] == '#') cnt++;
        }
        ans[i][j] = cnt + '0';
      }
    }
  }
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cout << ans[i][j];
    }
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;



int main() {
	stack<int> st;
	string s;
	cin >> s;
	st.push(s[0]);
	int count = 0;
	if (s.size() == 1)cout << 0 << endl;
	else {
		for (int i = 1; i < s.size(); i++) {
			if (st.empty()) {
				st.push(s[i]);
				continue;
			}
			if (s[i] != st.top()) {
				st.pop();
				count += 2;
			}
			else {
				st.push(s[i]);
			}


		}
		cout << count << endl;
	}
	
	return 0;
}



Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var all = int.Parse(Console.ReadLine());
            var allSet = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToList();
            var need = int.Parse(Console.ReadLine());
            var needSet = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToList();
            allSet.Sort();
            needSet.Sort();

            int index = 0;
            for(int j = 0; j < needSet.Count; j++)
            {
                int now = needSet[j];
                for(int i= index; i <= allSet.Count; i++)
                {
                    if (i == allSet.Count)
                    {
                        Console.WriteLine("NO");
                        return;
                    }

                    if(now == allSet[i])
                    {
                        index = i + 1;
                        break;
                    }
                }

            }

            Console.WriteLine("YES");

        }
    }
}

Measured memory_bytes: 39232
/*input
12 3
4 56 78 901 2 345 67 890 123 45 6 789
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, s = 0, c = 0; cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
    	cin >> a[i];
    	s += a[i];
    }
    for(int i = 0; i < n; i++)
    {
    	if(!(s % (4 * m)) && a[i] >= s/(4 * m)) c++;
    	else if(s % (4 * m) && a[i] > s/(4 * m)) c++;
    }
    if(c >= m) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

MOD = 10**9 + 7

L = 4 * 10**6
fact = [1]*(L+1)
rfact = [1]*(L+1)
r = 1
for i in range(1, L+1):
  fact[i] = r = r * i % MOD
rfact[L] = r = pow(fact[L], MOD-2, MOD)
for i in range(L, 0, -1):
  rfact[i-1] = r = r * i % MOD

def solve():
    A, B, C, Sx, Sy = map(int, readline().split())
    if A+B+C == 0:
        return False
    if not Sx > Sy:
        A, B = B, A
        Sx, Sy = Sy, Sx
    Sd = Sx - Sy
    K = Sy
    zero = False
    if A == 0:
        if B > 0 or Sd != 0:
            zero = True
        else:
            K = 0
    elif B == 0:
        K = 0

    if zero:
        write("0\n")
        return True

    res = 0
    for k in range(K+1):
        if Sd+k < A or k < B:
            continue
        r = fact[Sd + k-1] * rfact[Sd + k - A] % MOD
        r = r * (fact[k-1] * rfact[k - B] % MOD) % MOD
        r = r * (fact[Sy-k + A+B+C-1] * rfact[Sy-k] % MOD) % MOD
        res += r
    res %= MOD
    res = res * (fact[A+B+C] * rfact[A] % MOD) % MOD
    res = res * (rfact[B] * rfact[C] % MOD) % MOD
    res = res * (rfact[A-1] * rfact[B-1] % MOD) % MOD
    res = res * rfact[A+B+C-1] % MOD
    write("%d\n" % res)
    return True
while solve():
    ...


Measured memory_bytes: 321956
#include<iostream>
#include<cstdio> 
#include<cstring>
#define chkmin(x,y) x=min(x,y)
#define ll long long
using namespace std;
const int mod=1000000007;
int n,m,k,tim,top=0,low[55],dfn[55];
bool vis[55];
ll mi[210],ans=1,fac[210],ifac[210],inv[210];
struct edge
{
    int t;bool vis;
    edge *next,*rev;
}*con[55],*st[110];
void ins(int x,int y)
{
    edge *p=new edge;
    p->t=y;p->vis=0;
    p->next=con[x];
    con[x]=p;
}
ll ksm(ll a,int b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
void tarjan(int v,edge *fro)
{
    dfn[v]=low[v]=++tim;
    for(edge *p=con[v];p;p=p->next)
        if(!p->vis&&!p->rev->vis)
        {
            st[++top]=p;p->vis=p->rev->vis=1;
            if(!dfn[p->t])
            {
                tarjan(p->t,p);
                chkmin(low[v],low[p->t]);
                if(low[p->t]>=dfn[v])
                {
                    bool cir=1;int cnt=0;ll cal=0;
                    for(int i=top;st[i+1]!=p;cnt++,i--)
                        if(vis[st[i]->t]) cir=0;
                        else vis[st[i]->t]=1;       
                    if(cir)
                    {
                        for(int i=0;i<cnt;i++)  
                            cal=(cal+mi[gcd(cnt,i)])%mod;
                        cal=cal*inv[cnt]%mod;   
                    }
                    else cal=fac[cnt+k-1]*ifac[cnt]%mod*ifac[k-1]%mod;
                    ans=ans*cal%mod;
                    for(;st[top+1]!=p;top--) vis[st[top]->t]=0;
                }
            }
            else chkmin(low[v],dfn[p->t]);
        }
}
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    mi[0]=1;
    for(int i=1;i<=m;i++)
        mi[i]=mi[i-1]*k%mod;
    fac[0]=1;
    for(int i=1;i<=m+k;i++)
        fac[i]=fac[i-1]*i%mod;
    ifac[m+k]=ksm(fac[m+k],mod-2);

    for(int i=m+k-1;i>=0;i--)
        ifac[i]=ifac[i+1]*(i+1)%mod;
    for(int i=1;i<=m+k;i++)
        inv[i]=ifac[i]*fac[i-1]%mod;            
    for(int i=1;i<=m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        ins(x,y);ins(y,x);
        con[x]->rev=con[y];con[y]->rev=con[x];
    }
    for(int i=1;i<=n;i++)
        if(!dfn[i]) tarjan(i,NULL);
    printf("%lld",ans); 
    return 0;
}

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

#define FOR(i, m, n) for (int i = int(m); i < int(n); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
#define F first
#define S second
#define INF 1e9 + 7

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    int a[n];
    REP(i, n) {
        cin >> a[i];
    }

    double ans = 0;
    REP(i, n) {
        ans += 1.0 / a[i];
    }
    cout << 1.0 / ans << endl;

    return 0;
}

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

class main{
  public static void Main(string[] args){
    string[] s = Console.ReadLine().Split(" ");
    double dist = double.Parse(s[0]);
    double time = double.Parse(s[1]);
    double speed = double.Parse(s[2]);
    
    if((dist / speed) <= time)
      Console.WriteLine("Yes");
    else
      Console.WriteLine("No");
  }
}

Measured memory_bytes: 27384
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
a.sort()
if n%2 == 0:
    print(2*(sum(a[n//2:])-sum(a[:n//2]))-(a[n//2]-a[n//2-1]))
else:
    print(2*(sum(a[n//2+1:])-sum(a[:n//2]))-min(a[n//2]-a[n//2-1],a[n//2+1]-a[n//2]))

Measured memory_bytes: 7472
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const int DX[4] = {0, 0, +1, -1};
const int DY[4] = {+1, -1, 0, 0};
int main() {
    int H, W, K; cin >> H >> W >> K;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    vector<string> C(H); for (auto &c : C) cin >> c;
    vector<vector<int>> cost(H, vector<int>(W, 1e9));
    queue<tuple<int, int, int>> Q;
    Q.emplace(0, x1, y1);
    cost[x1][y1] = 0;
    while (!Q.empty()) {
        auto [c, x, y] = Q.front(); Q.pop();
        if (cost[x][y] != c) continue;
        if (x == x2 && y == y2) {
            cout << c << '\n';
            return 0;
        }
        for (int i = 0; i < 4; i++) {
            int nx = x, ny = y;
            for (int j = 0; j < K; j++) {
                nx += DX[i], ny += DY[i];
                if (!(0 <= nx && nx < H && 0 <= ny && ny < W)) break;
                if (C[nx][ny] != '.') break;
                if (cost[nx][ny] <= c) {
                    break;
                }
                if (cost[nx][ny] > c + 1) {
                    cost[nx][ny] = c + 1;
                    Q.emplace(c + 1, nx, ny);
                }
            }
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 12112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	vector<vector<int>>F(N, vector<int>(10));
	rep(i, N) {
		rep(j, 10) {
			cin >> F[i][j];
		}
	}
	vector<vector<int>>P(N, vector<int>(11));
	rep(i, N) {
		rep(j, 11) {
			cin >> P[i][j];
		}
	}
	vector<int>joi(10);
	int c = 0;
	vector<int>ans(1023);
	int cnt = 0;
	rep(j1, 2) {
		rep(j2, 2) {
			rep(j3, 2) {
				rep(j4, 2) {
					rep(j5, 2) {
						rep(j6, 2) {
							rep(j7, 2) {
								rep(j8, 2) {
									rep(j9, 2) {
										rep(j10, 2) {
											if (j1 + j2 + j3 + j4 + j5 + j6 + j7 + j8 + j9 + j10 != 0) {
												joi = { j1,j2,j3,j4,j5,j6,j7,j8,j9,j10 };
												rep(i, N) {
													rep(j, 10) {
														if (F[i][j] == joi[j] && joi[j] == 1) {
															c++;
														}
													}
													ans[cnt] += P[i][c];
													c = 0;
												}
												cnt++;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	sort(ans);
	reverse(ans);
	cout << ans[0] << 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 K;
	int sum = 0;
	
	cin>>K;
	
	for(int i = 1; i <= K; i++){
		for(int j = 1; j <= K; j++){
			for(int k = 1; k <= K; k++){
				sum += __gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 3648
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
count = 0
for i in range(N-1, -1, -1):
    if (AB[i][0]+count)%AB[i][1] != 0:
        count += AB[i][1] - (AB[i][0]+count)%AB[i][1]
print(count)


Measured memory_bytes: 27380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);

int main() {
    ll a, b;
    cin >> a >> b;
    ll ans = a*b/__gcd(a,b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <string> 
#include <sstream>  
#include <vector> 
#include <time.h>
#include <algorithm>
#include <list>
#include <fstream>
#include <math.h>
using namespace std;

int main(void){
	while(true){
		int n,A = 0,B = 0;
		cin >> n;
		if(n == 0)break;
		int a,b;
		while(n){
			n--;
			cin >> a >> b;
			if(a == b){
				A += a;
				B += b;
			}else if(a > b){
				A += a + b;
			}else{
				B += a + b;
			}
		}
		cout << A << " " << B << endl;		
	}

}

Measured memory_bytes: 1160
import sys;
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    n=int(sys.stdin.readline())
    for i in range(n):
        x=[int(num) for num in sys.stdin.readline().split(' ')]
        x.sort();
        if(x[0]**2+x[1]**2==x[2]**2): print("YES")
        else :print("NO")
solve()

Measured memory_bytes: 7740
import java.util.Scanner;

class Main{

	public static void main(String[] args) {




		Scanner scan = new Scanner(System.in);
		String[] aStrings = new String[3];
		for(int i= 0; i < 3;i++){
			aStrings[i] = scan.next();
		}
		for(int i = 0;i < 3;i++){
			System.out.print(aStrings[i].charAt(i));
		}



	}


}


Measured memory_bytes: 22996
N, M = list(map(int, input().split()))
ab = []
for i in range(N):
    A, B = list(map(int, input().split()))
    ab.append([A, B])

ab = sorted(ab, key=lambda x: x[0])

s = 0
for i in range(len(ab)):
    if M - ab[i][1] > 0:
        # print(ab[i][0],ab[i][1],ab[i][0] * ab[i][1],M)
        M -= ab[i][1]
        s += ab[i][0] * ab[i][1]
    else:
        for j in range(ab[i][1]):
            # print(ab[i][0],ab[i][1],ab[i][0] * ab[i][1],M)
            M -= 1
            s += ab[i][0]
            if M == 0:
                break
        break

print(s)

Measured memory_bytes: 22436
#include<cstdio>
#include<iostream>
#include<deque>
using namespace std;
deque<char>a, b, c;
int main()
{
    string s1,s2,s3;
    cin>>s1;
    cin>>s2;
    cin>>s3;
    int len1 = s1.size();
    for(int i = 0 ; i < len1; i++){
        a.push_back(s1[i]);
    }
    int len2 = s2.size();
    for(int i = 0 ; i < len2; i++){
        b.push_back(s2[i]);
    }
    int len3 = s3.size();
    for(int i = 0 ; i < len3; i++){
        c.push_back(s3[i]);
    }
    char now = a.front();
    a.pop_front();
    for(int i = 0; i < len1+len2+len3; i++){
        if(now == 'a'){
            if(a.size()==0){
                cout<<"A";
                break;
            }
            now = a.front();
            a.pop_front();
        }
        else if(now == 'b'){
            if(b.size()==0){
                cout<<"B";
                break;
            }
            now = b.front();
            b.pop_front();
        }
        else if(now == 'c'){
            if(c.size()==0){
                cout<<"C";
                break;
            }
            now = c.front();
            c.pop_front();
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int mod=998244353;
ll quick(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
const int maxn=1e5+7;
int cnt[maxn];
int main()
{
	int n;
	cin>>n;
	bool ok=1;
	for(int i=0,tmp;i<n;i++)
	{
		cin>>tmp;
		if(i==0&&tmp) ok=0;
		cnt[tmp]++;
	}
	if(cnt[0]!=1) ok=0;
	ll ans=1;
	for(int i=1;i<n;i++)
	{
		if(cnt[i]&&!cnt[i-1])
		{
			ok=0;
			break;
		}
		ans=(ans*quick(cnt[i-1],cnt[i]))%mod;
	}
	if(!ok) ans=0;
	cout<<ans<<endl;



}


Measured memory_bytes: 640
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

alias sread = () => readln.chomp();
enum MOD = 10 ^^ 9 + 7;

void main()
{
    auto S = sread();
    solve(S).writeln();
}

string solve(string S)
{
    long a = S[0 .. 2].to!long();
    long b = S[2 .. $].to!long();
    if ((12 < a && b == 0) || (12 < b && a == 0) || (12 < a && 12 < b) || S == "0000")
        return "NA";
    if (a <= 12 && b <= 12 && !(a == 0 || b == 0))
        return "AMBIGUOUS";
    if (a <= 12 && a != 0)
        return "MMYY";
    return "YYMM";
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s,t;
  cin >> s >> t;
  vector<int> p[26];
  int n = s.size();
  int m = t.size();
  rep(i,n){
    p[s[i]-'a'].push_back(i);
  }
  rep(i,n){
    p[s[i]-'a'].push_back(i+n);
  }
  ll ans = 0;
  int pos = 0;
  rep(i,m){
    int c = t[i]-'a';
    if(p[c].empty()){
      cout << -1 << endl;
      return 0;
    }
    pos = *lower_bound(p[c].begin(),p[c].end(),pos)+1;
    if(pos>=n){
      pos -= n;
      ans += n;
    }
  }
  ans += pos;
  cout << ans << endl;
}

Measured memory_bytes: 4208
N, K = map(int, input().split())
x = list(map(int, input().split()))


m=10**9
for i in range(N-K+1):
    temp=x[i+K-1]-x[i]+min(abs(x[i+K-1]), abs(x[i]))
    #print(x[i+K-1], x[i], temp)
    if temp<m:
        m=temp
print(m)

Measured memory_bytes: 62576
/* 

И пусть меня погубит, то к чему я
Бегу, не жалея ног.
И если мне суждено сгореть на восходе,
Я буду идти вперёд.

*/

#include <bits/stdc++.h>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;

const bool dbg_flg = 0;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n' 

const int inf = 1e9 + 7;
const int MAXN = 2e5 + 5;

int n;
int x;
int a[MAXN];

void solve() {
	cin >> n >> x;	

	if (x == 1 || x == 2 * n - 1) {
		cout << "No";

		return;
	}

	memset(a, -1, sizeof(a));

	a[n - 1] = x - 1;
	a[n] = x;
	a[n + 1] = x + 1;

	int cur = 1;

	for (int i = 1; i <= 2 * n - 1; i++) {
		if (a[i] == -1) {
	    	while (abs(cur - x) <= 1) cur++;
			a[i] = cur++;
		}		
	}

	cout << "Yes\n";

	for (int i = 1; i <= 2 * n - 1; i++) {
		cout << a[i] << '\n';
	}
}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 2304
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
   input! {
      a:u128,
      b:f64,
   }
   let f = b * 100.0;
   let mut b = (b * 100.0) as u128;
   if (f - b as f64).abs() > 0.5 {
      b += 1;
   }
   //println!("{}", a * b);
   println!("{}", (a * b) / 100);
}


Measured memory_bytes: 2216
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int K, S, ans = 0;
  cin >> K >> S;

  for (int i = 0; i <= K; i++) {
    if (i > S) break;

    for (int j = 0; j <= K; j++) {
      if (i + j > S) break;
      if (S <= (i + j + K)) ans++;
    }
  }

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


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=52;
const int MOD=1000000007;

int n;
char g[2][MAXN+1];

int dp[MAXN+1];

void run() {
	scanf("%d",&n); REP(i,2) scanf("%s",g[i]);

	memset(dp,0,sizeof(dp));
	REP(i,n) {
		if(g[0][i]==g[1][i]) {
			if(i==0) {
				dp[i+1]=3;
			} else if(g[0][i-1]==g[1][i-1]) {
				dp[i+1]=(ll)2*dp[i]%MOD;
			} else {
				dp[i+1]=dp[i];
			}
		} else if(i!=0&&g[0][i-1]==g[0][i]) {
			assert(g[1][i-1]==g[1][i]);
			if(i==1) {
				dp[i+1]=6;
			} else if(g[0][i-2]==g[1][i-2]) {
				dp[i+1]=(ll)2*dp[i-1]%MOD;
			} else {
				dp[i+1]=(ll)3*dp[i-1]%MOD;
			}
		}
	}
	printf("%d\n",dp[n]);
}

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


Measured memory_bytes: 256
def main():
    n = int(input())
    t = [int(i) for i in input().split()]
    m = int(input())
    for j in range(m):
        p,x = (int(i) for i in input().split())
        ans = 0
        for i in range(n):
            if i == p-1:
                ans += x
            else:
                ans += t[i]
        print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> s(m);
  REP(i, m){
    ll k;
    cin >> k;
    REP(j, k){
      ll a;
      cin >> a;
      a--;
      s[i].emplace_back(a);
    }
  }
  vector<ll>p(m);
  REP(i, m) cin >> p[i];

  ll ans = 0;
  REP(i, 1<<n){
    bool f = true;
    REP(j, m){
      ll count = 0;
      for(ll k : s[j]){
        if(i>>k & 1) count++;
      }
      if(count%2 != p[j]) f = false;
    }
    if(f) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
import sys

input = sys.stdin.readline

def main():
    mojiretu = ""
    while True:
        s = input().rstrip()
        if s == "":
            break
        mojiretu += s
    alphabet = [chr(i) for i in range(97, 97+26)]
    mojiretu = mojiretu.lower()
    for i in alphabet:
        print( i + " : " + str(mojiretu.count(i)))
    
if __name__ == "__main__":
    main()


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

int main()
{
    int n, k, x, y;
    int ans = 0;
    cin >> n >> k >> x >> y;
    if(n > k){
        ans = k*x + (n-k)*y;
    }
    else{
        ans = n*x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m, x[100001], dist[100001];
int ans;
int main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(int i = 0; i < m; i++)
        cin >> x[i];
    sort(x, x+m);

    for (int i = 1; i < m; i++) {
        dist[i] = abs(x[i] - x[i-1]);
    }
    sort(dist, dist+m);
   
    for (int i = 1; i < m - (n-1); i++)
        ans += dist[i];
    cout << ans << endl;

    return 0;
}


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

int main () {
	int N , M ; cin >> N >> M ;
	vector <int > cnt (M , 0);
	for ( int i = 0; i < N ; ++ i ) {
		int K; cin >> K ;
		for ( int j = 0; j < K ; ++ j ) {
			int A; cin >> A ; --A ;
			++ cnt [ A ];
        }
    }
	int ans = 0;
	for ( int i = 0; i < M ; ++ i ) {
		if ( cnt [ i ] == N ) {
			++ ans ;
        }
    }
	cout << ans << endl ;
}

Measured memory_bytes: 256