akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define VI  vector<ll>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
const ll mod=1e9+7;
double pi = 2 * acos(0.0);
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
bool cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return (a.first)<(b.first);
}
ll power(ll a,ll b)
{
        ll p=1;
        for(ll i=1;i<=b;i++)
        p*=a;

        return p;
}
ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }
void bfs(map<ll,vector<ll> > &g,ll src,vector<ll> &c)
{
    queue<ll> q;
    map<ll,ll> p;
    q.push(src);
    p[src]=src;
    c[src]=1;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        ll i=1;
        for(auto v:g[u])
        {
            if(c[v]==-1)
            {
                q.push(v);
                p[v]=u;
                if(i==c[u]||i==c[p[u]])
                    i++;
                if(i==c[u]||i==c[p[u]])
                    i++;
                c[v]=i;
                i++;
            }
        }
    }
}
int main()
{
    FASTIO;
    ll n,i,j;
    cin>>n;
    ll a[n],b[n],c[n],dp[n][3];
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        dp[i][0]=dp[i][1]=dp[i][2]=INT_MAX;
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}



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

int main(){
  int five=0;
  int seven=0;
  for(int i=0;i<3;i++){
  int num;
  cin>>num;
  if(num==5) five++;
  if(num==7) seven++;
  }
  if(five==2&&seven==1)
    cout<<"YES\n";
  else cout<<"NO\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>>G;
vector<bool>seen;
int ans=0;
void dfs(int v){
  //終了条件
  bool end=true;
  for(int i=0;i<seen.size();i++){
    if(!seen[i]&&i!=v)end=false;
  }
  if(end){
    ans++;
    return;
  }

  seen[v]=true;
  for(auto nv:G[v]){
    if(seen[nv])continue;
    dfs(nv);
  }
  seen[v]=false;
}
int main(){
  int N,M;
  cin>>N>>M;
  G.resize(N);
  seen=vector<bool>(N,false);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0);
  cout<<ans<<endl;
}

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

using namespace std;

#define INF 2e9

using ii = pair<int,int>;

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

    int n;
    cin >> n;
    vector<int> heights(n);
    vector<int> dp(n,INF);
    dp[0] = 0; //minimum cost
    for(auto& x : heights)
    {
        cin >> x;
    }

    for(int i=0;i<n;++i)
    {
        if(i-1>=0)
            dp[i] = min(dp[i],dp[i-1] + abs(heights[i] - heights[i-1]));
        if(i-2>=0)
            dp[i] = min(dp[i],dp[i-2] + abs(heights[i] - heights[i-2]));
    }

    cout << dp[n-1] << '\n';


    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

template<typename T>
struct Edge {
    int from, to;
    T cost;
};

template<typename T>
using Edges = vector<Edge<T>>;

template<typename T>
struct Graph {
    vector<Edges<T>> g;
    Graph(int n): g(n) {}
    int size() { return g.size(); };
    bool add_edge(int from, int to, T cost = 1) {
        g[from].emplace_back((Edge<T>){ from, to, cost });
    }
};

template<typename T>
struct MST {
    T cost;
    Edges<T> edges;
};

