akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int a[100010],b[100010];
int t[100010];
signed main(){
    int n,m;
    cin>>n>>m;
    for (int i = 0; i < m; i++)
    {
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
    }
    for (int i = 0; i < m; i++)
    {
        if(a[i]==0){
            t[b[i]]++;
        }
        else if(b[i]==0){
            t[a[i]]++;
        }
        else{
            t[a[i]]++;
            t[b[i]]++;
        }
    }
    for (int i = 1; i < n; i++)
    {
        if(t[i]%2!=0){
            cout<<"NO"<<endl;
            return 0;
        }

    }
    cout<<"YES"<<endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include<algorithm>
#include<cstdio>
#define mxn 100010
using namespace std;
int n,m,sl,fh,s[mxn],c[mxn],pos[mxn];
long long sum,ans;
struct typ
{
	int i,v;
	bool operator <(const typ &x)const {return v>x.v;}
}a[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	n=rd();m=rd();int x,y,z,T=n;
	for(int i=1;i<=n;++i) s[i]=rd();
	sort(s+1,s+n+1);
	for(int i=1;i<=m;++i) a[i].i=rd(),a[i].v=rd();
	sort(a+1,a+m+1);a[0].v=a[1].v;
	for(int i=1;T&&i<=m;++i)
	{
		x=lower_bound(s+1,s+T+1,a[i].v)-s;
		if(x<=1) break;pos[i]=x-1;y=i;
		for(T=x-1,z=a[i].i;z&&T;--z,--T) c[T]=a[i].v-s[T];
	}
	for(int i=1;i<=n;++i) ans+=s[i]+c[i];
	for(int j=0,p=2,ln=a[1].i,i=pos[1];i;--i)
	{
		while(ln<i&&i-ln==pos[p]) ln+=a[p].i,p++;
		if(i-ln>0) ans+=s[i]-s[i-ln];
		else
		{
			if(p>=y) p=y;if(s[i]<a[p].v) break;
			ans+=a[1].v-a[p].v-(a[1].v-s[i]);
			j++;if(j==pos[p]) p--;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  short int N;
  char S[100];
  short int i;
  
  scanf("%hd",&N);
  scanf("%s",S);
  
  if(N%2==1){
    printf("No");
    return 0;
  }else{
    for(i=0;i<N/2;i++){
      if(S[i]!=S[i+N/2]){
        printf("No");
        return 0;
      }
    }
  }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int rem = n%10;
  n=rem;
  if (n==2 || n==4 || n==5 || n==7 || n==9)
    cout<<"hon";
  else if (n==0 || n==1 || n==6 || n==8)
    cout<<"pon";
  else if (n==3)
    cout<<"bon";
  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int N, i, j = 1, arr[10000], count = 0;
	cin >> N;
	for(i = 1; i <= N; i++)
	{
		cin >> arr[i];
	}
	for(i = 1; i < N; i = j)
	{
		int k, sum = 0, end;
		for(k = i+1; k <= N; k++)
		{
			if(arr[k] == arr[i])
			{
				sum++;
				end = k;
			}
			else 
			{
				end = k-1;
				break;
			}
		}
		j = end+1;
		count = count + (int) ((sum+1)/2);
		//cout << j << "hhhhhh" << count<< endl;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
	int a, b, c, i;
	int n = 0;
	scanf("%d%d%d",&a,&b,&c);
	for (i=a;i<=b;i++){ 
		if (c%i==0) { n++; } }
	printf("%d\n",n);
	
	return 0;
}

Measured memory_bytes: 596
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())
ans = 0
for i in range(N):
    a = A[i]
    ans += B[a - 1]
    if i > 0 and a == A[i-1] + 1:
        ans += C[A[i-1]-1]
print(ans)

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



int main()
{
    vector<int> h;
    unsigned int n;
    unsigned long long cnt = 0;

    cin >> n;


    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        h.emplace_back(temp);
    }

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

        if (h[i] > h[i + 1]) {
            cnt += h[i] - h[i + 1];
            h[i + 1] += h[i] - h[i + 1];
        }

    }

    cout << cnt << endl;
        


    


    return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  vector<int> s(n);
  int i;
  rep(i,n)cin>>s[i];
  int q;cin>>q;
  vector<int> t(q);
  rep(i,q)cin>>t[i];
  int ans=0;
  rep(i,q)
  {
    int ch=upper_bound(all(s),t[i])-lower_bound(all(s),t[i]);
    if(ch>0)ans++;
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 3244
<?php
$n = trim(fgets(STDIN));
$r = array(0,0);
for($i = 0; $i < $n; $i++){
    $s = explode(" ",trim(fgets(STDIN)));
    $j = strcmp($s[0],$s[1]);
    if($j == 0){
        $r[0]++;
        $r[1]++;
    }
    elseif($j > 0) $r[0] += 3;
    elseif($j < 0) $r[1] += 3;
}
echo implode(" ",$r)."\n";

Measured memory_bytes: 15276
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x.size())
#define pb push_back
#define mp make_pair
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define int long long
#define endl "\n"

using namespace std;

const int N = 500510;
const int inf = (int)(1e18) + 123;
const int mod = 998244353;
const double eps = 1e-9;


int n, m;

int dp[(1 << 13)], cost[(1 << 13)];

vector <pair <int, int>> v;

int f(int mask) {
    if (mask == (1 << n) - 1) {
        return 0;
    }
    int &res = dp[mask];
    if (res != -1) {
        return res;
    }
    res = inf;
    for(auto it : v) {
        res = min(res, f(mask | it.first) + it.second);
    }
    return res;
}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    memset(dp, -1, sizeof dp);
    memset(cost, -1, sizeof cost);
    for(int i = 1; i <= m; ++i) {
        int a, b; cin >> a >> b;
        int mask = 0;
        for(int j = 0; j < b; ++j) {
            int x; cin >> x;
            mask |= (1 << (x - 1));
        }
        v.push_back({mask, a});
    }
    int ans = f(0);
    if (ans == inf) {
        cout << -1;
    }else {
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 1000

int max(int,int);

int main(){
  int q,i,j,k,lenA,lenB,count[N+1][N+1],maxlen;
  char A[N+1],B[N+1];
  scanf("%d",&q);
  if(q>150) exit(2);
  for(k=0;k<q;k++){
    scanf("%s %s",&A[1],&B[1]);
    A[0]=B[0]=' ';
    lenA=strlen(&A[1]);
    lenB=strlen(&B[1]);
    maxlen=0;
    for(i=0;i<=lenA;i++) count[i][0]=0;
    for(i=1;i<=lenB;i++) count[0][i]=0;
    for(i=1;i<=lenA;i++){
      for(j=1;j<=lenB;j++){
	if(A[i] == B[j]) count[i][j] = count[i-1][j-1]+1;
	else count[i][j] = max(count[i][j-1],count[i-1][j]);
	maxlen = max(maxlen,count[i][j]);
      }
    }
    printf("%d\n",maxlen);
  }
  
  return 0;
}

int max(int x,int y){
  if(x>=y)return x;
  else return y;
}



Measured memory_bytes: 5688
import java.util.Scanner;

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

        while(sc.hasNext()) {
            int d = Integer.parseInt(sc.next());

            long S = 0;
            for (int i = d; i < 600; i += d) {
                S += Math.pow(i, 2) * d;
            }
            System.out.println(S);
        }
    }
}

Measured memory_bytes: 26172
#003_C
from bisect import bisect_left, bisect_right
n = int(input())
a = [int(input()) for _ in range(n)]
b = sorted(a)

ans = 0
for i in range(n):
    if (i - bisect_left(b, a[i])) % 2 == 1:
        ans += 1
print(ans // 2)

Measured memory_bytes: 8292
#include "bits/stdc++.h"
#include "sstream"
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=2e3+1;
int main() {
    quick
int  n,mn=INT_MAX,ans=0,x; cin>>n;
while(n--){
    cin>>x;
    if(x<=mn){mn=min(mn,x),ans++;}
}
cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
typedef long long i64;
const int P=1e9+7,M=2000100;
i64 pw(i64 a,i64 n){
	i64 v=1;
	for(;n;n>>=1,a=a*a%P)if(n&1)v=v*a%P;
	return v;
}
i64 fac[M+7],fiv[M+7],ans=0;
int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
i64 f(int x,int y){return ++x,++y,fac[x+y]*fiv[x]%P*fiv[y]%P;}
i64 cal(int xa,int ya,int xb,int yb){return (f(xa-x1,ya-y1)-f(xa-x1,ya-y2)-f(xa-x2,ya-y1)+f(xa-x2,ya-y2))*(f(x6-xb,y6-yb)-f(x5-xb,y6-yb)-f(x6-xb,y5-yb)+f(x5-xb,y5-yb))%P;}
int main(){
	for(int i=fac[0]=1;i<=M;++i)fac[i]=i*fac[i-1]%P;
	fiv[M]=pw(fac[M],P-2);
	for(int i=M;i;--i)fiv[i-1]=i*fiv[i]%P;
	scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x1,&x2,&x3,&x4,&x5,&x6,&y1,&y2,&y3,&y4,&y5,&y6);
	++x2,++y2,--x5,--y5;
	for(int i=x3;i<=x4;++i){
		ans-=cal(i,y3-1,i,y3)*(y3+i);
		ans+=cal(i,y4,i,y4+1)*(y4+i+1);
	}
	for(int i=y3;i<=y4;++i){
		ans-=cal(x3-1,i,x3,i)*(x3+i);
		ans+=cal(x4,i,x4+1,i)*(x4+i+1);
	}
	printf("%lld\n",(ans%P+P)%P);
	return 0;
}

Measured memory_bytes: 31360
#include <stdio.h>
#define N 101
int A[N][N];

int main(){
  int i,j,n,count,hen,where;

  scanf("%d",&n);
  for(i=0;i<=n;i++)
    for(j=0;j<n;j++)
      A[i][j] = 0;

  for(i=0;i<n;i++){
    scanf("%d %d",&count,&hen);
    while(hen>0){
      scanf("%d",&where);
      A[count-1][where-1] = 1;
      hen--;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",A[i][j]);
    }
    printf("%d\n",A[i][n-1]);
  }
  
  return 0;
}


Measured memory_bytes: 2048
from sys import stdin
import numpy as np

n, k = map(int, stdin.readline().rstrip().split(' '))
arg = np.array(list(map(int, stdin.readline().rstrip().split(' '))))
small = []
for i, val in enumerate(arg):
    small.append([np.count_nonzero(arg[:i] < val), np.count_nonzero(arg[i+1:] < val)])
smallnd = np.array(small)

a, b = np.sum(smallnd, axis=0)

res = k*(int(a)*(k-1)+int(b)*(k+1))//2

print(int(res % (10**9+7)))


Measured memory_bytes: 12500
from collections import deque
import sys
sys.setrecursionlimit(10**9)

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

    graph = [0] * (N+1)
    for i in range(N+1): #1-indexed
        f = i
        t = A[i-1]
        graph[f] = t


    def solve():
        visited_set = set([])
        visited = []
        stack = deque([1])
        x = 1
        count = 0
        while len(stack) > 0:
            x = stack.pop()
            if x in visited_set:
                break

            visited_set.add(x)
            visited.append(x)
            stack.append(graph[x])
            count += 1

            if count == K:
                print(stack.pop())
                exit()

        loop_head = x
        head_index = visited.index(loop_head)
        loop_len = len(visited) - head_index

        r = (K-head_index)%loop_len
        print(visited[head_index:][r])



    solve()


if __name__ == "__main__":
  main()

Measured memory_bytes: 117564
S = input()
N = len(S)
ans = 0

tmp = list(S)
for i in range(1, N):
    if tmp[i-1] == tmp[i]:
        if tmp[i] == '0':
            tmp[i] = '1'
        else:
            tmp[i] = '0'
        ans += 1

print(ans)


Measured memory_bytes: 3956
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a=0, b=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='0') a++;
    if(s[i]=='1') b++;
  }
  if(a>b) a = b;
  cout << a*2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

