akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 2e5;
int visit[N] , color[N];
std::vector<int> v[N];
bool cycle = false;
int cnt = 0;
void dfs(int src , int col){
  visit[src] = 0;
  color[src] = col;
  cnt++;
  cout << src << " ";
  for(auto x : v[src]){
    if(visit[x] == -1){
      dfs(x , col^1);
    }else if(visit[x] == 0){
      continue;
    }else cycle = true;
  }
  visit[src] = 1;
}

int32_t main(){
 L_T_S_K;
  int a , b  ,k;
  cin >> a >> b >> k;
  int ans = k - a;
  int t = a;
  a-=k;
  if(ans > 0){
    k-=t;
    b-=k;
  }
  cout << max(0ll , a) << " " << max(0ll , b) << endl; 
  return 0;
}

Measured memory_bytes: 6400
S = gets.chomp.chars
ans = S.map{0}
sum = [0, 0]
start_pos = 0
for i in 0..S.length-1
    if i > 0
        if S[i-1] == "R" && S[i] == "L"
            pos = i-1
        elsif S[i-1] == "L" && S[i] == "R"
            ans[pos] = sum[(pos + 1 - start_pos) % 2]
            ans[pos + 1] = sum[(pos - start_pos) % 2]
            sum = [0, 0]
            start_pos = i
        end
    end
    sum[(i - start_pos + 1) % 2] += 1
