akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdlib>
#include<stack>
#include<climits>
#include<vector>
#include<string>
#include<map>
using namespace std;
char s[15];
int a[15];
int main(){
    while(~scanf("%s", s)){
        int len=strlen(s);
        int cnt=0;
        for(int i=0; i<len; i++){
            if(s[i]!='B') a[++cnt]=s[i]-'0';
            else{
                if(cnt>=1) --cnt;
            }
        }
        for(int i=1; i<=cnt; i++)
            printf("%d",a[i]);
        printf("\n");
    }
    return 0;
}


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

    int X,Y;
    cin >> X >> Y;

    for(int i = 0; i <= X; i ++){
        if(2*X + 2*i == Y){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 3632
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    double ans = 0.0;
    ll N;
    cin >> N;
    struct Point {
        ll id;
        ll x;
        ll y;
        double dist(const Point& rhs) {
            ll sq = (x - rhs.x) * (x - rhs.x) + (y - rhs.y) * (y - rhs.y);
            return sqrt((double)sq);
        }
        bool operator<(const Point& rhs) const {
            return id < rhs.id;
        }
    };
    vector<Point> points(N);
    rep(i,0,N) {
        cin >> points[i].x >> points[i].y;
        points[i].id = i;
    }
    do {
        rep(i,1,N) {
            ans += points[i-1].dist(points[i]);
        }
    } while (next_permutation(points.begin(), points.end()));
    ll fact = 1;
    rep(n,1,N+1) {
        fact *= n;
    }
    ans /= fact;
    cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 888
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int n;
    cin >> n;
    vector<string> w(n);
    rep(i,n)cin >> w[i];
    rep(i,n-1)
    {
        if(w[i][w[i].length()-1]!=w[i+1][0])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    SORT(w);
    rep(i,n-1)
    {
        if(w[i]==w[i+1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#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>;

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

ll dp[110][100100];
int w[110], v[110];

int main()
{
    int N, W;
    cin >> N >> W;
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N) rep(j, W + 1)
    {
        if (j >= w[i])
            chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        chmax(dp[i + 1][j], dp[i][j]);
    }
    // rep(i, N)
    // {
    //     rep(j, W + 1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << dp[N][W] << endl;
    return 0;
}

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

int main(){
 int s;
 cin >> s;
 int mae = s/100; //４桁の数字の上二けたは１００で割ることによって求められる　例：１２００/100= 12　知りたい数字になるように桁を消すというイメージ
 int ato = s%100; //後ろ二けたは１００で割ったときのあまり　例１２０１%100= 1　これは桁数によって、代わっていく（５桁の下二桁を知りたいときは１０００で割る）
 if(0<mae && mae<13){
     if(0<ato && ato<13){cout << "AMBIGUOUS" << endl;}
    else{cout << "MMYY" << endl;}
 }
 else{
     if(0<ato && ato<13){cout << "YYMM" << endl;}
     else{cout << "NA" << endl;}
     return 0;
 }
}

Measured memory_bytes: 384
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def add(i,s):
        while i <= n:
            bit[i] += s
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n,d,a = LI()
    p = LIR(n)
    bit = [0]*(n+1)
    p.sort()
    ans = 0
    X = [p[i][0] for i in range(n)]
    for i in range(n):
        x,h = p[i]
        j = bisect.bisect_left(X,x-2*d)
        if i != j:
            su = sum(i+1)
            if j > 0:
                su -= sum(j)
            h -=  su
        if h > 0:
            l = x
            k = math.ceil(h/a)
            ans += k
            add(i+1,k*a)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 106920
def timecalc(p1,p2,speed):
    h1,h2= p1
    l1,l2= p2
    return ((h1-l1)/speed,(h1-l2)/speed,(h2-l1)/speed,(h2-l2)/speed)

n=int(input())
ans=2**62
X = []
Y = []
U = []
D = []
L = []
R = []

for i in range(n):
    xin = input().split()
    x,y,dir = int(xin[0]),int(xin[1]),xin[2]
    if dir=='U':
        X.append(x)
        U.append(y)
    elif dir=='D':
        X.append(x)
        D.append(y)
    elif dir=='L':
        Y.append(y)
        L.append(x)
    else:
        Y.append(y)
        R.append(x)
if n==1:
    print(0)
    exit(0)

if X:
    X = [max(X),min(X)]
if Y:
    Y = [max(Y),min(Y)]
if U:
    U = [max(U),min(U)]
if D:
    D = [max(D),min(D)]
if L:
    L = [max(L),min(L)]
if R:
    R = [max(R),min(R)]
T = []

if X and R:
    T.extend( [i for i in timecalc(X,R,1) if i>0] )
if L and X:
    T.extend( [i for i in timecalc(L,X,1) if i>0] )
if Y and U:
    T.extend( [i for i in timecalc(Y,U,1) if i>0] )
if D and Y:
    T.extend( [i for i in timecalc(D,Y,1) if i>0] )
if L and R:
    T.extend( [i for i in timecalc(L,R,2) if i>0] )
if D and U:
    T.extend( [i for i in timecalc(D,U,2) if i>0] )

T = list(set(T))
T.append(0)

for i in T:
    xmax = -10**9
    ymax = -10**9
    xmin = 10**9
    ymin = 10**9
    if X:
        xmax = max(xmax,X[0])
        xmin = min(xmin,X[1])
    if Y:
        ymax = max(ymax,Y[0])
        ymin = min(ymin,Y[1])
    if U:
        ymax = max(ymax,U[0]+i)
        ymin = min(ymin,U[1]+i)
    if D:
        ymax = max(ymax,D[0]-i)
        ymin = min(ymin,D[1]-i)
    if L:
        xmax = max(xmax,L[0]-i)
        xmin = min(xmin,L[1]-i)
    if R:
        xmax = max(xmax,R[0]+i)
        xmin = min(xmin,R[1]+i)
    
    ans = min(ans,((xmax-xmin)*(ymax-ymin)))

print(ans)

Measured memory_bytes: 57176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();

		int a[] = new int[M];
		for (int i = 0; i < M; i++) {
			a[i] = sc.nextInt();
		}

		int c1 = 0;
		int c2 = 0;

		int n = X;
		while(X != 0) {
			X--;
			for (int i = 0; i < M; i++) {
				if (X == a[i]) {
					c1++;
				}
			}
		}

		X = n;
		while(X != N) {
			X++;
			for (int i = 0; i < M; i++) {
				if (X == a[i]) {
					c2++;
				}
			}
		}

		if (c1 <= c2) {
			System.out.println(c1);
		} else {
			System.out.println(c2);
		}

	}

}

Measured memory_bytes: 23636
#include <stdio.h>

int main(void)
{
    int mountains;
    int seeableinn = 0;
    int highest = 0;

    scanf("%d", &mountains);
    int height[mountains];

    for(int i = 0; i < mountains; i++)
        scanf("%d", &height[i]);

    for(int i = 0; i < mountains; i++)
        if(highest <= height[i])
        {
            seeableinn++;
            highest = height[i];
        }
    printf("%d\n", seeableinn);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll x,k; cin >> x >> k;
    ll ans = x%k;
    ll m = abs(ans-k)%k;
    cout << min(ans,m) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
using namespace std;
typedef pair<string,int>P;
int bfs(string worm){
  queue<P>que;
  que.push(P(worm,0));
  map<string,int>d;
  while(!que.empty()){
    P p = que.front();
    que.pop();

    if(d[p.first])continue;
    string str = p.first;
    bool flag = false;
    for(int i = 0 ; i < str.size()-1 ; i++ ){
      if(str[i] != str[i+1] ){
	flag = true;
	break;
      }
    }
    if(!flag)return p.second;
    d[p.first] = p.second;
    for(int i = 0 ; i < str.size()-1 ; i++ ){
      if(str[i] != str[i+1]){
	char tmp;
	string next;
	if(str[i] != 'b' && str[i+1] != 'b'){
	  tmp = 'b'; 
	}else if(str[i] != 'g' && str[i+1] != 'g'){
	  tmp = 'g';
	}else {
	  tmp = 'r';
	}
	next = str;
	next[i] = next[i+1] = tmp;
	que.push(P(next,p.second + 1));
      }
    }
  }
  return -1;
}

int main(){
  string worm; 
  while(  cin >> worm ){
    if(worm[0] == '0' )break;  
    int ret = bfs(worm);
    if(ret >= 0)cout << ret << endl;
    else cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(void){
    //n<=50
    int n,i,j,k,l,cnt;
    while(cin>>n){
        cnt = 0;
        for(i=0;i<=9;i++){
            for(j=0;j<=9;j++){
                for(k=0;k<=9;k++){
                    for(l=0;l<=9;l++) if(i+j+k+l==n) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

void print(string str,int a,int b){
  for(int i = a ; i < b + 1; i++){
    cout << str.at(i);
  }
  cout << endl;
  return;
}

void repla(string& str,int a,int b,string p){
  for(int i = a ; i < b + 1; i++){
    str.at(i) = p.at(i - a);
  }
  return;
}

int main(){
  string str, str1, p; int q, a, b;
  cin >> str >> q;
  
  for(int i = 0; i < q; i++){
    cin >> str1 >> a >> b;;
    if(str1 == "replace"){
      cin >> p;
      repla( str, a, b, p);
    }
    else if(str1 == "reverse"){
      reverse( str.begin() + a, str.begin() + b + 1);
    }
    else{
      print( str, a, b);
    }
  }
}


Measured memory_bytes: 3172
import java.util.*;
class Main{
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLInt()をnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */
    final int[] dx = {1,0,-1,0};
    final int[] dy = {0,1,0,-1};
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] t = new int[N];
        int[] x = new int[N];
        int[] y = new int[N];
        int nowt = 0;
        int nowx = 0;
        int nowy = 0;
        for(int i=0;i<N;i++){
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();

            int cost = Math.abs(nowx-x[i]) + Math.abs(nowy-y[i]);
            int dt = t[i] - nowt;

            if(cost > dt){
                System.out.println("No");
                return;
            }

            if((dt-cost) % 2 == 1){
                System.out.println("No");
                return;
            }

            nowt = t[i];
            nowx = x[i];
            nowy = y[i];
        }

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


Measured memory_bytes: 89900
import sys
sys.setrecursionlimit(1000000)
def main():
  _map = map
  _input = input
  _int = int
  def calc_results(results, pvalue, i):
    results[i] = pvalue + values[i]
    for j in childrens[i]:
      calc_results(results, results[i], j)
  n, q = _map(_int, _input().split())
  values = [0] * (n + 1)
  results = [0] * (n + 1)
  childrens = [[] for _ in range(n + 1)]
  for i in range(n - 1):
    a, b = _map(_int, _input().split())
    childrens[a].append(b)
  for _ in range(q):
    p, x = _map(_int, _input().split())
    values[p] += x
  calc_results(results, 0, 1)
  print(*[results[i] for i in range(1, n + 1)])
main()


Measured memory_bytes: 268008
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef vector<vector<P>> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<ll> vec;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

vector<bool> visit;
vvec G;
void dfs(int now){
    visit[now]=true;
    for(int next:G[now]){
        if(visit[next]) continue;
        dfs(next);
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    visit.resize(n,false);
    G.resize(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        G[x].pb(y);
        G[y].pb(x);
    }
    
    ll ans=0;
    rep(i,n){
        if(!visit[i]){
            ans++;
            dfs(i);
        }
    }
    cout<<ans<<endl;
}

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

using ll = long long;

void solve(std::vector<long long> x){
    for(int i = 0;i < 5;i++){
        if(x[i] == 0){
            cout<<i+1<<endl;
        }
    }
}

int main(){
    std::vector<long long> x(5);
    for(int i = 0 ; i < 5 ; i++){
        scanf("%lld",&x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3688
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // */

    lli n,i,ans=0;
    cin>>n;
    lli a[n];
    rep(i,0,n)
    {
        cin>>a[i];
    }
    rep(i,0,n-1)
    {
        if(a[i]%2)
        {
            ans+=a[i]/2;
            if(a[i+1])
            {
                ans++;
                a[i+1]--;
            }
        }
        else
        {
            ans+=a[i]/2;
        }
    }
    ans+=a[n-1]/2;
    cout<<ans;
 return 0;
}


                                                                                                                                                                                          

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n,k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll count = 0;
    for(int i = k;i<n;i++) {
        count += a[i];
    }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}

void print(const unsigned char Q[8]) {
    for(int i = 0; i < 8; ++i) {
        for(int j = 0; j < 8; ++j)
            putchar_unlocked(Q[i] == j ? 'Q' : '.');
        putchar_unlocked('\n');
    }
}
void queen_eight(unsigned char Q[8], unsigned char col[8], unsigned char lrd[15], unsigned char lld[15], int cnt) {
    if(cnt == 8) {
        print(Q);
        return;
    }
    if(Q[cnt] != 9) {
        queen_eight(Q, col, lrd, lld, cnt + 1);
        return;
    }
    for(int i = 0; i < 8; ++i) {
        if(col[i] || lrd[cnt - i + 7] || lld[cnt + i]) continue;
        Q[cnt] = i;
        col[i] = lrd[cnt - i + 7] = lld[cnt + i] = 1;
        queen_eight(Q, col, lrd, lld, cnt + 1);
        Q[cnt] = 9;
        col[i] = lrd[cnt - i + 7] = lld[cnt + i] = 0;
    }
}
int main(int argc, char **argv) {
    unsigned char Q[8] = {9, 9, 9, 9, 9, 9, 9, 9};
    unsigned char col[8] = {};
    unsigned char lrd[15] = {};
    unsigned char lld[15] = {};

    int k = get_uint();
    for(int i = 0; i < k; ++i) {
        int r = get_uint();
        int c = get_uint();
        Q[r] = c;
        col[c] = lrd[r - c + 7] = lld[r + c] = 1;
    }
    queen_eight(Q, col, lrd, lld, 0);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N,K;
vector<ll> A;

int main() {
    cin >> N >> K;
    
    A.assign(N,0);
    for (int i=0; i<N; i++) {
        cin >> A[i];
    }

    ll answer = 0;
    for (ll i=40; -1<=i; i--) {
        ll sum = 0;
        if( i!=-1 && !(K & (1ll<<i)) ) continue;

        for (ll j=40; 0<=j; j--) {
            ll mask=1ll<<j, count=0;

            for (ll i=0; i<N; i++) {
                if(mask & A[i]) count++;
            }

            if (i<j) {
                sum += (K & mask) ? mask * (N-count) : mask * count;
            } else if(j==i){
                sum += mask * count;
            } else {
                sum += mask * max(count, N-count);
            }
        }
        answer = max(answer, sum);
    }

    cout << answer << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>		
using namespace std;
 
#define ll long long
 
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n+1, 0);
    for(int i=1; i<=n; i++) cin >> p[i];
    vector<int> s(n+1, 0);
    s[0] = 0;
    for(int i=1; i<=n; i++) {
        s[i] = s[i-1] + p[i];
    }
    int max_i;
    int max_s = 0;
    for(int i=1; i<=n-k+1; i++) {
        if(s[i+k-1] - s[i-1]>=max_s) {
            max_s = s[i+k-1] - s[i-1];
            max_i = i;
        }
    }
 
    double ans = 0;
    for(int i=max_i; i<=max_i+k-1; i++) {
        for(int j=1; j<=p[i]; j++) {
            ans += j*(double)1/(double)p[i];
        }
    }
 
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
N,M = map(int,input().split())
MOD=10**9+7
X=list(map(int,input().split()))
Y=list(map(int,input().split()))

Xsum=0
for i in range(1,N+1):
    Xsum+=X[i-1]*i-(N-i+1)*X[i-1]
    Xsum%=MOD

Ysum=0
for i in range(1,M+1):
    Ysum+=Y[i-1]*i-(M-i+1)*(Y[i-1])
    Ysum%=MOD

print(Xsum*Ysum%MOD)


Measured memory_bytes: 97692
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

typedef pair<ll,ll> p;

vector<ll> dp;
vector<vector<ll> > connected;
vector<ll> ans;
ll m;

ll dfs(ll node, ll from){//nodeへfromからいく
  ll res = 1;
  for(ll k : connected[node]){
    if(k==from) continue;
    res = res * (dfs(k,node)+1) % m;
  }
  return dp[node] = res;
}

void dfs2(ll node, ll from, ll up){
  ll s = connected[node].size();
  ll pl[s], pr[s];
  pl[0] = 1, pr[s-1] = 1;
  REP(i,s-1){
    if(connected[node][i]==from) pl[i+1] = pl[i];
    else pl[i+1] = pl[i] * (dp[connected[node][i]]+1) % m;
  }
  REP(i,s-1){
    if(connected[node][s-1-i]==from) pr[s-2-i] = pr[s-1-i];
    else pr[s-2-i] = pr[s-1-i] * (dp[connected[node][s-1-i]]+1) % m;
  }
  REP(i,s){
    if(connected[node][i]==from) continue;
    dfs2(connected[node][i],node,(up+1)*pl[i]%m*pr[i]%m);
  }
  ans[node] = dp[node] * (up+1) % m;
}

int main(){
  ll n;
  cin >> n >> m;
  connected.resize(n);
  dp.resize(n);
  ans.resize(n);
  REP(i,n-1){
    ll x,y;
    cin >> x >> y;
    x--, y--;
    connected[x].push_back(y);
    connected[y].push_back(x);
  }
  dfs(0,-1);
  dfs2(0,-1,0);
  REP(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 20864
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	int ans = a[0];
	for (int i = 1; i < n; i++) {
		ans = ans ^ a[i];
	}
	
	cout << (ans == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{   
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int hour = 0;
    int minute = 0;
    int time = 0;
    int ans = 0;
    
    if (h1 > h2) {
        h2 = h2 + 24;
    }
    if (m1 <= m2) {
        hour = h2 - h1;
        minute = m2 - m1;
        time = 60 * hour + minute;
    } else {
        hour = (h2-1) - h1;
        minute = m2 + (60 - m1);
        time = 60 * hour + minute;
    }
    ans = time - k;
    if (ans <= 0) {
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
S = gets.chomp
ans = nil
if S == "zyxwvutsrqponmlkjihgfedcba"
    ans = -1
elsif S.length == 26
    reversed_suffix = []
    for i in 1..S.length
        if !reversed_suffix.empty? && S[-i] < reversed_suffix[-1]
            ans = S[0..-i-1] + reversed_suffix.find {|char| S[-i] < char}
            break
        else
            reversed_suffix << S[-i]
        end
    end
else
    all = "abcdefghijklmnopqrstuvwxyz"
    S.each_char do |char|
        all.delete!(char)
    end
    ans = S + all[0]
end
puts ans


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

#define rep(i,s,n) for(int i=s; i<n; ++i)
#define mset(a,n) memset(a, n, sizeof(a))
#define sc(a) scanf("%d", &a)
#define prt(a,c) printf("%lld%c", a, (c ? '\n' : ' '))

typedef long long LL;

const int N = 1e6 + 10;

int n;
LL vis[N];

int main() {
	mset(vis,0);
	vis[1] = 1;
	rep(i,2,N) {
		if((i%3==0)||(i%5==0))
			vis[i] = vis[i-1];
		else
			vis[i] = vis[i-1] + i;
	}
	
	sc(n);
	prt(vis[n],1);
	return 0;
}

Measured memory_bytes: 11652
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める
    計算量: O(Nlog)
    """
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
MOD = 10**9 + 7
a = list(map(int, input().split()))
lcm_ = multi_lcm(a) % MOD
ans = 0
for i in range(n):
    ans += lcm_ * pow(a[i], MOD - 2, MOD)
print(ans % MOD)


Measured memory_bytes: 66776
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]
J = [False]*(N+1)
K = [False]*(N+1)
J[0] = False
K[N] = False
J[1] = False
K[1] = False
for j in range(M):
  if L[j][0] == 1:
    J[L[j][1]] = True
for k in range(M):
  if L[k][1] == N:
    K[L[k][0]] = True
flag = False
for l in range(N+1):
  if J[l] and K[l]:
    flag = True
    break
if flag:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 54812
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>


using namespace std;
typedef long long ll;

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<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;


bool issq(int x) {
	for (int i = 1; i * i <= x; i++) {
		if (i * i == x) return true;
	}
	return false;
}
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, D; cin >> n >> D;
	vector<vector<int>> x(n, vector<int>(D));
	for (int i = 0; i < n; i++) for (int j = 0; j < D; j++) cin >> x[i][j];
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int d = 0;
			for (int k = 0; k < D; k++) d += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			if (issq(d)) cnt++;
		}
	}

	cout << cnt << endl;
	return 0;
}

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

static const int MAX = 200000;

int main(){

    int R[MAX], n;
    cin >> n;
    for(int i=0;i<n;i++) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for (int i=1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }   

    cout << maxv <<endl;

    return 0;
}



Measured memory_bytes: 3852
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N, M;
const int MAX_N = 100010;
vector<pii> edges1[MAX_N];
vector<pii> edges[MAX_N];
int visited[MAX_N];
int costs[MAX_N];
bool parent[MAX_N];

void init()
{
    rep(i, MAX_N)
    {
        costs[i] = INF;
        parent[i] = true;
    }
}
bool dfs(int pos, int pre, int cost)
{
    if (visited[pos] != 0)
    {
        if (visited[pos] == 2)
        {
            return false;
        }
        if (cost == costs[pos])
        {
            return true;
        }
        return false;
    }

    costs[pos] = cost;
    visited[pos] = 2;
    bool ok = true;
    for (auto &val : edges[pos])
    {
        int nxt = val.first;
        int c = val.second;
        if (nxt == pre)
        {
            continue;
        }

        ok &= dfs(nxt, pre, cost + c);
    }
    visited[pos] = 1;
    return ok;
}
int main()
{
    init();
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int l, r, d;
        cin >> l >> r >> d;
        l--, r--;
        edges[l].push_back(mp(r, d));
        parent[r] = false;
    }
    if (M == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    bool ok = true;
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        if (visited[i] != 0 || !parent[i])
        {
            continue;
        }
        if (edges[i].empty())
        {
            continue;
        }
        res++;
        // cerr << i << " " << res << endl;
        ok &= dfs(i, -1, 0);
    }

    if (ok && res > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 15232
x,y = map(int,input().split())

mod = 10**9+7

division = (x+y)//3

if [x%3,y%3] in [[1,1],[2,2]]:
    print(0)
    exit()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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



r = min(x,y)-division
ans = cmb(division,r,mod)

print(ans)


Measured memory_bytes: 122040
#include<stdio.h>
#include<string.h>
int main(void){
  int i,n,a=0,b=0,c=0,d=0;
  char s[10];
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%s", &s);
    if(strcmp(s,"AC")==0){
      a++;
    }
    else if(strcmp(s,"WA")==0){
      b++;
    }
    else if(strcmp(s,"TLE")==0){
      c++;
    }
    else{
      d++;
    }
  }
  printf("AC x %d\n", a);
  printf("WA x %d\n", b);
  printf("TLE x %d\n", c);
  printf("RE x %d\n", d);
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> score(n);
  int total = 0;
  for(int i=0;i<n;i++) {
    cin >> score[i];
    total += score[i];
  }

  sort(score.begin(), score.end());

  if(total % 10 == 0) {
    int point = total;
    for(auto i=0;i<n;i++) {
      if(score[i]%10==0) continue;
      else {
        point = score[i];
        break;
      }
    }
    cout << total - point << endl;
  } else {
    cout << total << endl;
  }
}

Measured memory_bytes: 256
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $c, $k) = split / /, <STDIN>);
my @t;
my ($ans, $bc, $tc) = (0, 0, 0);
for my $i (0..$n-1) {
  chomp ($t[$i] = <STDIN>);
}
@t = sort {$a <=> $b} @t;
for my $i (0..$n) {
  if ($i == $n) {
    $ans++ if $bc > 0;
    last;
  }
  $bc++;
  if ($bc == 1) {
    $tc = $t[$i];
  } elsif ($t[$i] > $tc + $k) {
    $ans++;
    $bc = 1;
    $tc = $t[$i];
  }
  if ($bc == $c) {
    $ans++;
    $bc = 0;
  }
}
say $ans;

Measured memory_bytes: 18944
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def swap_0_1(p):
    num_change = len([i for i in range(len(p)) if p[i] != i+1])
    if num_change in [0, 2]: return True
    return False

def main():
    n = int(input())
    p = list(map(int, input().split()))
    if(swap_0_1(p)): print("YES")
    else: print("NO")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (foldl')

main :: IO ()
main = do
  [n, k] <- map read <$> words <$> getLine
  unless (n == 0 && k == 0) $ do
    solve k <$> replicateM n (readi B.readInt <$> B.getLine) >>= print
    main

solve :: Int -> [Int] -> Int
solve k xs = fst $ foldl' f (sc, sc) $ zipWith (-) zs xs
  where (ys, zs) = splitAt k xs
        sc = sum ys
        f (sm, sc) d | sn > sm = (sn, sn)
                     | otherwise = (sm, sn)
          where sn = sc + d

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n



Measured memory_bytes: 37684
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]


ans = 0
AB = sorted(AB, key=lambda x: x[1])
last = 0
for i, v in enumerate(AB):
    if last < v[0]:
        last = v[1]-1
        ans += 1


print(ans)

Measured memory_bytes: 29848
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA(My_College_Sucks)
*/
#include <bits/stdc++.h>
using namespace std;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define nl printf("\n")
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli, lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
    opt;
    lli n,t;
    cin>>n>>t;
    lli ans=t,a[n],i,temp;
    rep(i,0,n)
    {
        cin>>a[i];
    }

    rep(i,1,n)
    {
        if(a[i]>=t+a[i-1])
        {
            ans+=t;
        }
        else
        {
            ans+=(a[i]-a[i-1]);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

char btn[9][8]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(void){
	int i,j,n;
	char c,tc;

	scanf("%d ",&n);
	while(n--){
		for(i=0;;i=j+1){
			for(j=i;(c=getchar())!='0' && c!='\n';tc=c,j++);
			if(c == '\n') break;

			if(i != j){
				putchar(btn[tc-'1'][(j-i-1)%strlen(btn[tc-'1'])]);
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.*;
public class Main{
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int n = 0;
		while((str=br.readLine()) != null){
			n=Integer.parseInt(str);
			System.out.println((n*n+n+2)/2);
		}
	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,ans=1,now;
  cin >> m >> n;
  long long a[n],b[n];
  pair<long long,long long> p[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    p[i]=make_pair(b[i],a[i]);
  }
  sort(p,p+n);
  now=p[0].first;
  for(int i=0;i<n;i++){
    if(now<=p[i].second){
      ans++;
      now=p[i].first;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main()
{  
  #ifndef ONLINE_JUDGE
	 freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);

  #endif

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

     long long ans[n];
     ans[0]=0;
     ans[1]=abs(a[0]-a[1]);
     for(int i=2; i<n; i++)
     { if(ans[i-1]+abs(a[i-1]-a[i]) < ans[i-2]+abs(a[i-2]-a[i]) )
     	 ans[i]=ans[i-1]+abs(a[i-1]-a[i]);
       else
       	 ans[i]=ans[i-2]+abs(a[i-2]-a[i]);
     }

     cout<<ans[n-1]<<endl;

 }

Measured memory_bytes: 4708
const main = (inputs) => {
  if(inputs[0] === 'Sunny'){
    console.log('Cloudy');
  }
  else if(inputs[0] === 'Cloudy'){
    console.log('Rainy');
  }
  else{
    console.log('Sunny');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));

Measured memory_bytes: 7372
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    ns = ""
    cnt = 0
    for i in s:
        if cnt%2 ==0:
            ns += i
        cnt+=1
    
    print(ns)
solve()


Measured memory_bytes: 3188
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long 
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{ quick;

	int n;
	cin>>n;
	int h[n];
	fab(0,n,i)
	cin>>h[i];
	vector<int> dp(n);
	dp[n-1]=0;
	dp[n-2]=abs(h[n-1]-h[n-2]);

	for(int i=n-3;i>=0;i--)
	{
		dp[i]=min(dp[i+1]+abs(h[i+1]-h[i]),dp[i+2]+ abs(h[i+2]-h[i]));
	}
	cout<<dp[0]<<endl;

	return 0;
}

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

ll inf=9223372036854775806,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a,b;
	cin>>a>>b;
	if (a[0]==b[2]&&a[2]==b[0]&&a[1]==b[1]){
		cout<<"YES";
	}
	else {
		cout<<"NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
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; }


signed main()
{
    int A,B; cin>>A>>B;
    if(A<=5) cout<<0<<endl;
    else if(A<=12) cout<<B/2<<endl;
    else cout<<B<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    int w = 0, p = 0;
    int K = 0, P = 0;
    for (int i = 0; i < nap.size(); ++i)
    {
        if (nap[i] == 'g')
        {
            if (P + 1 <= K)
            {
                ++P;
                ++w;
            }
            else
                ++K;
        }
        else
        {
            if (P + 1 <= K)
                ++P;
            else
            {
                ++K;
                ++p;
            }
        }
    }
    cout << w - p;
    return 0;
}


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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;

    int sum;
    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        sum = 0;
        int num = i;
        while (num)
        {
            sum += (num % 10);
            num /= 10;
        }
        if (a <= sum && sum <= b)
        {
            // cout << i << endl;
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

int N;

int main(void) {
  cin >> N;
  ll sum = 0, mx = 1;
  for (mx = 1; mx <= N; mx++) {
    sum += mx;
    if (sum >= N) break;
  }
  int diff = sum - N;
  for (int i = 1; i <= mx; i++) {
    if (i != diff) cout << i << endl;
  }
  return 0;
}


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

int main() {
	double max = 0;
	double min = numeric_limits<double>::max();
	double now;
	while (cin >> now) {
		if (max < now) {
			max = now;
		}
		if (min > now) {
			min = now;
		}
	}
	cout << max - min << endl;
	
	return 0;
}

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

void printArr(int arr[], int n, int q){
	for(int i = 0; i <= n; i++){
		if(i == q) {
			cout << "[";
		}
		cout << arr[i];
		if(i == q){
			cout << "]";
		}
		if(i != n){
			cout << " ";
		}
	}
	cout << endl;
}

int partition(int arr[], int s, int l){
	int x = arr[l];
	int i = s - 1;

	for(int j = s; j < l; j++){
		if(arr[j] <= x){
			i++;
			swap(arr[i], arr[j]);
		}
	}
	swap(arr[i+1], arr[l]);
	return i + 1;
}

int main(){
	int n, q;
	int arr[1000000];

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

	q = partition(arr, 0, n - 1);
		printArr(arr,n-1,q);

}


Measured memory_bytes: 3496
//
// Created by 李青坪 on 2018/12/9.
//

#include <cmath>
#include <cstdio>
//#include <assert.h>
#include <algorithm>
#include <vector>

#define EPSLON 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPSLON)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK -2
#define ONLINE_FRONT 2
#define ON_SEGMENT 0

using namespace std;

// 点
class Point {
public:
    double x;
    double y;

    Point() {}

    Point(double x, double y) : x(x), y(y) {}

    Point operator+(Point a) {
        return Point(x + a.x, y + a.y);
    }

    Point operator-(Point a) {
        return Point(x - a.x, y - a.y);
    }

    Point operator*(double a) {
        return Point(x * a, y * a);
    }

    Point operator/(double a) {
        return Point(x / a, y / a);
    }

    double norm() {
        return x * x + y * y;
    }

    double absVector() {
        return sqrt(norm());
    }

    bool operator==(Point a) const {
        return equals(x, a.x) && equals(y, a.y);
    }
};

typedef Point Vector;

// 线段
class Segment {
public:
    Point a, b;
};

typedef Segment Line;

typedef vector<Point> Polygon;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

int contains(Polygon g, Point p) {
    int n = g.size();
    bool contain = false;
    for (int i = 0; i < n; ++i) {
        Vector a = g[i] - p;
        Vector b = g[(i + 1) % n] - p;
        if (abs(cross(a, b)) < EPSLON && dot(a, b) < EPSLON) return 1;
        if (a.y > b.y) swap(a, b);
        if (a.y < EPSLON && b.y > EPSLON && cross(a, b) > EPSLON) contain = !contain;
    }
    return contain ? 2 : 0;
}

int n;

int main() {
    Polygon g;
    scanf("%d", &n);
    double x, y;
    for (int i = 0; i < n; ++i) {
        scanf("%lf %lf", &x, &y);
        g.push_back(Point(x, y));
    }
    int q;
    scanf("%d", &q);
    for (int j = 0; j < q; ++j) {
        scanf("%lf %lf", &x, &y);
        Point p = Point(x, y);
        printf("%d\n", contains(g, p));
    }
}


Measured memory_bytes: 2764