akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

struct query{
	int vert;
	int dist;
	int col;
};

vector<int> graph[100010];
vector<query> ql;
// farbe[v] := 頂点 v は何色か？（初期値 0）
int farbe[100010];
// dmax[v] := 頂点 v から距離いくつまでのノードが塗られているか？
int dmax[100010];

void init(){
	for( int i = 0; i < 100010; ++i ) dmax[i] = -1;
}

void dfs( int v, int d, int c ){
	if( d < 0 || dmax[v] >= d ) return;
	dmax[v] = d;
	if( farbe[v] == 0 ) farbe[v] = c;
	for( auto next : graph[v] ){
		dfs( next, d-1, c );
	} 
}

int main(){
	init();
	int n, m; cin >> n >> m;
	for( int i = 0; i < m; ++i ){
		int a, b; cin >> a >> b; --a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	int qnum; cin >> qnum;
	for( int i = 0; i < qnum; ++i ){
		int vt, dt, ct; cin >> vt >> dt >> ct; --vt;
		ql.push_back((query){vt, dt, ct});
	}
	reverse( ql.begin(), ql.end() );
	for( int i = 0; i < qnum; ++i ){
		dfs( ql[i].vert, ql[i].dist, ql[i].col );
	}
	for( int i = 0; i < n; ++i ){
		cout << farbe[i] << endl;
	}
}

Measured memory_bytes: 8816
#include<bits/stdc++.h>
#define mx 100005
using namespace std;

int n, h[mx], mincost[mx];
long long l;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &h[i]);
		if(i == 0) continue;
		else if(i == 1) mincost[i] = abs(h[i] - h[i-1]);
		else mincost[i] = min(mincost[i-2] + abs(h[i] - h[i-2]), mincost[i-1] + abs(h[i] - h[i-1]));
	}
	printf("%d\n", mincost[n-1]);
}

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

using namespace std;

int main() {
    long long a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (v <= w) {
        cout << "NO\n";
    } else if (abs(a - b) > (v - w) * t) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int main() {
  ll n;
  cin >> n;
  vector<ll> h(n), dp(n + 5, INF);
  REP(i, n) cin >> h[i];
  dp[0] = 0;
  REP(i, n - 1) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1920
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m,k=map(int,input().split())
uf = UnionFind(n)
friend=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friend[a]+=1
    friend[b]+=1
    uf.union(a,b)

block=[0]*n
for i in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    if uf.same(c,d):
        block[c]+=1
        block[d]+=1

ans=[0]*n
for i in range(n):
    ans[i]=uf.size(i)-friend[i]-block[i]-1

print(*ans)

Measured memory_bytes: 14904
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim],D[lim];
lld Arr[lim];
lld ans = 0;
lld n, m, q;

void findAns(int ind, int val) {
    if(ind == n + 1) {
        lld curr = 0;
        rep(i,1,q) {
            if(Arr[B[i]] - Arr[A[i]] == C[i]) curr += D[i];
        }
        // Error(curr);
        ans = max(ans, curr);
        return ;
    }
    rep(i,val,m) {
        Arr[ind] = i;
        findAns(ind + 1, i);
    }
}


int main(){
    n = sc(), m = sc(), q = sc();
    rep(i,1,q) A[i] = sc(), B[i] = sc(), C[i] = sc(), D[i] = sc();
    findAns(1, 1);
    prL(ans);
    return 0;
}


Measured memory_bytes: 3848
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			String x = String.valueOf(i);
			if (i % 3 == 0 || x.indexOf("3") != -1){
				System.out.print(" " + i);
			}
		}
		System.out.println("");
	}

}

Measured memory_bytes: 29936
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;
 
const int N=100005;
 
int n,os,js;
bool tag;
int a[N];

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

int dfs(int b){
	int i,g=0;
	js=os=0; tag=0;
	for (i=1;i<=n;i++){
		if (a[i]&1) a[i]--;
		g=gcd(g,a[i]);
	}
	for (i=1;i<=n;i++){
		a[i]/=g;
		if (a[i]&1){
			js++;
			if (a[i]==1) tag=1;
		}
		else os++;
	}
	if (os&1) return (!b);
	if (tag||js>1) return b;
	return dfs(b^1);
}
 