ll nCr(ll n, ll r){
  if(n == r) return 1;
  if(n-r < r) r = n-r;
  if(r == 0) return 0;
  if(r == 1) return n;
  ll res = 1;
  for(ll i = 1; i <= r; i++){
    res *= n--;
    res /= i;
  }
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  vector<ll> cnt(5, 0);
  REP(i, N){
    string S; cin >> S;
    if(S[0] == 'M') cnt[0]++;
    if(S[0] == 'A') cnt[1]++;
    if(S[0] == 'R') cnt[2]++;
    if(S[0] == 'C') cnt[3]++;
    if(S[0] == 'H') cnt[4]++;
  }
  ll res = 0;
  for(int i = 0; i < 3; i++){
    for(int j = i+1; j < 4; j++){
      for(int k = j+1; k < 5; k++){
        res += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy
from collections import deque
from functools import reduce
from decimal import Decimal


def main():
    n = int(input())
    s = []
    c = [0, 0, 0, 0]
    for _ in range(n):
        s.append(input())
    for result in s:
        if result == "AC":
            c[0] += 1
        if result == "WA":
            c[1] += 1
        if result == "TLE":
            c[2] += 1
        if result == "RE":
            c[3] += 1
    for i in range(4):
        if i == 0:
            print("AC x", c[0])
        if i == 1:
            print("WA x", c[1])
        if i == 2:
            print("TLE x", c[2])
        if i == 3:
            print("RE x", c[3])


if __name__ == '__main__':
    main()


Measured memory_bytes: 87924
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N,A; cin >> N >> A;
  cout << N*N-A << endl;
}


Measured memory_bytes: 256
//Print a Frame

#include <iostream>
#include <cassert>

int main()
{
  while (1) {
    int height, width;
    std::cin >> height >> width;

    assert(height >= 0 && height <= 300);
    assert(width >= 0 && width <= 300);
    if (!height && !width) break;

    for (int h = 0; h < height; ++h) {
      for (int w = 0; w < width; ++w) {
        if ((h == 0 || h == height - 1) || (w == 0 || w == width - 1))
          std::cout << '#';
        else
          std::cout << '.';
      }
      std::cout << std::endl;
    }
    std::cout << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void)
{
	int a,b,i;
	scanf("%d%d",&a,&b);
	for(i=0;i<2*a-1;i++){
		if(i<2*a-1)
			printf("%d ",b-a+1+i);
		else if(i==2*a-1)
			printf("%d ",b);
		else    printf("%d ",b-a+1+i);
		}
	return 0;
}


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

#define ll long long
#define INF 99999999
#define INF_LL 1LL << 60
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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; }

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    int A,B;
    cin >> A >> B;

    REP(i, 1, 4)
    {
        if( A*B*i%2 != 0 )
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())

im = [[0] * (N + 2) for _ in range(N + 2)]
for _ in range(M):
    l, r = map(int, input().split())
    im[1  ][r  ] += 1
    im[l+1][r  ] -= 1
    im[1  ][N+1] -= 1
    im[l+1][N+1] += 1

for i in range(1, N+1):
    for j in range(1, N+1):
        im[i][j+1] += im[i][j]
for j in range(1, N+1):
    for i in range(1, N+1):
        im[i+1][j] += im[i][j]
for _ in range(Q):
    p, q = map(int, input().split())
    print(im[p][q])

Measured memory_bytes: 9588
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;

} 

Measured memory_bytes: 3596
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var sum = 0; var pre = a[0];
        for (int i = 1; i < n; i++)
        {
            var kt = a[i] - pre;
            sum += Math.Min(w, kt);
            pre = a[i];
        }
        sum += w;
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 30304
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000
#define M 100000

int oo[1 + M * 2], oj[1 + M * 2];

int link(int o, int j) {
	static int _ = 1;

	oo[_] = o, oj[_] = j;
	return _++;
}

int ae[N], cc[N];
char visited[N];

void dfs(int i, int c) {
	int o;

	if (visited[i])
		return;
	visited[i] = 1;
	cc[i] = c;
	for (o = ae[i]; o; o = oo[o])
		dfs(oj[o], c);
}

int main() {
	static int ii[N + 1];
	int n, m, i, p, c, ans;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%d", &p);
		ii[p] = i;
	}
	while (m--) {
		int x, y;

		scanf("%d%d", &x, &y), x--, y--;
		ae[x] = link(ae[x], y);
		ae[y] = link(ae[y], x);
	}
	memset(cc, -1, n * sizeof *cc);
	c = 0;
	for (i = 0; i < n; i++)
		if (!visited[i])
			dfs(i, c++);
	ans = 0;
	for (p = 1; p <= n; p++)
		if (cc[ii[p]] == cc[p - 1])
			ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4992
N,K = map(int, input().split())
x = list(map(int, input().split()))
ans=min([min(abs(x[i])+abs(x[i]-x[i+K-1]),abs(x[i+K-1])+abs(x[i+K-1]-x[i])) for i in range(N-K+1)])
print(ans)

Measured memory_bytes: 14384
import java.util.*;

/**
 * A
 */
public class Main {

    Node root;

    public void run() {

        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        
        for(int i=0; i<m; i++) {
            String str = sc.next();
            Node ans;
            if(str.startsWith("i")) {
                insert(sc.nextInt());
            } else if(str.startsWith("f")) {
                ans = find(sc.nextInt());
                if(ans != null) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            } else {
                inorder(root);
                System.out.println();
                preorder(root);
                System.out.println();
            }
        }

        sc.close();

    }

    
    public void insert(int v) {
        
        Node x = root; // root
        Node y = null; // parent of x
        Node z = new Node(v); // it will be inserted
        
        while(x != null) {
            y = x;
            if(z.id < x.id) {
                x = x.left;
            } else {
                x = x.right;
            }
        }
        if(y == null) {
            root = z;
        } else if(z.id < y.id) {
            y.left = z;
        } else {
            y.right = z;
        }
        
    }
    
    public Node find(int v) {

        Node n = root;

        while (n != null && n.id != v) {
            if(n.id > v) {
                n = n.left;
            } else {
                n = n.right;
            }
        }

        return n;

    }

    public void inorder(Node tree) {
        
        if(tree == null) {
            return;
        }

        inorder(tree.left);
        System.out.print(" "+tree.id);
        inorder(tree.right);

    }

    public void preorder(Node tree) {

        if(tree == null) {
            return;
        }

        System.out.print(" "+tree.id);
        preorder(tree.left);
        preorder(tree.right);

    }

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

}

class Node {

    int id;
    Node left;
    Node right;

    Node(int id) {
        this.id = id;
    }

}


Measured memory_bytes: 202816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n, x;
    scanf("%d%d", &n, &x);
    int ans = 0;
    for (int i = n, t; i--;)
    {
        scanf("%d", &t);
        ans = __gcd(ans, abs(t - x));
    }
    printf("%d\n", ans);
}

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

int main() {
	int n;
	cin >> n;
	cout << pow(n, 3) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int i,h[10],n;
        for(i=0; i<10; i++)
        {
            scanf("%d", &n);
            h[i]=n;
        }
        sort(h,h+10);
        for(i=9; i>=7; i--)
        {
            printf("%d\n",h[i]);
        }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    string s;
    int cnt = 0;
    cin >> s;
    
    for(int i = 0;i < s.length()-1;i++){
        if(s[i] != s[i+1]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int> A(N+1,0),B(Q);
  rep(i,Q){
    cin>>B[i];
    A[B[i]]+=1;
  }
  for(int i=1;i<N+1;i++){
    int sum=0;
    sum=K-Q+A[i];
    if(sum<1)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int nums[11][11];
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				cin >> nums[i][j];

		for (int i = 0; i < n; ++i) {
			nums[i][n] = nums[n][i] = 0;
			for (int j = 0; j < n; ++j) {
				nums[i][n] += nums[i][j];
				nums[n][i] += nums[j][i];
			}
		}

		nums[n][n] = 0;
		for (int i = 0; i < n; ++i)
			nums[n][n] += nums[i][n];

		for (int i = 0; i <= n; ++i, cout << endl)
			for (int j = 0; j <= n; ++j)
				printf("%5d", nums[i][j]);
	}
}

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

int main(){
	/*input*/
	int n;	cin >> n;
	vector<int>a(n+1);
	vector<int>b(n);
	for(int i = 0; i < n+1; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	/*calculaiton*/
	vector<long int>tmp(n+1);
	for(int i = 0; i < n; i++){
		int sa = a[i] - tmp[i];
		if(b[i] >= sa){
			tmp[i] += sa;
			if((b[i] - sa) >= a[i + 1]){
				tmp[i + 1] = a[i + 1];
			}else{
				tmp[i + 1] = b[i] - sa;
			}
		}else{
			tmp[i] += b[i];
		}
	}
	long int ans = 0;
	for(int i = 0; i < n + 1; i++){
		ans += tmp[i];
	}
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long k = sc.nextLong();
		for(int i = 0; i < k; i++) {
			if(s.charAt(i) != '1') {
				System.out.println(s.charAt(i));
				return;
			}
		}
		System.out.println('1');
	}
}

Measured memory_bytes: 35824
#include "bits/stdc++.h"
using namespace std;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 2e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int N, M, K;
    cin >> N >> M >> K;
    rep(r, N + 1) {
        rep(c, M + 1) {
            if (r * M + c * N - 2 * r * c == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    static Scanner input = new Scanner(System.in);

    static public void solve() {
        int c1x = input.nextInt();
        int c1y = input.nextInt();
        int c1r = input.nextInt();
       
        int c2x = input.nextInt();
        int c2y = input.nextInt();
        int c2r = input.nextInt();

        input.close();

        double x = (double) c1x - c2x;
        double y = (double) c1y - c2y;
        double l12 = Math.sqrt(x * x + y * y);
        double plus = (double) c1r + c2r;
        double minus = (double) c1r - c2r;
        if (minus < 0) minus = - minus;

        if (l12 > plus) {
            System.out.println("4");
        }
        if (l12 == plus) {
            System.out.println("3");
        }
        if (l12 < plus && l12 > minus) {
            System.out.println("2");
        }
        if (l12 == minus) {
            System.out.println("1");
        }
        if (l12 < minus) {
            System.out.println("0");
        }
    }

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


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

struct City{
    int d,v;
    bool operator<(const City&right)const{return d>right.d;}
};
struct Edge{int to,len;};

int n,m,s,t,d1[100009],d2[100009],ans[100009];
vector<Edge> yen[100009],snuuk[100009];

signed main(){
    cin>>n>>m>>s>>t;
    rep(i,m){
        int u,v,a,b;
        cin>>u>>v>>a>>b;
        yen[u].push_back({v,a});
        yen[v].push_back({u,a});
        snuuk[u].push_back({v,b});
        snuuk[v].push_back({u,b});
    }
    rep(i,n+1)d1[i]=d2[i]=1e18;
    priority_queue<City> que;
    que.push({0,s});
    d1[s]=0;
    while(!que.empty()){
        City c=que.top();
        que.pop();
        if(d1[c.v]<c.d)continue;
        rep(i,yen[c.v].size()){
            if(d1[yen[c.v][i].to]>c.d+yen[c.v][i].len){
                d1[yen[c.v][i].to]=c.d+yen[c.v][i].len;
                que.push({d1[yen[c.v][i].to],yen[c.v][i].to});
            }
        }
    }
    que.push({0,t});
    d2[t]=0;
    while(!que.empty()){
        City c=que.top();
        que.pop();
        if(d2[c.v]<c.d)continue;
        rep(i,snuuk[c.v].size()){
            if(d2[snuuk[c.v][i].to]>c.d+snuuk[c.v][i].len){
                d2[snuuk[c.v][i].to]=c.d+snuuk[c.v][i].len;
                que.push({d2[snuuk[c.v][i].to],snuuk[c.v][i].to});
            }
        }
    }
    for(int i=n;i;i--)ans[i]=max(ans[i+1],(int)1e15-d1[i]-d2[i]);
    rep(i,n)cout<<ans[i+1]<<endl;
}

Measured memory_bytes: 19704
Q, H, S, D = map(int, input().split())
N = int(input())
x = min([4*Q, 2*H, S, D//2])
if x == (D//2):
  print((N//2)*D + (N%2)*min([4*Q, 2*H, S]))
else:
  print(N*x)

Measured memory_bytes: 3060
N,K = map(int,input().split())
H = list(map(int,input().split()))

dp = [0]*N
dp[1]= abs(H[1]-H[0])
#dp[i] インデックスiにいるときの最小値
inf = float("inf")

for i in range(1,N-1):
    tmp = inf
    oppai = min(K,i+1)
    for jump in range(1,oppai+1):
        tmp = min(tmp,dp[i+1-jump]+abs(H[i+1]-H[i+1-jump]))
    dp[i+1]=tmp
print(dp[N-1])
  

Measured memory_bytes: 52448
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
void solve(){
  	string s;
  	cin >> s;
  	int ret = 0;
  	for (auto it : s){
	  if ( it == '+') ret++;
	  else ret--;	
	}
	cout << ret << endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


Measured memory_bytes: 256
a, b = list(map(int, input().split()))

# cumlative_xor(a) を 0　から a までのxorの結果とする。
# 求める答えは、cumlative_xor(b) xor cumlative_xor(a-1) （累積XOR）

def cumlative_xor(a):
	ans = 0
	if a % 4 == 1 or a % 4 == 2 :
		ans = 1

	for i in range(1, 41):
		temp = 2 ** i
		if a & 1 == 0 and a & temp > 0:
			ans = ans | temp

	return ans

print(cumlative_xor(b) ^ cumlative_xor(a-1))


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int h,m,s;
	int time;
	int nokori,nokori3;
	while (1) {
		cin >> h >> m >> s;
		if (h == -1 && m == -1 && s == -1) {
			break;
		}
		time = 3600 * h + 60 * m + s;
		nokori = 7200 - time;
		nokori3 = nokori * 3;
		printf("%02d:",nokori/3600);
		nokori %= 3600;
		printf("%02d:",nokori/60);
		nokori %= 60;
		printf("%02d\n",nokori);
		printf("%02d:",nokori3/3600);
		nokori3 %= 3600;
		printf("%02d:",nokori3/60);
		nokori3 %= 60;
		printf("%02d\n",nokori3);
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if((a-b<=d && b-c<=d && a-b>=-d && b-c>=-d) || (a-c<=d && a-c>=-d))
    printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 1664
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n;
    cin>>n;
    ll ans=11;
    for(ll i=1;i<=sqrt(n)+1;i++){
        if(n%i==0){
            ll ans1;
            ll ans2;
            for(int j=0;j<10;j++){
                if(pow(10,j)<=i && i<pow(10,(j+1))){
                    ans1=j+1;
                    break;
                }

            }
            for(int j=0;j<10;j++){
                if(pow(10,j)<=n/i && n/i<pow(10,(j+1))){
                    ans2=j+1;
                    break;
                }
                if(n/i==1e10) {
                    ans2=11;
                    break;
            }
            }
           //cout<<ans2<<endl;
            ans=min(ans,max(ans1,ans2));
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
d = {0: [], 1:[]}
letters = 'abcdefghijklmnopqrstuvwxyz'
for i in letters:
    d[0].append(i)

curs = ''
ans = []
next = s[0]
c = []
f = False

for i in s:
    curs += i
    d[1].append(d[0].pop(d[0].index(i)))

if len(s) < 26:
    ans = curs + d[0][0]
else:
    while ans == []:
        if s:
            c.append(s[-1])
            s2 = s[:-1]
            c.sort()
            for j in c:
                if s2 + j > s:
                    ans = s2 + j
                    break
            s = s[:-1]
        else:
            ans = -1


print(ans)

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL N, K; cin >> N >> K;
  LL ans = 0, A = (5*K+3)%11;
  for(LL i=1;i<=5;++i){
	LL x;
	for(x=0;x<100;++x)
	  if(x%11 == A && x%7 == i) break;
	while(x<=7*(N-2)){
	  ++ans;
	  x += 77;
	}
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <string>
#include <map>
#include <list>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007

int main(){
    ull X, x = 100, year = 0;
    cin >> X;
    while (x < X){
        x = x * 1.01;
        year++;
    }
    cout << year << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void) {
  int d, n;

  cin >> d;
  cin >> n;

  int ans;
  if (n == 100) ans = 101;
  else ans = n;

  for (int i = 0; i < d; i++) ans *= 100;

  cout << ans << endl;

}


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

int main() {
   int y, m, d;
   
   char c1, c2;
   cin >> y >> c1 >> m >> c2 >> d;
   cout << (m <= 4 ? "Heisei" : "TBD");
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,k;
  cin>>a>>b>>k;
  rep(i,k){
    if(i%2==0){
      if(a%2==1) a--;
      a/=2;
      b+=a;
    }else{
      if(b%2==1) b--;
      b/=2;
      a+=b;
    }
  }
  cout<<a<<" "<<b<<endl;
      

  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}



public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		String S = fs.next();

		if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,bool>
#define mp make_pair

using namespace std;

const int roz = (1<<19);

int tree[roz][2];

int ask(int lo,int hi,int u,int a,int b,int idx)
{
    if(lo == a && b == hi) return tree[u][idx];
    if(b<=a) return 1e9;
    int mid =(lo+hi)/2;
    int l = ask(lo,mid,u*2,a,min(b,mid),idx);
    int r = ask(mid,hi,u*2+1,max(a,mid),b,idx);
    return min(l,r);
}

void wst(int pos,int val,int idx)
{
    pos += roz/2;
    tree[pos][idx] = val;
    pos /= 2;
    while(pos >= 1)
    {
        tree[pos][idx] = min(tree[pos*2][idx],tree[pos*2+1][idx]);
        pos /= 2;
    }
    return;
}

ll n,q;
const int nax = 2e5 + 5;


int minp[nax][2];


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

    ll ans = 0;
    cin>>n>>q;
    for(int i=0;i<roz/2;i++)
    {
        wst(i,1e9,0);
        wst(i,1e9,1);
    }
    minp[0][0] = minp[0][1] = 1e9;
    for(int i=1;i<=q;i++)
    {
        int tp,x;
        cin>>tp>>x;
        if(tp == 1)
        {
            int tm = ask(0,roz/2,1,2,x,0);

            tm--;
            tm = min(tm,i-1);
            int v = minp[tm][1];
            v = min(v,(int)n);
            ans += (v - 2);
            minp[i][1] = minp[i-1][1];
            minp[i][0] = min(minp[i-1][0],x);

            wst(x,i,0);

        }
        else if(tp == 2)
        {
            int tm = ask(0,roz/2,1,2,x,1);

            tm--;
            tm = min(tm,i-1);
            int v = minp[tm][0];
            v = min(v,(int)n);
            ans += (v - 2);

            minp[i][0] = minp[i-1][0];
            minp[i][1] = min(minp[i-1][1],x);

            wst(x,i,1);

        }
    }

    cout<<(n-2) * (n-2) - ans;


    return 0;
}


Measured memory_bytes: 9300
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n, m;
    cin >> n >> m;
    string a[n], b[m];
    rep(i, n)cin >> a[i];
    rep(i, m)cin >> b[i];
    bool flag = false;
    rep(i, n)if(i+m <= n)rep(j, n)if(j+m <= n)if(a[i][j] == b[0][0]){
        int cnt = 0;
        rep(k, m)rep(l, m)if(b[k][l]==a[i+k][j+l])cnt++;
        if(cnt >= m*m)flag=true;
    }
    if(!flag)cout << "No";
    else cout << "Yes";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();

		int[] nHeightArray = new int[n];

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

			nHeightArray[i] = scan.nextInt();
		}

		Map<Integer, List<Integer>> mLoadMap = new HashMap<>();

		for (int i = 0; i < m; i++) {

			int a = scan.nextInt();
			int b = scan.nextInt();

			if (mLoadMap.containsKey(a)) {

				mLoadMap.get(a).add(b);

			} else {

				List<Integer> bList = new ArrayList<>();
				bList.add(b);
				mLoadMap.put(a, bList);
			}
			
			if (mLoadMap.containsKey(b)) {

				mLoadMap.get(b).add(a);

			} else {

				List<Integer> bList = new ArrayList<>();
				bList.add(a);
				mLoadMap.put(b, bList);
			}
		}

		int count = 0;

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

			if (mLoadMap.containsKey(i)) {

				int ownHeight = nHeightArray[i - 1];

				boolean highest = true;

				for (int b : mLoadMap.get(i)) {

					if (ownHeight <= nHeightArray[b - 1]) {

						highest = false;
					}
				}

				if (highest) {
					count++;
				}
			} else {

				count++;
			}
		}

		println(count);
	}

	public static void println(Object target) {
		System.out.println(target);
	}
}


Measured memory_bytes: 67148
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
A, B, C = map(int, input().split())
# 文字列の入力
#s = input()
#print(s[0:K-1]+s[K-1].lower()+s[K:N])
if A*B*C == 5*5*7:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int n, m, i, ans;
int main() {
	cin >> n >> m;
	if (n == 1) {
		cout << m << endl;
		return 0;
	}
	for (int i = 1; i <= m&&i <= m / n; ++i) {
		if (m%i == 0)ans = i;
	}
	cout << ans << endl;
	return 0;
}


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

int a[50][6];
int main(){
	vector<int>v[3];
	int n;scanf("%d",&n);
	rep(i,n)rep(j,6){
		int c,d;scanf("%d%d",&c,&d);
		a[i][j]=c*60+d;
		v[j/2].push_back(a[i][j]);
	}
	rep(i,3)sort(v[i].begin(),v[i].end());
	int Max=0;
	rep(i,v[0].size())rep(j,v[1].size())rep(k,v[2].size()){
		int b[]{v[0][i],v[1][j],v[2][k]};
		int cnt=0;
		rep(t,n){
			bool flag=true;
			rep(l,3){
				if(!(a[t][l*2]<=b[l]&&b[l]<=a[t][l*2+1]))flag=false;
			}
			cnt+=flag;
		}
		Max=max(Max,cnt);
	}
	cout<<Max<<endl;
}

Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main() {
	long long int n, a, b, ans;
	cin >> n >> a >> b;
	long long int x = n % (a + b);
	long long int y = (n - x) / (a + b);
	if (x > a)x = a;
	ans = a * y + x;
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		// 文字列の入力
		String s = sc.next();
		String[] S = s.split("");

		switch(S[k-1]){
			case "A":
				S[k-1]="a";
				break;
			case "B":
				S[k-1]="b";
				break;
			case "C":
				S[k-1]="c";
				break;
		}

		String ans = "";

		for(String str:S)ans+=str;

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;

	if ( n % 1000 == 0 )
	{
		cout << 0 << endl;
	}
	else {
		int r = n / 1000;
		cout << ( ( r + 1 ) * 1000 ) - n << endl;
	}




}

Measured memory_bytes: 3636
// A - Triangle

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll MAX = 1e9;

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

	ll x = S % MAX == 0 ? 0 : MAX - (S % MAX);
	ll y = (S + x) / MAX;

	cout << 0 << " " << 0 << " " << MAX << " " << 1 << " " << x << " " << y << endl;

	//cout << "S = " << MAX * y - 1 * x << endl; // **** debug ****

	return 0;
}

Measured memory_bytes: 3604
/* ex3_4
    sak_Citrus*/

#include <stdio.h>

int main(void){
    //標準入力
    int n;
    scanf("%d",&n);
    for(int i=1;i<10;i++){
        //nがiで割り切れてなおかつその商が10未満なら
        if(n%i == 0 && n/i < 10){
            printf("Yes\n");
            break;
        }
        //最後までbreakされなかったら九九にはない
        if(i == 9)
            printf("No\n");
    }
  	return 0;

}

Measured memory_bytes: 128