template<typename T>
vector<T> bellman_ford(Edges<T> &edges, int V, int s) {
    const auto INF = numeric_limits<T>::max();

    vector<T> dist(V, INF);
    dist[s] = T();
    for(int i = 0; i < V; i++) {
        bool update = false;
        for(auto &e : edges) {
            if(dist[e.from] != INF && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
        if(i == V - 1) return vector<T>();
    }
    return dist;
}

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

    int v,e,r;
    cin>>v>>e>>r;
    Edges<int> edges(e);
    for(int i=0;i<e;i++){
        int s,t,d;
        cin>>s>>t>>d;
        edges.emplace_back((Edge<int>){s,t,d});
    }
    vector<int> dist = bellman_ford<int>(edges,v,r);
    if(dist.empty()){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    for(int i=0;i<v;i++){
        if(dist[i]==numeric_limits<int>::max())cout<<"INF"<<endl;
        else cout<<dist[i]<<endl;
    }
}


Measured memory_bytes: 3204
#include <stdio.h>
int main(void) {
  int house_number;
  int cir_lake;
  int dis_house[200000];
  int dis[200000];
  int i, max;
  
  scanf("%d %d", &cir_lake, &house_number);
  for(i = 0; i < house_number; i++) {
    scanf("%d", &dis_house[i]);
  }
  for(i = 0; i < house_number - 1; i++) {
    dis[i] = dis_house[i + 1] - dis_house[i];
  }
  dis[house_number - 1] = cir_lake - dis_house[house_number - 1] + dis_house[0];
  max = dis[0];
  for(i = 0; i < house_number; i++) {
    if(max < dis[i]) {
      max = dis[i];
    }
  }
  printf("%d", cir_lake - max);
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

//--------------------------


int main() {

  ll n,k;
  cin >> n >> k;

  ll res = 0;
  for(ll i=k; i<=n+1; ++i) {
    ll x = i*(i-1)/2;
    ll y = i*(2*n-i+1)/2;
    ll add = y-x+1;
    res = (res+add)%MOD;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, k;
    cin>>n>>k;
    vl as(n);
    cin>>as;

    vl ss(n + 1);
    vl bs(n + 1);
    rep(i, n) {
        ss[i + 1] = ss[i] + as[i];
        bs[i + 1] = bs[i] + max(0ll, as[i]);
    }
    ll ans = -LINF;
    rep(i, n - k + 1) {
        ll res = bs[i] - bs[0];
        res += max(0ll, ss[i + k] - ss[i]);
        res += bs.back() - bs[i + k];
        chmax(ans, res);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

int main() {
  long N;
  scanf("%ld%*c", &N);
  long i, n;
  long odd_num = 0;
  for (i = 0; i < N; i++) {
    scanf("%ld%*c", &n);
    if (n % 2 != 0)
      odd_num++;
  }
  if (odd_num % 2 == 0)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}



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

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

    int n, k, mindiff;
    mindiff = INT_MAX;
    cin >> n >> k;

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

    sort(num, num+n);

    for(int i=0; i+k-1<n; i++) {
        int diff = num[i+k-1] - num[i];
        if (diff < mindiff)
            mindiff = diff;
    }

    cout << mindiff;

}


Measured memory_bytes: 640
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

MOD = 1000000007

def smax(a,b):
    if a>b:
        return a
    else:
        return b

def smin(a,b):
    if a<b:
        return a
    else:
        return b

def main():
    N = int(readline())
    A = list(map(int,readline().split()))
    if N%2==0:
        A.append(0)
        DP = [[[-10**27]*2 for j in range(2)] for i in range(N+2)]
        DP[0][0][0] = 0
        for i in range(N+1):
            DP[i+1][0][0] = DP[i][0][1]
            DP[i+1][1][0] = smax(DP[i][0][0],DP[i][1][1])
            DP[i+1][0][1] = DP[i][0][0]+A[i]
            DP[i+1][1][1] = DP[i][1][0]+A[i]
            #print(DP[i+1][1][0])
        print(DP[N+1][1][0])

    else:
        A.append(0)
        DP = [[[-10**27]*2 for j in range(3)] for i in range(N+2)]
        DP[0][0][0] = 0
        for i in range(N+1):
            DP[i+1][0][0] = DP[i][0][1]
            DP[i+1][1][0] = smax(DP[i][0][0],DP[i][1][1])
            DP[i+1][2][0] = smax(DP[i][1][0],DP[i][2][1])
            DP[i+1][0][1] = DP[i][0][0]+A[i]
            DP[i+1][1][1] = DP[i][1][0]+A[i]
            DP[i+1][2][1] = DP[i][2][0]+A[i]
            #print(DP[i+1][1][0])
        print(DP[N+1][2][0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 189496
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
	
    int a[5]  ;    
    cin >> a[0] >> a[1] >>a[2] >> a[3] >> a[4]  ;

    int ans = 1000100 ;
    int ind[5] = {0,1,2,3,4} ;
    do{
        int tmp = 0 ;
        for(int i=0; i<5; i++){
            while(tmp%10!=0) tmp+=1 ;
            tmp += a[ind[i]] ;
        }
        ans = (ans<tmp) ? ans : tmp ;
    }while(next_permutation(ind,ind+5));

    cout << ans << endl;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define LL long long

int n;
LL a[100005];

bool cmp(LL a, LL b)
{
    return a > b;
}

int main()
{
    while(~scanf("%d", &n))
    {
        map<LL, LL> mapp;
        vector<LL> vec;
        map<LL, LL> vis;
        for(int i = 1; i <= n; ++i)
        {
            scanf("%lld", &a[i]);
            mapp[a[i]]++;
            if(mapp[a[i]] >= 2 && vis[a[i]] == 0)
            {
                vec.push_back(a[i]);
                vis[a[i]] = 1;
            }
            if(mapp[a[i]] == 4)
            {
                vec.push_back(a[i]);
                mapp[a[i]]++;
            }
        }
        int len = vec.size();
        if(len < 2)
        {
            printf("0\n");
            continue;
        }
        sort(vec.begin(), vec.end(), cmp);
        cout << vec[0] * vec[1] << endl;
    }
}


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

int main(void){
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i,n){
        cin >> p[i];
        p[i]++;
    }
    ll sum = accumulate(p.begin(),p.begin()+k,0LL);
    ll m = sum;
    for(int i=0;i<n-k;i++){
        sum = sum - p[i] + p[i+k];
        m = max(m,sum);
    }
    cout << fixed << setprecision(10);
    cout <<  m/2. << endl;
}


Measured memory_bytes: 1792
from math import ceil
N = int(input())

nodes, edges = 0, 0
nodes = sum([i * (N - i + 1) for i in range(1, N + 1)])

for i in range(N - 1):
    u, v = map(int, input().split())
    u, v = min(u, v), max(u, v)
    edges += u * (N - v + 1)

print(nodes - edges)


Measured memory_bytes: 17068
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
void writeln(int x) {
	int s = 0; char f[10];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) reader(&a[i]), reader(&b[i]);
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) z[a[i]].push_back(make_pair(b[i], d[i]));
		if (dist[b[i]] > dist[a[i]]) z[b[i]].push_back(make_pair(a[i], d[i]));
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 23288
package main

import (
	"fmt"
	"os"
)

func main() {
	var n, k int

	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	fmt.Fscan(fp, &n, &k)

	aList := make([]int, n)
	dp := make([]int, k+1)

	for i := 0; i < n; i++ {
		fmt.Fscan(fp, &aList[i])
	}

	for j := 1; j <= k; j++ {
		for i := 0; i < n && aList[i] <= j; i++ {
			if dp[j-aList[i]] == 0 {
				dp[j] = 1
				break
			}
		}
	}

	if dp[k] == 1 {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}

}

Measured memory_bytes: 1280
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = []
m = []
for i in range(N):
    l.append(stdin.readline().rstrip().split())
    l[i].pop(0)
k = l[N-1]
for i in range(N-1):
    k = set(k)&set(l[i])
print(len(k))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<vector>
#include<queue>
#define N 500010
using namespace std;
typedef long long ll;
ll a[N];
ll b[N];
int main()
{
    ll n;
    cin>>n;
    for (ll i=1;i<=n;i++)
       cin>>a[i];
    for (ll i=1;i<=n;i++)
       cin>>b[i];
       ll ans=0;
    for (ll i=1;i<=n;i++)
      {
          if (a[i]>b[i])
               ans-=(a[i]-b[i]);
          else
              ans+=(b[i]-a[i])/2;;
      }
      if (ans>=0)
         cout << "Yes" << endl;
    else
         cout << "No" << endl;
    return 0;
}
/*#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<stack>
#include<map>
#include<vector>
#include<queue>
#define N 500010
using namespace std;
typedef long long ll;
int father[100],Rank[100];
int a[100],b[100];

int Find(int x)   //查找
{
   while (father[x]!=x)
    x=father[x];
   return x;
}
void Union (int x,int y) //合并
{
    int fx,fy;
    fx=Find(x);
    fy=Find(y);
    if (fx!=fy)        //如果x,y不在一个集合里面就合并
        father[fx]=fy;
}
int main()
{
  int n,m,x,w,v;
  cin>>n>>m;
  for (int i=1;i<=n;i++)
    {
        cin>>x;
        father[i]=x;
    }
    for (int i=1;i<=m;i++)
     {
         cin>>w>>v;
         Union(w+1,v+1);
     }
     for (int i=1;i<=n;i++)
     {

     }
    return 0;
}
*/


Measured memory_bytes: 2432
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
//#define int long long
//template
typedef pair<int,int> P;
//main
signed main(){
  int K;cin>>K;
  std::vector<P> e[K];
  for(int i=0;i<K;i++){
    e[i].push_back(P((i+1)%K,1));
    e[i].push_back(P(i*10%K,0));
  }
  std::vector<int> d(K,INF);
  d[1]=0;
  deque<int> que;
  que.push_front(1);
  while(que.size()){
    int p=que.front();que.pop_front();
    for(P q:e[p]){
      if(d[q.first]>d[p]+q.second){
        d[q.first]=d[p]+q.second;
        if(q.second)que.push_back(q.first);
        else que.push_front(q.first);
      }
    }
  }
  cout<<d[0]+1<<endl;
}


Measured memory_bytes: 6272
function main()
    MOD = 1000000007
    s = chomp(readline())
    n = length(s)
    ans = 0
    a,b,c,z = zeros(Int, (n+1,)),zeros(Int, (n+1,)),zeros(Int, (n+1,)),zeros(Int, (n+1,))
    t = zeros(Int, (n+1,))
    t[1] = 1
    for i in 2:n+1
        t[i] = t[i-1]*3%MOD
    end
    for i in 1:n
        a[i+1], b[i+1], c[i+1], z[i+1] = a[i], b[i], c[i], z[i]
        if s[i] == 'A'
            a[i+1] += 1
        elseif s[i] == 'B'
            b[i+1] += 1
        elseif s[i] == 'C'
            c[i+1] += 1
        else
            z[i+1] += 1
        end
    end
    for i in 1:n
        if s[i] == 'B'
            ans = (ans + a[i]*(c[n+1]-c[i+1])%MOD*t[z[n+1]+1]%MOD)%MOD
            ans = (ans + (z[i]*(c[n+1]-c[i+1])+a[i]*(z[n+1]-z[i+1]))%MOD*t[max(1,z[n+1])]%MOD)%MOD
            ans = (ans + z[i]*(z[n+1]-z[i+1])%MOD*t[max(1,z[n+1]-1)]%MOD)%MOD
        elseif s[i] == '?'
            ans = (ans + a[i]*(c[n+1]-c[i+1])%MOD*t[max(1,z[n+1])]%MOD)%MOD
            ans = (ans + (z[i]*(c[n+1]-c[i+1])+a[i]*(z[n+1]-z[i+1]))%MOD*t[max(1,z[n+1]-1)]%MOD)%MOD
            ans = (ans + z[i]*(z[n+1]-z[i+1])%MOD*t[max(1,z[n+1]-2)]%MOD)%MOD
        end
    end
    print("$ans\n")
end

main()


Measured memory_bytes: 157004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*右端が小さいものから見ていって、これまでの区間と被りが無ければ
取る
*/

int main() {
 ll N;
 cin >> N;
 vector<ll> X(N);
 vector<ll> L(N);
 vector<pair<ll,ll>> p(N);
 rep(i,N){
     cin >> X[i];
     cin >> L[i];
 }
 rep(i,N){
     p[i].first = X[i]+L[i];//右端
     p[i].second = X[i]-L[i];//左端
 }
 sort(p.begin(),p.end());

 ll ans = 1;
 ll rb = p[0].first;//右端
 ll lb = p[0].second;//左端
 for(int i = 1;i<N;i++){
     if(p[i].second >= rb){//被りが無ければ右端と左端を更新
         ans++;
         rb = p[i].first;
         lb = p[i].second;
     }
 }
 cout << ans << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <vector>

inline int read()
{
	int data = 0, w = 1; char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(2e5 + 10), INF(1e9);
int n, p[N], val[N], cnt[N]; char s[N];
struct
{
	int max[N << 2];
	void build(int x = 1, int l = 1, int r = n)
	{
		max[x] = -INF; if (l == r) return;
		int mid = (l + r) >> 1, ls = x << 1, rs = ls | 1;
		build(ls, l, mid), build(rs, mid + 1, r);
	}

	void Modify(int p, int v, int x = 1, int l = 1, int r = n)
	{
		if (l == r) return (void) (max[x] = v);
		int mid = (l + r) >> 1, ls = x << 1, rs = ls | 1;
		if (p <= mid) Modify(p, v, ls, l, mid);
		else Modify(p, v, rs, mid + 1, r);
		max[x] = std::max(max[ls], max[rs]);
	}

	int Max(int ql, int qr, int x = 1, int l = 1, int r = n)
	{
		if (ql <= l && r <= qr) return max[x];
		int mid = (l + r) >> 1, ls = x << 1, rs = ls | 1, ans = -INF;
		if (ql <= mid) ans = Max(ql, qr, ls, l, mid);
		if (mid < qr) ans = std::max(ans, Max(ql, qr, rs, mid + 1, r));
		return ans;
	}
} A, B;

int check(int x, int Q)
{
	if (Q < 0) return 0;
	if (Q & 1) return A.Max(x, n) >= Q;
	else return B.Max(x, n) >= Q;
}

int main()
{
	n = read(), A.build();
	for (int i = 1, mx = 0; i <= n; i++)
		if ((p[i] = read()) > mx) mx = p[i], val[i] = 2;
		else val[i] = 1;
	for (int i = n; i; i--)
	{
		int x = A.Max(p[i], n), y = B.Max(p[i], n);
		if (val[i] & 1) B.Modify(p[i], x + val[i]), A.Modify(p[i], y + val[i]);
		else A.Modify(p[i], x + val[i]), B.Modify(p[i], y + val[i]);
	}
	for (int i = n; i; i--) cnt[i] = cnt[i + 1] + (val[i] == 2);
	int cntx = 0, cnty = 0, mxx = 0, mxy = 0;
	for (int i = 1; i <= n; i++)
	{
		A.Modify(p[i], -INF), B.Modify(p[i], 0);
		if (check(mxy, cntx + (p[i] > mxx) + cnt[i + 1] - cnty)
		 || check(std::max(mxx, p[i]), cnty + cnt[i + 1] - cntx - (p[i] > mxx)))
			s[i] = '0', cntx += p[i] > mxx, mxx = std::max(mxx, p[i]);
		else s[i] = '1', cnty += p[i] > mxy, mxy = std::max(mxy, p[i]);
	}
	if (cntx != cnty) puts("-1"); else puts(s + 1);
	return 0;
}


Measured memory_bytes: 8156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int x[] = new int[N];
		int y[] = new int[N];
		int h[] = new int[N];

		for (int i=0; i<N; i++){
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}

		for (int i=0; i<=100; i++){
			for (int j=0; j<=100; j++){
				int H = 0;
				for (int k=0; k<N; k++){
					if (h[k] != 0){
						H = h[k] + Math.abs(i - x[k]) + Math.abs(j - y[k]);
						break;
					}
				}
				boolean flg = true;
				for (int k=0; k<N; k++){
					if (h[k] != Math.max(H- Math.abs(i -x[k]) - Math.abs(j - y[k]),0)){
						flg = false;
						break;
					}
				}
				if (flg){
					System.out.println(i + " " + j + " " + H);
					return;
				}
			}
		}

	}
}

Measured memory_bytes: 23508
<?php
  
$x = trim(fgets(STDIN));
$k = trim(fgets(STDIN));
[$r, $g, $b] = explode(' ', $x);

$count = function($a, $b) {
  if ($a < $b) return 0;
  return floor(log($a / $b, 2)) + 1;
};

$c1 = $count($r, $g);
$g *= pow(2, $c1);
$c2 = $count($g, $b);
echo $c1 + $c2 <= $k ? 'Yes' : 'No';

Measured memory_bytes: 16412
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


N, W = inpl()
VW = [inpl() for _ in range(N)]

dp = [0] * (W + 1)

for w in range(W + 1):
    for i in range(N):
        if w < VW[i][1]:
            continue

        dp[w] = max(dp[w], dp[w - VW[i][1]] + VW[i][0])

# print(dp[N])
print(dp[W])



Measured memory_bytes: 5924
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int n, m;
	while(cin >> n >> m) {
		vi ans;
		//(1 - 1 / n / 2) m
		if(n == 2) {
			ans.push_back(0);
			ans.push_back(m);
		}else {
			rep(i, (n - 1) / 2) {
				ans.push_back(0);
			}
			rep(i, (n + 2) / 2) {
				ans.push_back(m);
			}
		}
		rep(i, ans.size()) {
			if(i != 0) putchar(' ');
			printf("%d", ans[i]);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1200
//abc078_d.cpp
//Thu Mar  1 21:21:32 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

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

	int a[n];

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

	if (n==1){
		cout << abs(a[n-1]-w) << endl;
	}else {
		if (abs(a[n-1]-w)>abs(a[n-1]-a[n-2])){
			cout << abs(a[n-1]-w) << endl;
		}else{
			cout << abs(a[n-1]-a[n-2]) << endl;
		}
	}
}

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

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

  int ans=0,x;
  for(int i=0;i<n;i++){
    cin >> x;
    ans += min(x,abs(x-k));
  }
  cout << ans*2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int N;
	cin >> N;
	vector<ll> inputs(N);
	for (int i = 0; i < N; i++) {
		cin >> inputs[i];
	}

	sort(inputs.begin(), inputs.end(), greater<int>());

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) continue;
		if (i == 1) ans += inputs[0];
		else {
			ans += inputs[ i / 2];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;

int main(){
	while (cin >> n){
		int ans;
		n % 39 == 0 ? ans = 39 : ans = n % 39;
		printf("3C%02d\n", ans);
	}
}

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
      fastio;
      int n,k;
      cin>>n>>k;
      int a[n];
      for(int i=0;i<n;i++)
        cin>>a[i];
      sort(a,a+n);
      int ans=0;
      for(int i=0;i<k;i++)
      {
        ans+=a[i];
      }
      cout<<ans<<endl;
    }

Measured memory_bytes: 3644
from collections import Counter
def main():
    n = int(input())
    A = list(map(int, input().split()))
    L = Counter([i + a for i, a in enumerate(A)])
    R = Counter([i - a for i, a in enumerate(A)])
    ans = 0
    for key in R.keys():
        ans += L[key] * R[key]
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61392
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int a,b;
string s;

int main(){
	cin >> a >> b >> s;
	
	REP(i,0,s.size()){
		if(i==a and s[i]!='-'){cout << "No" << endl; return 0;}
		else if(a==i) continue;
		else if(s[i]<'0'||'9'<s[i]){cout << "No" << endl; return 0;}
	}
	
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	int main()
	{
		long long  a,b,x,n;
		scanf("%lld %lld %lld" ,&a,&b,&x);
		n=(b/x) - (a/x);
	    if(a%x == 0)
	    ++n;
	    printf("%lld\n",n);
	}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		 BufferedReader br = new BufferedReader(new
		 InputStreamReader(System.in));
		 int num = Integer.parseInt(br.readLine());
		 System.out.println(num * num * num);
		 }

}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  string t;
  t = s.substr(0,n/2);
  if(s==t+t){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000
#define N5 100007
#define ll long long int
int N;

ll w[N5],v[N5],dp[101][N5];

int main()
{
	set<int> A;
	cin >>N;
	REP(i,N){
		int a;
		cin >> a;
		if(A.count(a) == 1){
			cout << "NO";
			return 0;
		}else{
			A.insert(a);
		}
	}
	cout << "YES";


}





Measured memory_bytes: 9600
#include <cstdio>  
#include <cstring>  
#include <iostream>  
#include <algorithm>  
#define N 501000  
using namespace std;  
struct KSD  
{  
    int v,next;  
}e[N<<1];  
int head[N],cnt;  
inline void add(int u,int v)  
{  
    e[++cnt].v=v;  
    e[cnt].next=head[u];  
    head[u]=cnt;  
}  
int n;  
int sg[N];  
void dfs(int x,int p)  
{  
    int i,v;  
    sg[x]=0;  
    for(i=head[x];i;i=e[i].next)  
    {  
        v=e[i].v;  
        if(v==p)continue;  
        dfs(v,x);  
        sg[x]^=(sg[v]+1);  
    }  
}  
int main()  
{  
    int i,j,T;  
    int a,b;  
   // for(scanf("%d",&T);T--;)  
    //{  
        cnt=1;  
        memset(head,0,sizeof(head));  
        scanf("%d",&n);  
        for(i=1;i<n;i++)  
        {  
            scanf("%d%d",&a,&b);  
            add(a,b),add(b,a);  
        }  
        dfs(1,0);  
        if(sg[1])puts("Alice");  
        else puts("Bob");  
  //  }  
    return 0;  
}  

Measured memory_bytes: 9472
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, w, h;
    cin >> n >> w >> h;
    vector<int> v(w+1), u(h+1);
    for (int i = 0; i < n; ++i) {
        int x, y, p;
        scanf("%d%d%d", &x, &y, &p);
        v[max(0, x-p)]++; v[min(w, x+p)]--;
        u[max(0, y-p)]++; u[min(h, y+p)]--;
    }
    int ok = 1;
    for (int i = 0; i < w; ++i) {
        v[i+1] += v[i];
        if(v[i] == 0) {
            ok = 0;
        }
    }
    if(ok){
        puts("Yes");
        return 0;
    }
    ok = 1;
    for (int i = 0; i < h; ++i) {
        u[i+1] += u[i];
        if(u[i] == 0) {
            ok = 0;
        }
    }
    if(ok){
        puts("Yes");
        return 0;
    }
    puts("No");
    return 0;
}


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

int main()
{
	int n, q; cin >> n >> q;
	string s; cin >> s;
	vector<int> l(q), r(q);	for (int i = 0; i < q; i++) cin >> l[i] >> r[i];
		
	vector<int> accum(n + 1, 0); accum[0] = 0;

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

		accum[i] += accum[i - 1];

		if (s.at(i - 1) == 'A') {

			if (s.at(i) == 'C') {
				accum[i]++;
			}
			
		}
		
	}

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

		cout << accum[r[i] - 1] - accum[l[i] - 1] << endl;

	}

	return 0;
}

Measured memory_bytes: 2176
program main
  implicit none
  character(100000) :: s
  character(50000) :: odd
  integer :: i, j
  read(*, *) s
  do i = 1, len(s), 2
    j = (i + 1) / 2
    odd(j:j) = s(i:i)
  end do
  write(*, "(a)") trim(odd)
end program main


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

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

int main () {
    while(1) {
        int n, m;
        cin >> n >> m;
        if (n == 0) break;
        vector<P> v;
        for (int i = 0; i < n; ++i) {
            int d, p;
            cin >> d >> p;
            v.push_back(P(p, d));
        }

        sort(v.begin(), v.end(), greater<P>()); 
        for (P& pd : v) {
            if (pd.second <= m) {
                m -= pd.second;
                pd.second = 0;
            } else {
                pd.second -= m;
                m = 0;
                break;
            }
        }


        int ans = 0;
        for (P pd : v) {
            ans += pd.first * pd.second;
        }
        cout << ans << endl;
    }
}


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

int main(){
	ll n, a, b;
	cin >> n >> a >> b;
	ll s = (n / (a + b) * a);
	n = n % (a + b);
	if(n <= a) s += n;
	else s += a;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int a[] = new int[3];
		for(int i = 0; i < 3; i++) a[i] = sc.nextInt();
		int max = -1;
		int idx = 0;
		for(int i = 0; i < 3; i++) {
			if(max < a[i]) {
				max = a[i];
				idx = i;
			}
		}
		a[idx] *= 10;
		int sum = 0;
		for(int i = 0; i < 3; i++) {
			sum += a[i];
		}
		System.out.println(sum);
	}
	Main(){doIt();}
	public static void main(String[] args) {
		new Main();
	}

}


Measured memory_bytes: 21844
import sys
inf = sys.maxsize // 2
n,k = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
#print(h)
ans = inf
for i in range(n - k + 1):
    #print(i, i+k)
    tmp = h[i+k-1] - h[i]
    ans = min(ans, tmp)
print(ans)


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

int main(){

    int table[13];
    table[1]=table[3]=table[5]=table[7]=table[8]=table[10]=table[12]=1;
    table[4]=table[6]=table[9]=table[11]=2;
    table[2]=3;

    int x,y;
    cin>>x>>y;
    cout<<(table[x]==table[y]?"Yes":"No")<<endl;






    return 0;
}

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

int main(){
  vector<vector<int>> vec(3, vector<int>(3));
  vector<int> tmp(3);
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> vec.at(i).at(j);
    }
  }
  bool ans = true;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 3; j++){
      tmp.at(j) = vec.at(i).at(j) -vec.at(i + 1).at(j);
    }
    if(tmp.at(0) != tmp.at(1) || tmp.at(1) != tmp.at(2) || tmp.at(2) != tmp.at(0)){
      ans = false;
    }
  }
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 3; j++){
      tmp.at(j) = vec.at(j).at(i) -vec.at(j).at(i + 1);
    }
    if(tmp.at(0) != tmp.at(1) || tmp.at(1) != tmp.at(2) || tmp.at(2) != tmp.at(0)){
      ans = false;
    }
  }
  if (ans){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3612
num_A, num_B, order_K = map(int, raw_input().split())

def get_divisor(num):
  results_divisor = []
  for i in range(1, num + 1):
    if num % i == 0:
      results_divisor.append(i)
  return results_divisor

common_divisor =  list(set(get_divisor(num_A)) &  set(get_divisor(num_B)))
common_divisor.sort(reverse=True)
print common_divisor[order_K - 1]

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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second
#define endl '\n'

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    int n;
    cin >> n;

    map<int,int> mp;
    int a;
    for (int i=0; i<n; ++i) {
        cin >> a;
        mp[a]++;
    }

    int cnt = 0;
    for (auto e:mp) {
        if (e.se%2)
            cnt++;
    }

    cout << cnt << endl;
}}