end
ans[pos] = sum[(pos + 1 - start_pos) % 2]
ans[pos + 1] = sum[(pos - start_pos) % 2]
puts ans.join(" ")

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

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

    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    double ans = 0;
    rep(i, 0, n) {
        double a;
        cin >> a;
        ans += 1 / a;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

int main() {
	lint N, K;
	cin >> N >> K;
	vector<lint>S(N);
	rep(i, K) {
		lint D;
		cin >> D;
		vector<lint>A(D);
		rep(i, D) {
			cin >> A[i];
			S[A[i] - 1]++;
		}
	}
	lint cnt = 0;
	rep(i, N) {
		if (S[i] == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3536
loop do
  n, x = gets.split(" ").map(&:to_i)
    exit if n == 0 and x == 0
  count = 0

  for i in 1..n
    for j in (i + 1)..n
      for k in (j + 1)..n
        count += 1 if i + j + k == x
      end
    end
  end

  puts count
end

Measured memory_bytes: 6104
a, b, k = map(int, input().split())

ak = [i for i in range(a, min(b + 1, a + k))]
bk = [i for i in range(max(a, b - k + 1), b + 1)]

abk = list(set(ak) | set(bk))
abk.sort()

for i in abk:
    print(i)


Measured memory_bytes: 3060
INF = 10 ** 20
n = int(input())
edges = [list(map(int, input().split())) for _ in range(n)]
dist = [[INF] * n for _ in range(n)]

edgeList = []
for i in range(n):
    for j in range(i, n):
        edgeList.append((edges[i][j], i, j))
edgeList.sort()

for k in range(n):
    edgesk = edges[k]
    for i in range(n):
        disti = dist[i]
        edgesik = edges[i][k]
        for j in range(n):
            if disti[j] > edgesik + edgesk[j]:
                disti[j] = edgesik + edgesk[j]

ans = 0
for c, i, j in edgeList:
    minCost = INF
    for k in range(n):
        if k in (i, j):continue
        if minCost > dist[i][k] + dist[k][j]:
            minCost = dist[i][k] + dist[k][j]
    if c > minCost:
        print(-1)
        break
    if c < minCost:
        ans += c
else:
    print(ans)

Measured memory_bytes: 62688
#include <stdio.h>
#include <stdlib.h>
#include <math.h>








int N,i,j,x,g,c,y,z; 
int W[100];



int main(){



scanf("%d", &N);

for (i=0;i < N;i++){ 
    scanf("%d",&W[i]); 
}


g=0;

for (i=0;i < N;i++){ 
   g=g+W[i];    
   
}

c=0;
y=g;
x=g;

for (i=0;i < N;i++){ 
   c=c+W[i];
   
   y=abs((g-c)-c);
   
   if(y < x){
   
     x=y;
   }    
   
}








 


printf("%d",x);

 






//if(str[2]=='a'){printf("yes");}

//printf("%d",x);

   return(0);
} 






Measured memory_bytes: 128
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    static final int INF = 50000000;
    static final int NINF = -50000000;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int N = sc.ni();
        int[][] edges = new int[N-1][2];
        for (int i = 0; i < N-1; i++) {
        	edges[i][0] = sc.ni();
        	edges[i][1] = sc.ni();
        	Arrays.sort(edges[i]);
        }
        edges = sort(edges);
        int e = 0;
        long sub = 0;
        long tri = 0;
        long ans = 0;
        for (int i = 1; i <= N; i++) {
        	while (e < N-1 && edges[e][1]<=i) {
        		sub += edges[e][0];
        		e++;
        	}
        	tri += i;
        	ans += (tri-sub);
        }
        pw.println(ans);
        pw.close();
    }

    public static int[][] sort(int[][] arr) {
    	//Sort an array (immune to quicksort TLE)
    	Random rgen = new Random();
    	for (int i = 0; i < arr.length; i++) {
    		int randomPosition = rgen.nextInt(arr.length);
    		int[] temp = arr[i];
    		arr[i] = arr[randomPosition];
    		arr[randomPosition] = temp;
    	}
    	Arrays.sort(arr, new Comparator<int[]>() {
    		@Override
    		public int compare(int[] arr1, int[] arr2) {
    			return arr1[1]-arr2[1];
    			//Ascending order.
    		}
    	});
    	return arr;
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 62040
use strict;
use warnings;
package FenwickTree;
sub new{
	return bless[(0)x$_[1]],$_[0];
}
sub add{
	my$self=shift;
	my($p,$x)=@_;
	$p++;
	while($p<=@{$self}){
		$self->[$p-1]+=$x;
		$p+=$p&-$p;
	}
}
sub sum{
	my$self=shift;
	return$self->prefixsum($_[1])-$self->prefixsum($_[0]);
}
sub prefixsum{
	my$self=shift;
	my$r=shift;
	my$s=0;
	while($r>0){
		$s+=$self->[$r-1];
		$r-=$r&-$r;
	}
	return$s;
}
package main;
my($N,$Q)=split$",<>;
my$fenwicktree=FenwickTree->new($N);
my@a=split$",<>;
for my$i(0..$#a){
	$fenwicktree->add($i,$a[$i]);
}
for(1..$Q){
	my($t,$a,$b)=split$",<>;
	if($t==0){
		$fenwicktree->add($a,$b);
	}
	else{
		print$fenwicktree->sum($a,$b),$/;
	}
}


Measured memory_bytes: 69068
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M, L;
int dp[1 << 16][2];

signed main() {
    while(cin >> N, N) {
        memset(dp, -1, sizeof(dp));
        dp[0][0] = 0;

        int ans = 0;
        rep(p,0,N) {
            int mo = p%2, info = 0;
            cin >> M >> L;
            rep(i,0,M) {
                int S, E; cin >> S >> E;
                S -= 6, E -= 6;

                int val = 0;
                rep(j,S,E) val += (1 << j);
                info += val;
            }

            rep(bit,0,1<<16) {
                chmax(dp[bit][mo^1], dp[bit][mo]);
                if(bit & info) continue;
                if(dp[bit][mo] == -1) continue;
                chmax(dp[bit | info][mo^1], dp[bit][mo] + L);
                dp[bit][mo] = -1;
            }
        }
        rep(i,0,1<<16) chmax(ans, dp[i][N%2]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_; \
__VA_ARGS__;--c_;if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define flg() __LINE__, __PRETTY_FUNCTION__
#define mkp(...) make_pair(__VA_ARGS__)
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__, __VA_ARGS__)
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template< typename t > using V = vector< t >;
template< typename t > void print(ostream& os, const t& a){os<<a<<'\n';}
template< typename t, typename... v > void print(ostream& os, const t& a, 
v&&... b){os << a << ' '; print(os, b...);}

int a, b;

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

    cin >> a >> b;

    if (b >= 0 and a <= 0)
        return prt("Zero"), 0;

    if (b >= 0) 
        b = -1;

    int dl = b - a + 1;

    dl = max(dl, 0);

    prt(dl % 2? "Negative" : "Positive");
}

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

int main(){

	int map[14][14] = {0};
	int x, y, size, m, cnt;
	char cnm;
	
	while(cin >> x >> cnm >> y >> cnm >> size){
		x += 2;
		y += 2;
		switch(size){
			case 3: map[y-2][x]++;
							map[y][x-2]++;
							map[y][x+2]++;
							map[y+2][x]++;
			case 2: map[y-1][x-1]++;
							map[y-1][x+1]++;
							map[y+1][x-1]++;
							map[y+1][x+1]++;
			case 1: map[y][x]++;
							map[y-1][x]++;
							map[y][x-1]++;
							map[y][x+1]++;
							map[y+1][x]++;
							break;
		}
	}
	
	cnt = 0;
	m = 0;
	for(int i=2; i<12; i++){
		for(int j=2; j<12; j++){
			if(map[i][j] == 0) cnt++;
			m = max(m, map[i][j]);
		}
	}
	
	cout << cnt << endl << m << endl;

	return 0;

}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    long[][] A = new long[3][3];
    for(int i=0; i<3; i++) {
      for(int j=0; j<3; j++) {
        A[i][j] = scan.nextInt();
      }
    }
    int N = scan.nextInt();
    long[] b = new long[N];
    for(int k=0; k<N; k++) {
      b[k] = scan.nextInt();
    }
    scan.close();

    int[] Bi = new int[3];
    int[] Bj = new int[3];
    int lt = 0;
    int rt = 0;
    for(int k=0; k<N; k++) {
      for(int i=0; i<3; i++) {
        for(int j=0; j<3; j++) {
          if(b[k] == A[i][j]) {
            Bi[i]++;
            if(Bi[i] == 3) {
              System.out.println("Yes");
              return;
            }

            Bj[j]++;
            if(Bj[j] == 3) {
              System.out.println("Yes");
              return;
            }

            if(i == j) {
              lt++;
            }
            if(lt == 3) {
              System.out.println("Yes");
              return;
            }

            if(i + j == 2) {
              rt++;
            }
            if(rt == 3) {
              System.out.println("Yes");
              return;
            }
          }
        }
      }
    }

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

Measured memory_bytes: 25300
import heapq

N = int(input())
A = list(map(int, input().split()))
 
L = A[:N]
heapq.heapify(L) 

sum_L = [0] * (N+1)
sum_L[0] = sum(L)

for i in range(N):
    min_L = heapq.heappushpop(L, A[N+i])
    sum_L[i+1] = sum_L[i] + A[N+i] - min_L
    #print(L, i, A[N+i], min_L, sum_L)

R = A[N*2:]
rev_R = list(map(lambda x: x*(-1), R))
heapq.heapify(rev_R) 

sum_R = [0] * (N+1)
sum_R[N] = sum(R)

for i in range(N-1, -1, -1):
    max_R = heapq.heappushpop( rev_R, A[N+i]*(-1) ) * (-1)
    sum_R[i] = sum_R[i+1] + A[N+i] - max_R
    # print(rev_R, i, A[N+i], max_R, sum_R)

ans = -10**14

for i in range(N+1):
    ans = max(ans, sum_L[i] - sum_R[i])

print(ans)

Measured memory_bytes: 122512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n, m, x;
  cin >> n >> m >> x;
  vi a(m);
  rep(i,m) cin >> a[i];
  int sl = 0, sr = 0;
  for (int i = x; i <= n; ++i) {
    rep(j,m) {
      if (i == a[j]) sr++;
    }
  }
  for (int i = x; i >= 0; --i) {
    rep(j,m) {
      if (i == a[j]) sl++;
    }
  }
  int ans = min(sl, sr);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
q = ni()
h = 0

from collections import deque
ss=deque(list(s))

for i in range(q):
  que = nn()
  if int(que[0]) == 1:
    h += 1
  else:
    b = int(que[1])
    c = que[2]
    if (h+b)%2 == 0:
      ss.append(c)
    else:
      ss.appendleft(c)

ss = list(ss)

if h%2 == 1:
  ss = reversed(ss)

print(''.join(ss))

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

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << endl;

    return 0;
}

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

int main() {

    int N; cin >> N;
    string S; cin >> S;
    bool flag = true;

    // Nが奇数のときは必ず'NO'
    if (N % 2 == 1) flag = false;
    else {
        for (int i=0; i<N/2; i++) {
            if (S.at(i) != S.at(i + N/2)) {
                flag = false;
                break;
            }
        }
    }
    
    if (flag) cout << "Yes" << endl;
    else cout << "No" << 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;

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

    ll tot = 0;
    rep(i,m) {
        int a;
        cin >> a;
        tot += a;
    }

    if (n>=tot) cout << n-tot << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 3636
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}

int main(void){
    int i,j,n,m,t,k,a,b,r=0,l,x;
    double d;
    char s[262144];
    scanf("%d%d%d",&x,&a,&b);
    //l=strlen(s);
    //for(i=1;i<=n;i++){scanf("%d",&a[i]);}
    x-=a;
    x%=b;
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <list>
#include <queue>
#include <vector>
using namespace std;
 
const long MAX=100000;
 
vector<int> G[MAX];
list<int> ou;
bool V[MAX];
int N;
int indeg[MAX];
 
void bfs(int s){
    queue<int> que;
    que.push(s);
    V[s]=true; //?¨???????
     
    while( !que.empty() ){
        int u=que.front();
        que.pop();
        ou.push_back(u); //????????¨????????????????????????
         
        for(int i=0; i<G[u].size(); ++i){
            int v=G[u][i]; //u?????????????????????????????????????????????
            indeg[v]--; //????¬???°???????????????
             
            if(indeg[v]==0 && !V[v]){
                V[v]=true;
                que.push(v);    
            }
        }
    }       
}
 
//topological sort
void tsort(){
    for(int i=0; i<N; ++i) indeg[i]=0;
     
    for(int i=0; i<N; ++i){
        for(int j=0; j<G[i].size(); ++j){
            int k=G[i][j];
            indeg[k]++;
        }
    }
     
    for(int i=0; i<N; ++i){
        if(indeg[i]==0 && !V[i]) bfs(i);    
    }
     
    for(list<int>::iterator it=ou.begin(); it!=ou.end(); ++it){
        cout << *it << endl;    
    }
}
 
int main(){
    long M;
    scanf(" %d %ld", &N, &M);
     
    for(int i=0; i<N; ++i) V[i]=false;
     
    for(long i=0; i<M; ++i){
        int s, t;
        scanf(" %d %d", &s, &t);
        G[s].push_back(t); //??????????????????     
    }   
     
    tsort();
}


Measured memory_bytes: 6244
#include <iostream>
#include <algorithm>
#include <list>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

int main(){
    int n, m, x, sum1=0, sum2=0;
    cin >> n >> m >> x;

    int a[n+1];

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

    for(int i=0; i<m; i++){
        int b;
        cin >> b;
        a[b] = 1;
    }
    
    for(int i=x; i<=n; i++){
        sum1 += a[i];
    }

    for(int i=x; i>=0; i--){
        sum2 += a[i];
    }

    cout << min(sum1, sum2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
bool vh[1000005],vw[1000005];
int bh[1000005],bw[1000005];
int nh[1000005],nw[1000005];
int h,w,n,x[31],y[31],c1=0,c2=0;
int kh[105],kw[105],wgt[65][65];
int dis[65][65],que[10005][2],l=1,r=0;
bool ban[65][65];
inline int mul(int a,int b)
{return 1ll*a*b%mod;}
inline int sub(int a,int b)
{return (a-b<0?a-b+mod:a-b);}
inline bool ok(int a,int b)
{if (a<=0||a>c1||b<=0||b>c2||ban[a][b]) return 0;
return 1;
}
int main (){
	int i,j,k,l,ans=0;
	scanf ("%d%d%d",&h,&w,&n);
	for (i=1;i<=n;i++)
	{scanf ("%d%d",&x[i],&y[i]);
	x[i]++;y[i]++;
	nh[x[i]]++;nw[y[i]]++;
	vh[x[i]]=vw[y[i]]=1;
	}
	bh[1]=++c1;kh[1]++;
	int lo=0,tot=mul(h,w)-n;
	if (tot<0) tot+=mod;
	for (i=2;i<=h;i++)
	{lo+=(w-nh[i-1]);
	if (lo>=mod) lo-=mod;
	if ((!vh[i-1])&&(!vh[i]))
	{ans+=mul(lo,sub(tot,lo));
	if (ans>=mod) ans-=mod;
	bh[i]=bh[i-1];kh[c1]++;
	}
	else {bh[i]=++c1;kh[c1]=1;}
	}
	bw[1]=++c2;kw[1]++;
	lo=0;tot=mul(h,w)-n;
	if (tot<0) tot+=mod;
	for (i=2;i<=w;i++)
	{lo+=(h-nw[i-1]);
	if (lo>=mod) lo-=mod;
	if ((!vw[i-1])&&(!vw[i]))
	{ans+=mul(lo,sub(tot,lo));
	if (ans>=mod) ans-=mod;
	bw[i]=bw[i-1];kw[c2]++;
	}
	else {bw[i]=++c2;kw[c2]=1;}
	}
	for (i=1;i<=c1;i++)
	{for (j=1;j<=c2;j++)
	{wgt[i][j]=mul(kh[i],kw[j]);}
	}
	for (i=1;i<=n;i++)
	{ban[bh[x[i]]][bw[y[i]]]=1;}
	ans*=2;
	if (ans>=mod) ans-=mod;
	for (i=1;i<=c1;i++)
	{for (j=1;j<=c2;j++)
	{if (ban[i][j]) continue;
	l=1;r=0;que[++r][0]=i;que[r][1]=j;
	memset (dis,0x7f,sizeof(dis));
	dis[i][j]=0;
	while (l<=r)
	{int a=que[l][0],b=que[l][1];l++;
	if (ok(a-1,b)&&dis[a-1][b]>dis[a][b]+1)
	{dis[a-1][b]=dis[a][b]+1;
	que[++r][0]=a-1;que[r][1]=b;
	}
	if (ok(a+1,b)&&dis[a+1][b]>dis[a][b]+1)
	{dis[a+1][b]=dis[a][b]+1;
	que[++r][0]=a+1;que[r][1]=b;
	}
	if (ok(a-1,b)&&dis[a-1][b]>dis[a][b]+1)
	{dis[a-1][b]=dis[a][b]+1;
	que[++r][0]=a-1;que[r][1]=b;
	}
	if (ok(a,b-1)&&dis[a][b-1]>dis[a][b]+1)
	{dis[a][b-1]=dis[a][b]+1;
	que[++r][0]=a;que[r][1]=b-1;
	}
	if (ok(a,b+1)&&dis[a][b+1]>dis[a][b]+1)
	{dis[a][b+1]=dis[a][b]+1;
	que[++r][0]=a;que[r][1]=b+1;
	}
	}
	int tp=0;
	for (k=1;k<=c1;k++)
	{for (l=1;l<=c2;l++)
	{if (ban[k][l]) continue;
	tp+=mul(dis[k][l],wgt[k][l]);
	if (tp>=mod) tp-=mod;
	}
	}
	tp=mul(tp,wgt[i][j]);
	ans+=tp;
	if (ans>=mod) ans-=mod;
	}
	}
	if (ans&1) ans+=mod;
	printf ("%d\n",ans>>1);
	return 0;
}

	
	

Measured memory_bytes: 14848
import Control.Monad
import qualified Data.Map as M

main :: IO()
main = do
    [h,w] <- map read . words <$> getLine
    grid <- replicateM h getLine
    print $ calcAns grid h w
        where
            calcAns grid h w = if step > 0 then whites - step else -1
                where
                    step = dijkstra (toMap grid 1) (h,w)
                    toMap [] _ = M.empty
                    toMap (l:ls) n = toMap ls (n+1) `M.union` M.fromList (map (\(m,s) -> ((n,m),s)) $ zip [1..] l)
                    whites = sum $ map (length . filter (=='.')) grid

dijkstra g gp@(h,w) = dijk [(1,1)] (M.singleton (1,1) 1)
    where
        dijk [] _ = -1
        dijk (p:ps) d = if gp `elem` cont then d M.! p + 1 else dijk ps' d'
            where
                cont = filter (\(i,j) -> i>0 && i<=h && j>0 && j<=w && g M.! (i,j) == '.') (contiguous p)
                contiguous (i,j) = [(i-1,j),(i,j-1),(i+1,j),(i,j+1)]
                (ps',d') = foldr update (ps,d) cont
                    where
                        update p' (ps,d) = if M.member p' d then (ps,d) else (ps++[p'],M.insert p' (d M.! p + 1) d)


Measured memory_bytes: 3324
import java.util.Scanner;


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

		int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int num3 = sc.nextInt();
		int temp; 	//入れ替え用

		if(num2 > num1){
			temp = num1;
			num1 = num2;
			num2 = temp;
		}
		if(num3 > num2){
			temp = num2;
			num2 = num3;
			num3 = temp;
		}
		if(num2 > num1){
			temp = num1;
			num1 = num2;
			num2 = temp;
		}

		temp = Integer.parseInt("" + num1 + num2);
		
		System.out.println(temp + num3);
	}
}

Measured memory_bytes: 22740
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for _ in range(n):
  d = int(input())
  for i in range(3):
    if d in a[i]:
      a[i][a[i].index(d)] = -1

for i in range(3):
  if sum(a[i])==-3:
    print('Yes')
    exit()
  s = 0
  for j in range(3):
    s += a[j][i]
  if s==-3:
    print('Yes')
    exit()
if a[0][0]+a[1][1]+a[2][2]==-3:
  print('Yes')
  exit()
if a[0][2]+a[1][1]+a[2][0]==-3:
  print('Yes')
  exit()

print('No')

Measured memory_bytes: 9156
#include <iostream>

using namespace std;
typedef long long ll;
ll val[3010][3010] = {},dp[3010][3010][4] = {};
int main(){
    int i,j,r,c,k; cin >> r >> c>> k;
    for(i=0;i<k;i++){
        int r1,c1; ll v1; cin >> r1 >> c1 >> v1;
        r1--; c1--; val[r1][c1] = v1; 
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            for(k=0;k<=3;k++) dp[i][j][k] = -1000000000000000;
        }
    }
    dp[0][0][0] = 0; dp[0][0][1] = val[0][0];
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            if(i>0) for(k=0;k<=3;k++) dp[i][j][0] = max(dp[i][j][0],dp[i - 1][j][k]);
            if(i>0) for(k=0;k<=3;k++) dp[i][j][1] = max(dp[i][j][1],dp[i - 1][j][k] + val[i][j]);
        }
        for(j=1;j<c;j++){
            for(k=1;k<=3;k++) dp[i][j][k] = max(dp[i][j][k],dp[i][j - 1][k - 1] + val[i][j]);
            for(k=0;k<=3;k++) dp[i][j][k] = max(dp[i][j][k],dp[i][j - 1][k]); 
        }
    }
    ll ans = 0;
    for(k=0;k<=3;k++) ans = max(ans,dp[r - 1][c - 1][k]);
    cout << ans << endl;
}

Measured memory_bytes: 356284
#include <bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int n;
int main() {
    cin>>n;
    for (int i=1; i<=n; i++) {
        int x; cin>>x;
        if (i&1) a[(i+1)/2]=x;
        else b[i/2]=x;
    }
    sort(a+1,a+1+n/2);
    sort(b+1,b+1+n/2);
    int mx1=0,mx2=0,mx3=0,mx4=0,p1,p2,p3,p4,cnt=1;
    for (int i=2; i<=n/2+1; i++) {
        if (a[i]==a[i-1]) cnt++;
        else {
            if (a[i]==a[i-1]) cnt++;
            else {
                if (cnt>mx1) mx2=mx1,mx1=cnt,p2=p1,p1=a[i-1];
                else if (cnt>mx2) mx2=cnt,p2=a[i-1];
                cnt=1;
            }
        }
    }
    cnt=1;
    for (int i=2; i<=n/2+1; i++) {
        if (b[i]==b[i-1]) cnt++;
        else {
            if (cnt>mx3) mx4=mx3,mx3=cnt,p4=p3,p3=b[i-1];
            else if (cnt>mx4) mx4=cnt,p4=b[i-1];
            cnt=1;
        }
    }
    if (p1!=p3) cout<<n-mx1-mx3<<endl;
    else cout<<min(n-mx1-mx4,n-mx3-mx2);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, c; cin >> a >> b >> c;
    int ans = min(a+b, b+c);
    ans = min(ans, a+c);
    cout << ans << endl;
}

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

using namespace std;

int main(){
  int N, h[100]={0};
  int max=0, ans=0;
  cin >> N;
  for(int i=0; i < N; i++){
    cin >> h[i];
    if(h[i]>=max){
      ans++;
      max=h[i];
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << ” = ” << (x) << ” (L” << __LINE__ << “)” << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
       return l.first<r.first || (l.first==r.first && l.second > r.second);
       });
*/

typedef long long  ll;

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


using Graph = vector<vector<int> >;

int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    int MAX=0;
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    a.push_back(1000000001);
    int ans=0;
    for(int i=0;i<n;i++){
        int j=1;
        while(a.at(i)==a.at(i+j)){
            j++;
        }
        i+=j-1;
        if(j>a.at(i)){
            ans+=(j-a.at(i));
        }
        else if(j<a.at(i)){
            ans+=j;
        }
    }
    cout<<ans<<endl;




   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	string S, P;
	cin >> P >> S;
	string ans = "No";
	REP(i, P.length())
	{
		bool f = true;
		REP(j, S.length())
		{
			if (P[(i + j) % P.length()] != S[j])
			{
				f = false;
				break;
			}
		}
		if (f)
		{
			ans = "Yes";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3240
N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
        if i + j >N:
            break
        k = N - i - j
        if (i *10000 + j*5000 + k*1000) == Y:
            print(i,j,k)
            exit()

print(-1,-1,-1)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	const long mod = 1000000007;

	void solve() {
		int N, K;
		cin >> N >> K;

		long ans = 0;
		for( long i = K; i <= N+1; ++i ) {
			long a = (i-1) * i / 2;
			long b = (N + (N-i+1)) * i / 2;
			ans = (ans + b - a + 1) % mod;
		}

		cout << ans << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{

    internal class Solution
    {
        public int N, P;
        public int[] A;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                P = line[1];
                A = Input.ReadIntArray();
            }

            int ONES = 0;
            int TWOS = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] % 2 == 1) ONES++;
                else TWOS++;
            }

            if (P == 1 && ONES == 0)
            {
                Console.WriteLine(0);
                return;
            }

            long ret = 1;
            for (int i = 0; i < TWOS; i++)
            {
                ret *= 2;
            }
            for (int i = 0; i < ONES-1; i++)
            {
                ret *= 2;
            }

            Console.WriteLine(ret);
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:
    print(-1)
    exit()
hen=[]
for i in range(1,n):
    for j in range(i+1,n):
        hen.append((i,j))
x=(n-1)*(n-2)//2-k
ans=[(0,i) for i in range(1,n)]
for i in range(x):
    ans.append(hen[i])
print(len(ans))
for x,y in ans:
    print(x+1,y+1)


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

from collections import deque

import bisect
n = int(input())

a = [int(input()) for i in range(n)]

#color = [a[0]]

d = deque()
d.appendleft(a[0])

for i in range(1,n):
    idx = bisect.bisect_left(d,a[i])
    if idx == 0:
        d.appendleft(a[i])
    else:
        d[idx-1] = a[i]
        
print(len(d))

Measured memory_bytes: 8064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

 
int main(){
    int w,i;
    char s[1001];
    scanf("%s%d",s,&w);
    for(i=0;i<strlen(s);i+=w){
        printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int INF = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<pair<ll, ll>> a(n);
	rep(i, n) {
		ll x, l;
		cin >> x >> l;
		a[i] = make_pair(x + l, x - l);
	}
	ll b = -1000000001;
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i, n) {
		if (b <= a[i].second) {
			b = a[i].first;
			ans++;
		}
	}
	cout << ans << endl;
}

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

int main(void) {
	int i, Amax = 0, K=0,T=0,sum=0;
	int Ai[100];

	scanf("%d %d\n", &K, &T);

	for (i = 0; i<T; i++) {
		scanf("%d", &Ai[i]);
		if(Ai[i]>Ai[Amax]){
			Amax = i;
		}
	}
	for (i=0;i<T;i++){
		if(i != Amax){
			sum +=Ai[i];
		}
	}
	if(sum+1<Ai[Amax]){
		printf("%d",Ai[Amax]-sum-1);
	}else{
		printf("0");
	}
	return 0;
}


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

signed main(){
  string A,B,C;
  cin>>A>>B>>C;
  cout<<A[0]<<B[1]<<C[2]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void outStr(vector<string>& ary) {

	string aryStr = "";
	for (int i = 0; i < ary.size(); i++)
	{
		aryStr = aryStr + ary[i];
		if (i < ary.size() - 1) aryStr = aryStr + " ";
	}

	cout << aryStr << endl;
	return;
}

bool isSmaller(string s1, string s2) {

	int v1 = stoi(s1.substr(1));
	int v2 = stoi(s2.substr(1));

	bool rtn = false;
	if (v1 < v2) rtn = true;

	return rtn;
}

void bubbleSort(vector<string>& ary) {

	bool flag = 1;
	int swTime = 0;
	while (flag)
	{
		flag = 0;
		for (int j = ary.size() - 1; j >= 1; j--)
		{
			if (isSmaller(ary[j], ary[j - 1])) {
				string sw = ary[j - 1];
				ary[j - 1] = ary[j];
				ary[j] = sw;
				flag = 1;

			}

		}
	}

	return;
}

void selectionSort(vector<string>& ary) {

	for (int i = 0; i < ary.size(); i++)
	{
		int minj = i;
		bool needSw = false;
		for (int j = i; j < ary.size(); j++) {
			if (isSmaller(ary[j], ary[minj])) {
				minj = j;
				needSw = true;
			}
		}
		if (needSw) {
			string sw = ary[i];
			ary[i] = ary[minj];
			ary[minj] = sw;

		}
	}

	return;
}



int main() {

	int N;
	cin >> N;
	vector<string> bb(N);
	vector<string> ss;
	for (int i = 0; i < N; i++) {
		cin >> bb[i];
		ss.push_back(bb[i]);
	}

	bubbleSort(bb);
	outStr(bb);

	string stb = "Stable";
	cout << stb << endl;

	selectionSort(ss);
	outStr(ss);

	bool isSame = true;
	for (int i = 0; i < bb.size(); i++)
	{
		if (bb[i] != ss[i]) isSame = false;
	}

	if (!isSame) stb = "Not stable";

	cout << stb << endl;


	return 0;
}



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

int main(int argc, const char * argv[])
{
    string str;
    while (getline(cin, str)) {
        for (int i = 0; i < str.length() - 4; i++) {
            string stuck = str.substr(i, 5);
            if (stuck.find("apple") != string::npos) {
                str[i] = 'p';
                str[i + 1] = 'e';
                str[i + 2] = 'a';
                str[i + 3] = 'c';
                str[i + 4] = 'h';
                i += 4;
            }
            else if (stuck.find("peach") != string::npos) {
                str[i] = 'a';
                str[i + 1] = 'p';
                str[i + 2] = 'p';
                str[i + 3] = 'l';
                str[i + 4] = 'e';
                i += 4;
            }
        }
        cout << str << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
/*
      author  : nishi5451
      created : 14.08.2020 19:29:14
*/

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

const int INF = 1e9+1;

int main(){
    int n;
    cin >> n;
    int a=INF,b=0;
    rep(i,n){
        int tmp;
        cin >> tmp;
        a = min(a,tmp);
        b = max(b,tmp);
    }
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#define REP(i,n) for(LL i=0, i##_len=(n); i<i##_len; ++i)

int main() {
  LL N;
  std::cin >> N;
  std::vector<LL> A(N);
  for(LL i=0; i<N; i++) {
    std::cin >> A[i];
  }

  std::vector<LL> ans(N);
  ans[0] = 0;
  for(LL i=0; i<N; i++) {
    if( i%2 == 0 ) { ans[0] += A[i]; }
    else { ans[0] -= A[i]; }
  }
  for(LL i=1; i<N; i++) {
    ans[i] = A[i-1]*2 - ans[i-1];
  }

  for(LL i=0; i<N-1; i++) {
    std::cout << ans[i] << ' ';
  }
  std::cout << ans[N-1] << std::endl;

  return 0;
}



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

typedef long long int ll;
typedef vector<int> vi;			typedef vector<ll> vl;
typedef vector<vi> vvi; 		typedef vector<vl> vvl;
typedef pair<int, int> 	pii;	typedef pair<ll, ll> pll;
typedef vector<pii> vii; 		typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define in insert
#define mp(a, b) make_pair(a, b)
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#ifdef KARAN
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef KARAN
		freopen("inp.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
    	freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 256
def getComb(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD
    
X,Y = [int(i) for i in input().split()]
def check(x,y):
    if x/2 == y:
        return 0
    elif x/2 < y:
        return 1
    else:
        return 9
cnt = 0
possible = True
MOD = 10**9 + 7

while True:
    check_num =  check(X,Y)
    if check_num == 0:
        break
    elif check_num == 1:
        X += 1
        Y -= 1
        cnt += 1
    else:
        possible = False
        break
if possible == True:
    n = X // 2 
    r = cnt
    print(getComb(n,r,MOD))
else:
    print(0)


Measured memory_bytes: 40428
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int m, cnt;
vector<int> g;
void insertion_sort(int a[], int n, int g) {
  rep(i, g, n) {
    int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j = j - g;
      cnt++;
    }
    a[j + g] = v;
  }
}

void shell_sort(int a[], int n) {
  cnt = 0;
  m = 1;
  g.push_back(1);
  while (true) {
    g.push_back(g[m - 1] * 3 + 1);
    if (g[m] > n)
      break;
    m++;
  }
  repr(i, 0, m) { insertion_sort(a, n, g[i]); }
}

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

  int n;
  cin >> n;
  int a[n];
  rep(i, 0, n) cin >> a[i];

  shell_sort(a, n);
  cout << m << endl;
  repr(i, 0, m) {
    if (i < m - 1)
      cout << " ";
    cout << g[i];
  }
  cout << endl;

  cout << cnt << endl;
  rep(i, 0, n) cout << a[i] << endl;
  ;
}



Measured memory_bytes: 7112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, P;
string S;
int rest[200010];
ll cnt[10010];
ll sum[200010];
ll ans;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin >> N >> P >> S;
	reverse(S.begin(), S.end());
	if(P == 2){
		for(int i = 0; i < N; i++){
			if((S[i] - '0') % 2 == 0) ans += N - i;
		}
		cout << ans << endl;
		return 0;
	}
	if(P == 5){
		for(int i = 0; i < N; i++){
			if((S[i] - '0') == 0 || (S[i] - '0' == 5)) ans += N - i;
		}
		cout << ans << endl;
		return 0;
	}
	rest[0] = 1;
	for(int i = 1; i < N; i++){
		rest[i] = rest[i - 1] * 10;
		rest[i] %= P;
	}
	for(int i = 0; i < N; i++){
		sum[i] += rest[i] * (S[i] - '0');
		sum[i] %= P;
		sum[i + 1] = sum[i];
		cnt[sum[i]]++;
	}
	ans += cnt[0];
	for(int i = 0; i < N - 1; i++){
		cnt[sum[i]]--;
		ans += cnt[(P + sum[i]) % P];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2964
fun main(args: Array<String>) {
    val (x, y, a, b, c) = readLine()!!.split(" ").map{it.toInt()}
    val p = LongArray(a)
    var q = LongArray(b)
    val r = LongArray(c)
    var index = 0
    for (i in readLine()!!.split(" ")) {
        p[index] = i.toLong()
        index ++
    }
    index = 0
    for (i in readLine()!!.split(" ")) {
        q[index] = i.toLong()
        index ++
    }
    index = 0
    for (i in readLine()!!.split(" ")) {
        r[index] = i.toLong()
        index ++
    }
    val aa = p.sortedDescending().take(x).toLongArray()
    val bb = q.sortedDescending().take(y).toLongArray()
    val apple = ( aa + bb + r).sortedDescending().take(x+y)
    var ans = 0L
    repeat(x+y){ans += apple[it]}
    println(ans)
}


Measured memory_bytes: 108904