int main(){
	int i;
	scanf("%d",&n);
	tag=0;
	for (i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (a[i]&1){
			js++;
			if (a[i]==1) tag=1;
		}
		else os++;
	}
	if (os&1) printf("First\n");
	else{
		if (tag||js>1){
			printf("Second\n");
			return 0;
		}
		if (dfs(1)) printf("First\n");
		else printf("Second\n");
	}
	return 0;
}

Measured memory_bytes: 640
a = input().split()
a = [int(i) for i in a]
a = sorted(a)
if a[0] + 2019 <= a[1]:
    print(0)
else:
    b_1 = [i for i in range(a[0], a[1] + 1)]
    c = [i % 2019 for i in b_1]
    c = sorted(c)
    epoc = 2019
    for i in range(len(c)):
        for u in range(i):
            epoc1 = (c[i] * c[u]) % 2019
            if epoc1 < epoc:
                epoc = epoc1

    print(epoc)
    

Measured memory_bytes: 3188
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/23
Solved on 2019/3/
@author: shinjisu
"""


# ABC 068 C - Cat Snuke and a Voyage
import bisect
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, M = getIntList()
    d.dmp((N, M), 'N, M')
    ship = set()
    for i in range(M):
        a, b = getIntList()
        ship.add((a, b))
    d.dmp((ship), 'ship')
    for i in range(2, N):
        if ((1, i) in ship or (i, 1) in ship) and\
             ((i, N) in ship or (N, 1) in ship):
            return 'POSSIBLE'
    return 'IMPOSSIBLE'


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)


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

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

constexpr int dx[]={1,0,-1,0};
constexpr int dy[]={0,1,0,-1};
constexpr int ddx[] = {1,1,-1,-1,2,2,2,2,2,-2,-2,-2,-2,-2,1,0,-1,1,0,-1};
constexpr int ddy[] = {1,-1,1,-1,0,1,2,-1,-2,2,1,0,-1,-2,2,2,2,-2,-2,-2};
constexpr int INF = 1<<28;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H,W,C_h,C_w,D_h,D_w;

  cin>>H>>W>>C_h>>C_w>>D_h>>D_w;
  C_h--,C_w--,D_h--,D_w--;
  vector<string> S(H);
  rep(i,H)cin>>S[i];

  vector dist(H,vector(W,INF));
  dist[C_h][C_w] = 0;
  deque<pair<int,int>> deq;
  deq.emplace_front(C_h,C_w);
  while(!deq.empty()){
    auto [y,x] = deq.front();
    deq.pop_front();
    rep(i,4){
      int ny = y+dy[i];
      int nx = x+dx[i];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]){
        dist[ny][nx] = dist[y][x];
        deq.emplace_front(ny,nx);
      }
    }
    rep(j,20){
      int ny = y+ddy[j];
      int nx = x+ddx[j];
      if(ny<0||nx<0||ny>=H||nx>=W)continue;
      if(S[ny][nx]=='#')continue;
      if(dist[ny][nx]>dist[y][x]+1){
        dist[ny][nx] = dist[y][x]+1;
        deq.emplace_back(ny,nx);
      }
    }
  }
  int ans = dist[D_h][D_w];
  cout<<(ans==INF?-1:ans)<<endl;
}


Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,a;
    cin >> n >> a;
    print(n*n-a);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3636
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for j in range(M):
    b.append(b[j] + B[j])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Measured memory_bytes: 47480
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;int l;
  cin>>l;
  cin>>s>>t;
  char a[2*l];
  for(int i=0;i<l;i++)
    a[2*i]=s[i];
  for(int i=0;i<l;i++)
    a[2*i+1]=t[i];
 for(int i=0;i<2*l;i++)
 cout<<a[i];
  return 0;
}


Measured memory_bytes: 256
/*input
5 3 100
*/
#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;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, s; cin >> n >> k >> s;
    for(int i = 0; i < k; i++) cout << s << ' ';
    if(s != 1000000000) for(int i = k; i < n; i++) cout << 1000000000 << ' ';
	else for(int i = k; i < n; i++) cout << 1 << ' ';

    return 0;
}

Measured memory_bytes: 1280
// This template belongs to Juan Carlo Vieri

/*   ____   __
    /  _/  |  |    __         __
 __|  |__  |  |   /_/        |  |
|__    __| |  |   __    ____ |  | __   ___   _  ___
   |  |    |  |  |  |  /  _/ |  |/ /  / _ \ | |/ _/
   |  |    |  |  |  | |  |_  |     \ |  __/ |   /
   |__|    |__|  |__|  \___\ |__|\__\ \___\ |__|
*/

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

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast64_t intt;
typedef int_fast64_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

class pointHash {
 public:
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void sub() {

}

void solve() {
  // intt t; cin >> t;
  // while (t--) sub();
  intt n;
  cin >> n;
  intt ans = 1;
  vc<intt> arr(n);
  rep(i, 0, n){
    cin >> arr[i];
    if(arr[i] == 0){
      cout << 0 << endl;
      return;
    }
  }
  rep(i, 0, n){
    if(ans > 1000000000000000000 / arr[i]){
      cout << -1 << endl;
      return;
    }
    ans *= arr[i];
  }
 cout << ans << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


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

int main(void){
    int x, y;
    cin >> x >> y;
    if(x==1 || x==3 || x==5 || x==7 || x==8 || x==10 || x==12){
        if(y==1 || y==3 || y==5 || y==7 || y==8 || y==10 || y==12){
            printf("Yes\n");
            return 0;
        }
    }
    if(x==4 || x==6 || x==9 || x==11){
        if(y==4 || y==6 || y==9 || y==11){
            printf("Yes\n");
            return 0;
        }
    }
    if(x==2){
        if(y==2){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int a = sc.nextInt();
      int b = sc.nextInt();

      for(int i = a; i <= b; i++) {
        if(i % k == 0) {
          System.out.println("OK");
          return;
        }

      }
        System.out.println("NG");
  }
}

Measured memory_bytes: 27016
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int L,R;
	cin >> L >> R;
	if(R - L + 1 >= 2019) {
		cout << 0 << endl;
	}
	else {
		if(R / 2019 - (L - 1) / 2019 != 0) {
			cout << 0 << endl;
		}
		else {
			int count = 1e10;
			for(int i = L;i <= R - 1;i++) {
				for(int j = L + 1;j <= R;j++) {
					count = min(count,( i % 2019 ) * ( j % 2019 ) % 2019);
				}
			}
			cout << count << endl;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;
int main()
{
	string a,b;
	int c=0,d=0,n;//c??????a???d??????b
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		if(a>b)//????????¬????°±??????????????????
			c=c+3;
		if(a==b)
			{
				c++;
				d++;}
		if(a<b)
			d=d+3;
	}
	cout<<c<<" "<<d<<endl;
}
	

Measured memory_bytes: 3168
#include<stdio.h>
#include<stdlib.h> 
#include<string.h>
#define NIL NULL
 
struct node{
  int key;
  struct node *left;
  struct node *right;
  struct node *p;
};
 
typedef struct node * Node;
 
Node root;

/*宣言*/
void Inorder_tree_walk(Node);
void Preorder_tree_walk(Node);
void insert(int);


/*main関数*/
int main(){
  int i,x,num;
  char s[10];

  scanf("%d",&num);
  for (i=0; i<num; i++){
    scanf("%s",s);

    if (strcmp("insert",s)==0){
      scanf("%d",&x);
      insert(x);
    }


    else if (strcmp("print",s)== 0){
      Inorder_tree_walk(root);
      puts("");

      Preorder_tree_walk(root);
      puts("");
    }
  }
  return 0;
}




/*先行順巡回*/
void Preorder_tree_walk(Node tree){
  printf(" %d",tree->key);
  if(tree != NIL){
    if((tree->left) != NIL)Preorder_tree_walk(tree->left);
    if((tree->right) != NIL)Preorder_tree_walk(tree->right);
  }
}
 

/*中間順巡回*/
void Inorder_tree_walk(Node tree){
   
  if(tree != NIL){

    if((tree->left) != NIL){Inorder_tree_walk(tree -> left);}

    printf(" %d",tree->key);
     
    if(tree->right!=NIL){Inorder_tree_walk(tree->right);}
  }
}


/*挿入*/
void insert(int k){
 Node y=NIL;
 Node x=root;
 Node z;

 /*新しいkeyの初期化*/
    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->p=y;

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

Measured memory_bytes: 24048
#include <iostream>
using namespace std;
int main(){
	int i=0,j=0,w,h;
	while(true){
	cin >> w >> h;
	if(h==0&&w==0) break;
	for(i=0;i<w;i++){
		for(j=0;j<h;j++){
            if((i+j)%2==0){
                cout << "#";
            }else{
                cout << ".";
            }
		}
		cout << endl;
	}
	cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
import java.util.*;

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

        int[] ss = new int[26];
        int[] tt = new int[26];

        Arrays.fill(ss, 0);
        Arrays.fill(tt, 0);
        for(int i = 0; i < s.length(); i++){
            ss[s.charAt(i) - 'a'] ++;
            tt[t.charAt(i) - 'a'] ++;
        }
        Arrays.sort(ss);
        Arrays.sort(tt);

        String ans = "Yes";
        for(int i = 0; i < 26; i++){
            if(ss[i] != tt[i]) ans = "No";
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 27404
r, c = map(int, input().split())
a = [[0] * c for i in range(r + 1)]
for i in range(r):
	a[i] = list(map(int, input().split()))
for j in range(c):
	for i in range(r):
		a[r][j] += a[i][j]
for i in range(r + 1):
	m = 0
	for j in range(c):
		m += a[i][j]
		print(a[i][j], end=" ")
	print(m)



Measured memory_bytes: 6220
#include<iostream>
#include <string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a%2 == 1 && b%2 == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
import math

n,d = map(int,input().split())
x = [[int(i) for i in input().split()] for i in range(n)] 
seq = list(itertools.combinations(range(n),2))
tmp = 0.0
cnt = 0
for i,j in seq:
    for k in range(d):
        tmp += (x[i][k] - x[j][k])**2
    tmp = math.sqrt(tmp)
    if tmp.is_integer():
        cnt += 1
    tmp = 0.0
print(cnt)

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

typedef long long ll;
typedef double dd;

typedef vector<int> vi;
typedef pair<int,int> pii;

const int mx=1e6+11;
const long double PI=3.14159265358979;

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define sqr(a) ((a) * (a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(ll i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()

#define yes cout<<"YES"<<nl;
#define no cout<<"NO"<<nl;

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
   su;
   char a;
   cin>>a;
   if(isupper(a))
   {
      cout<<'A';
   }
   else
      cout<<'a';
   cout<<nl;
   return 0;
}


Measured memory_bytes: 3580
///   BISMILLAHIR RAHMANIR RAHEEM
///   ALLAH IS WATCHING ME
///   ALLAH save us from COVID-19.Amin.

///   █▀█─█──█──█▀█─█─█
///   █▄█─█──█──█▄█─█▄█
///   █─█─█▄─█▄─█─█─█─█

///   كُلُّ نَفْسٍ ذَآئِقَةُ الْمَوْت
///   Every soul shall taste death.

/// TODO::

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

///  order_of_key return number of elements less than x.
///  find_by_order return index.

using namespace std;
using namespace __gnu_pbds;


#define MOHAMMAD  ios::sync_with_stdio(0);cin.tie(0);
#define all(x)    (x).begin(), (x).end()
#define AE        cout << fixed << setprecision(10);

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

typedef tree< int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

//debug
template<typename F,typename S>ostream&operator<<(ostream&os,const pair<F,S>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&v){os<<"{";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"}";}
template<typename T>ostream&operator<<(ostream&os,const set<T>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<",";os<<*it;}return os<<"]";}
template<typename T>ostream&operator<<(ostream&os,const multiset<T>&v) {os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<*it;}return os<<"]";}
template<typename F,typename S>ostream&operator<<(ostream&os,const map<F,S>&v){os<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())os<<", ";os<<it->first<<" = "<<it->second;}return os<<"]";}
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu(){cerr << endl;}
template<typename T>void faltu(T a[],int n){for(int i=0;i<n;++i)cerr<<a[i]<<' ';cerr<<endl;}
template<typename T,typename...hello>void faltu(T arg,const hello&...rest){cerr<<arg<<' ';faltu(rest...);}
//#else
//#define dbg(args...)
//***********************************************  The END **********************************************************************************************************************************
using ll = long long;

int main()
{

  /// MOHAMMAD
 ll n;
 cin >> n;
 cout << n + (n*n) + ( n*n*n);



}

/*





  Alhamdulillah
*/



Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main(){
    char x[4],y[4];
    scanf("%s %s",x,y);
    if(x[0]==y[2] && x[1]==y[1] &&x[2]==y[0]){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = [];
  $b = [];
  for($i=0;$i<$n;$i++){
    list($a[], $b[]) = explode(" ", trim(fgets(STDIN)));
  }

  sort($a);
  sort($b);

  if($n % 2 == 1){
    $min = $a[($n+1)/2-1];
    $max = $b[($n+1)/2-1];
  }else{
    $min = $a[$n/2]+$a[$n/2-1];
    $max = $b[$n/2]+$b[$n/2-1];
  }
  echo $max - $min + 1;


Measured memory_bytes: 44176
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int ans = 999;
        for (int i = 0; i < S.length() - 2; i++) {
            String sub = S.substring(i, i + 3);
            int n = Integer.parseInt(sub);
            ans = Math.min(ans, Math.abs(n - 753));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
import java.math.BigInteger;
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                if (j * a[i] + 1 <= d) {
                    sum++;
                } else {
                    break;
                }
            }
        }
        System.out.println(sum + x);
    }

}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <numeric>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<double> xarray, yarray;
  vector<int> set(N);
  double perm = 1.0;
  for(int i=1;i<=N;i++) perm *= i;
  std::iota(set.begin(), set.end(), 1);
  
  for(int i=0;i<N;i++){
    int x_, y_;
    cin >> x_ >> y_;
    xarray.push_back(x_);
    yarray.push_back(y_);
  }
  
  int prev_i;
  vector<double> dists;
  double average = 0;
  
  do{
    double dist = 0;
    prev_i = set[0];
    //cout << prev_i << endl;
    for(auto i : set){
      //cout << i << " "; //cout << "\n";
      //cout << xarray[i] << " " << xarray[prev_i] << endl;
      dist += std::sqrt(pow(xarray[i-1]-xarray[prev_i-1],2) + pow(yarray[i-1]-yarray[prev_i-1],2));
      prev_i = i;
    }
    dists.push_back(dist);
    average += dist/perm;
    //cout << endl;
  }  while( next_permutation(set.begin(), set.end()) );
  
  cout << setprecision(11) << average << endl;
  return 0;
}

Measured memory_bytes: 892
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
string s, t;
vector<vector<int>> dp;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s >> t;
    dp.assign(sz(s) + 1, vector<int> (sz(t) + 1, 0));
    FOR(i, 1, sz(s) + 1)
    {
        FOR(j, 1, sz(t) + 1)
        {
            if(s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); 
        }
    }
    string res = "";
    int x = sz(s), y = sz(t);
    while(x >= 1 && y >= 1 && dp[x][y] != 0)
    {
        if(s[x - 1] == t[y - 1]) 
        {
            res += s[x - 1];
            x--; y--;
        }
        else
        {
            if(dp[x][y - 1] > dp[x - 1][y]) y--;
            else x--;
        }
    }
    reverse(res.begin(), res.end());
    cout << res;
    return 0;
}

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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');

            int n, m;
            n = int.Parse(s[0]);
            m = int.Parse(s[1]);
                
            if((n + m )== 15)
            {
                Console.WriteLine("+");
            }
            else if((n * m) == 15)
            {
                Console.WriteLine("*");
            }
            else
            {
                Console.WriteLine("x");
            }

        }
    }
}

Measured memory_bytes: 11092
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        a: [isize; n],
    }
    let mut x = 0;
    for i in 0..n {
        if i % 2 == 0 {
            x += a[i];
        } else {
            x -= a[i];
        }
    }
    println!("{}", x);
    for i in 1..n {
        x = 2 * a[i - 1] - x;
        println!("{}", x);
    }
}


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

int main(){
	int n,k;
	long long h[100005],dp[100005];
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
		for(int j=2;j<=k && i-j>=0;j++)
			dp[i]=min(dp[i],(long long)(dp[i-j]+abs(h[i-j]-h[i])));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1792
M=10**9+7
n,k,*a=map(int,open(y:=0).read().split())
a.sort()
x=s=1
a=a[-k*(a[-1]<0<k%2):]
while x+y<k:
 if(t:=a[y]*a[y+1])>a[-x]*a[~x]:s=s*t%M;y+=2
 else:s=s*a[-x]%M;x+=1
print(s*(x+y-k or a[-x])%M)

Measured memory_bytes: 31756
//Coded by tzc_wk
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
忘文件操作，爆零两行泪。
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
map<string,bool> mp;
int n=read();
signed main(){
	int ans=0;
	while(n--){
		string s;cin>>s;
		if(!mp[s])	ans++;
		mp[s]=1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19272
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val l = (0 until n).map { sc.next().toInt() }
    println(problem143d(n, l))
}

fun problem143d(n: Int, l: List<Int>): Int {
    val l = l.sorted().toIntArray()
    var count = 0
    for (i in 0 until n) {
        val a = l[i]
        for (j in i + 1 until n) {
            val b = l[j]
            for (k in j + 1 until n) {
                val c = l[k]
                if (a < b + c && b < c + a && c < a + b) {
                    count++
                } else {
                    break
                }
            }
        }
    }
    return count
}

Measured memory_bytes: 51592
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int h,n,x,sum=0;
    cin>>h>>n;
    f(i,1,n)
    {
        cin>>x;
        sum+=x;
    }
    if(sum>=h)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }

















    return 0;

}













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

int main(void) {
  int N, T;
	cin >> N >> T;
  int t[N];
  REP(i,N) cin >> t[i];
  int sum, term;
  sum = T * N;
  REP(i,N-1) {
    term = t[i+1] - t[i] - T;
    if (term < 0) sum += term;
  }
  cout << sum << '\n';
}


Measured memory_bytes: 1024
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}


int main() {
    int i,j;
    int n;
    int limit = 1;
    scanf("%d", &n);

    while(limit <= n){
        limit *= 2;
    }

    printf("%d", limit/2);

    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int64_t k;
  cin >> k;
  
  // 行先表
  vector<int> a(n);
  for (int i = 0; i < n; i ++)
  {
    cin >> a[i];
    a[i]--;
  }

  // 訪問済みフラグ兼訪問時のワープ済み回数記録(-1:未訪問)
  vector<int> visited(n, -1);

  // 現在位置とワープ済み回数
  int pos = 0;
  int turn = 0;

  vector<int> history;
  while(visited.at(pos) == -1)
  {
    history.push_back(pos + 1);
    visited.at(pos) = turn ++;
    pos = a.at(pos);
  }

  if (k < history.size())
    cout << history[k] << endl;
  else
  {
    int64_t loop_start = visited.at(pos);
    k -= loop_start;
    int64_t loop_length = turn - loop_start;
    k %= loop_length;
    cout << history[k + loop_start] << endl;
  }
 
  return 0;
}

Measured memory_bytes: 5816
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N = sc.nextInt();
	static int[] A_i = new int[N];
	static int M = sc.nextInt();
	public static void main(String[] args) {
		inputBibs();
		swappingBibs();

		for (int i = 0; i < N; i++) {
			System.out.println(A_i[i]);
		}

	}

	private static void inputBibs() {
		for (int i = 0; i < N; i++) {
			A_i[i] = sc.nextInt();
		}
	}

	private static void swappingBibs() {
		for (int k = 2; k <= M; k++) {
			for (int i = 0; i < N - 1; i++) {
				if (A_i[i] % k > A_i[i + 1] % k) {
					int tmp;
					tmp = A_i[i];
					A_i[i] = A_i[ i + 1];
					A_i[i+ 1 ] = tmp;
				}
			}
		}

	}

}



Measured memory_bytes: 26276
class in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const my_iterator& begin(){return i;}const my_iterator& end(){return n;}};

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

using i64 = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<i64> a(n);
    for(auto& x : a) cin >> x;

    i64 ans = 0LL;
    i64 mi = 1LL;//maxをとる
    for(int i : in(n)) {
        i64 x = a[i];
        if(mi > x) continue;
        if(mi == x) {
            ++mi;
            continue;
        }
        i64 plus = (x - 1) / mi;
        ans += plus;
        mi = max(mi, 2LL);
//        cout << x << ' ' << ans << ' ' << mi << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
hist = {}
hist_wa = {}
count_ac = count_wa = 0
for i in range(m):
  p,s = input().split()
  if p in hist:
    continue
  if s == 'AC':
    hist[p] = True
    count_ac += 1
    if p in hist_wa:
      count_wa += hist_wa[p]
  else:
    if p in hist_wa:
      hist_wa[p] += 1
    else:
      hist_wa[p] = 1
print('{} {}'.format(count_ac, count_wa))
    

Measured memory_bytes: 17116
#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 NDEBUG
#include<assert.h>
const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int cnt = 0;
  while(b <= a) {
    cnt++;
    b *= 2;
  }
  while(c <= b) {
    cnt++;
    c *= 2;
  }
  if(cnt > k) puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  long n;
  cin >> n;

  vector<long> a(n);
  fillLong(a, n);

  sortv(a);
  int idxl = 1;
  int idxr = n-1;
  int left = a[0];
  int right = a[0];

  int mode = 0;
  long res = 0;

  while(idxl <= idxr) {
    if (mode == 0) {
      res += a[idxr] - left;
      left = a[idxr];
      idxr--;
    } else if (mode == 1) {
      res += a[idxr] - right;
      right = a[idxr];
      idxr--;
    } else if (mode == 2) {
      res += left - a[idxl];
      left = a[idxl];
      idxl++;
    } else if (mode == 3) {
      res += right - a[idxl];
      right = a[idxl];
      idxl++;
    } 
    mode = (mode+1)%4;
  }

  long res2 = 0;
  idxl = 0;
  idxr = n-2;
  left = a[n-1];
  right = a[n-1];
  mode = 2;

  while(idxl <= idxr) {
    if (mode == 0) {
      res2 += a[idxr] - left;
      left = a[idxr];
      idxr--;
    } else if (mode == 1) {
      res2 += a[idxr] - right;
      right = a[idxr];
      idxr--;
    } else if (mode == 2) {
      res2 += left - a[idxl];
      left = a[idxl];
      idxl++;
    } else if (mode == 3) {
      res2 += right - a[idxl];
      right = a[idxl];
      idxl++;
    } 
    mode = (mode+1)%4;
  }

  cout << max(res, res2) << endl;
}


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

long long mod = 1000000007;

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

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

int main() {
    long long n, s;
    cin >> n >> s;
    vector<int> as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }
    long long min = 1e10;
    long long x, sum = 0, ans = 0, p2 = 0;
    for (int p1 = 0; p1 < n; p1++) {
        while (p2 < n && sum + as[p2] < s) {
            sum += as[p2];
            p2++;
        }
        if (p2 == n) {
            continue;
        }
        if (p2 - p1 + 1 < min) {
            min = p2 - p1 + 1;
        }
        sum -= as[p1];
        //cout << p1 << " " << p2 << endl;
    }
    if (min == 1e10) {
        cout << 0 << endl;
        return 0;
    }
    cout << min << endl;
}


Measured memory_bytes: 3360
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s, t;
    cin >> s >> t;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int64_t count(int64_t H){
  if(H==1){
    return 1;
  }
  else{
    return 1+2*count(H/2);
  }
}

int main() {
  int64_t H;
  cin >> H;
  cout << count(H) << endl;
}

Measured memory_bytes: 256
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);

  ll arr[5];
  for(int i=0;i<5;i++) cin>>arr[i];
  ll k,c=0;
  cin>>k;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(arr[j]-arr[i]>k&&j!=i) c++;
      
    }
  }
  if(c) cout<<":(";
  else cout<<"Yay!";

}

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

#define pb push_back
#define mk make_pair
#define fs first
#define sc second
#define all(a) s.begin(), s.size()
#define file(s, w) freopen(s".in", "r", stdin); freopen(w".out", "w", stdout);

typedef long long ll;
typedef long double ld;

using namespace std;

const int N = 1e5 + 500;
const int mod = 1e9 + 7;
const int eps = 1e9 - 11;
const int inf = 2e9;
long long ans, cur, n, p, m, r;
long long a[2000];
void show(){
        for (int i = 1; i <= n; i ++)
                cout << a[i] << " ";
        cout << endl;
}
int main()
{
        cin >> n;
    for (int i = 1; i <= n; i ++)
        a[i] = i;
    r = 1;
    for (int i = 1; i <= n; i ++){
        m = 0;
        for(int j = i; j <= n; j ++)
            if (a[j] !=  1){
                m = a[j];
                break;
            }
        p = 0;
        if (m > 0)
            for ( int j = i; j <= n; j ++)
                while (a[j] % m == 0){
                    p ++;
                    a[j] = a[j] / m;
                }
             //   show();
            if (p > 0) r = (r * (p + 1) + mod) % mod;
        else break;
    }
    cout << r << endl;
}


Measured memory_bytes: 256