Measured memory_bytes: 4992
using System;
class Program
 {
   static void Main(string[] args)
   {
     int N;
     N = int.Parse(Console.ReadLine());
     bool f=false;

     for(int i = 0; i < 26 ;i++)
     {
       for(int j = 0; j < 15 ;j++ )
       {
        if(4*i+7*j==N)
        {
          if(!f)
          {
            Console.WriteLine("Yes");
          }
          f = true;
          break;
        } 
       }
     }

     if(!f)
     {
       Console.WriteLine("No");
     }
     
   }
 }

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>

using namespace std;

int Sum10(int n);

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


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        List<Character> frontList=new ArrayList<>();
        List<Character> backList=new ArrayList<>();
        int q=sc.nextInt();
        int fl=0,bl=0;
        boolean direction=true;
        int t=0,f=0;
        char c=0;
        for(int i=0;i<q;i++){
            t=sc.nextInt();
            if(t==1){
                direction=!direction;
            }else{
                f=sc.nextInt();
                c=sc.next().charAt(0);
                if(direction==(f==1)){
                    frontList.add(c);
                    fl++;
                }else{
                    backList.add(c);
                    bl++;
                }
            }
        }
        if(direction){
            for(int i=fl-1;i>=0;i--){
                System.out.print(frontList.get(i));
            }
            System.out.print(str);
            for(int i=0;i<bl;i++){
                System.out.print(backList.get(i));
            }
        }else{
            for(int i=bl-1;i>=0;i--){
                System.out.print(backList.get(i));
            }
            int l=str.length();
            for(int i=l-1;i>=0;i--){
                System.out.print(str.charAt(i));
            }
            for(int i=0;i<fl;i++){
                System.out.print(frontList.get(i));
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 143708
#include<stdio.h>

int H[200005];
int comp( const void *a,const void *b){
	return *(int*)a-*(int*)b;
} 
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	long long i;
	for(i=0;i<n;i++){
		scanf("%d",&H[i]);
	}
	qsort(H,n,sizeof(int),comp);
	long long sum;
	if(k>=n){
		printf("0");
	}
	else{
		sum=0;
		for(i=0;i<n-k;i++){
			sum=sum+(long long)H[i];
		}
			printf("%lld",sum);
	}

	return 0;
}

Measured memory_bytes: 1788
N = int(input())
k = 0

for i in range(0, 26, 1):
  for j in range(0, 16, 1):
    if i * 4 + j * 7 == N:
      print('Yes')
      k = 1
      break
  if k == 1:
    break
else:
  if k != 1:
    print('No')

Measured memory_bytes: 9128
// Date: 2020-05-02

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int main() {
    LL a, b, n;
    cin >> a >> b >> n;
    LL m = min(n, b-1);
    LL ans = a*m/b;
    cout << ans;

    return 0;
}

Measured memory_bytes: 3580
n, m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
  u,v,z=map(int, input().split())
  g[u-1].append((u-1, v-1, z))
  g[v-1].append((v-1,u-1,z))
count = 0
renketu_list = [-1]*n
stack = []
for i in range(n):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      u,v,z=stack.pop()
      if renketu_list[v] == -1:
        renketu_list[v] = count
        while len(g[v])>0:
          stack.append(g[v].pop())

print(count)


Measured memory_bytes: 43832
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int   
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

int const mod = 1e9+7;
// int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = (res*a)%m;
            res %= m;
        }
        a=(a*a)%m;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x,int m){
    return power(x,m-2,m);
}

int const N = 2e6+55;
int const inf = 1e18;
ld pi = 3.14159265359;


void solve(){   
    int i,j,l;
    int n;
    cin >> n;
    vector<int> a(n);
    int xr = 0;
    for(auto &x:a){
        cin >> x;
        xr ^= x;
    }

    for(auto x:a){
        cout << (xr^x) << " ";
    }
}           


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){   
        // cout << "Case #"<<tt<<": ";
        solve();
    }
    return 0;
}


/*



*/

Measured memory_bytes: 4772
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    long X=sc.nextLong();
    int count=0;
    int N=100;
    double money=N;
    while (money<X) {
    	money=money*1.01;
    	money=Math.floor(money);
    	count++;
    }
    System.out.println(count);
    }}

Measured memory_bytes: 35736
/*
Author : N_o_o_B
Created : January 12 2020 11:59:02 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    fori(i,n-2){
        string foo = "";
        for(int j=i;j<=i+2;j++){
            foo += s[j];
        }
        if(foo == "ABC") ans++;
    }
    cout << ans << endl;



    time_taken();
    return 0;
}

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

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

// code starts
int main()
{
	int n,x,t;
	cin >> n >> x >> t;
	int sets = (n+x-1)/x;
	cout << sets*t << endl;
}


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

#define pb push_back
#define fi first
#define se second


using namespace std;


int main()
{
	int n;

	cin>>n;

	string frase;

	cin >> frase;


	int nr = 0,nw = 0;

	for (int i = 0; i < n; ++i)
	{
		if(frase[i] == 'R')
			nr++;
		if(frase[i] == 'W')
			nw++;
	}

	int nwe = 0;
	for (int i = 0; i < nr; ++i)
	{
		if(frase[i] == 'W')
			nwe++;
	}

	cout << nwe << endl;

	return 0;
}


Measured memory_bytes: 3704