akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int N = 200050;
int n,a[N],mn[N];
int main(){
	int i;
	n = read();
	for (i = 1; i <= n; ++i) a[i] = read(),mn[i] = (i==1) ? (a[1]) : (min(mn[i-1],a[i]));
	int ans = 1;
	for (i = 2; i <= n; ++i) if (a[i] <= mn[i-1]) ++ans;
	cout << ans << endl;
    return 0;
}


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

void solve(){

	int n; 
	cin>>n ;

	vector<int> a(n) ;

	rep(i,n){
		cin>>a[i] ;
	}

	int count=0 ;

	for(int i=0;i<n;i++){
		if(a[i]==i+1 && i!=n-1){
			swap(a[i],a[i+1]) ;
			count++ ;

		}

		if(a[i]==i+1 && i==n-1){
			swap(a[i],a[i-1]) ;
			count++ ;
		}
	}
	cout<<count ;
}


int main(){

		int y ;

		y=1 ;
		//cin>>y ;

		while(y--){
 
			solve() ;

		}

}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdlib.h>
using namespace std;

int main()
{
	double n;
	cin >> n;

	int count = 0;
	double temp = n;
	while (temp / 10 >= 1) {
		count++;
		temp = temp / 10;
	}

	int answer = 0;
	for (int i = 0; i <= count; i++) {
		if (i % 2 == 0) {
			if (i == count) {
				answer += n - pow(10, i) + 1;
			}
			else {
				answer += 9 * pow(10, i);
			}
		}
	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int l = INT_MAX, r = INT_MIN;
    ll ans = INT_MAX;
    
    rep(i, n) {
        l = min(l, a[i]);
        r = max(r, a[i]);
    }
    
    if (l == r) {
        cout << "0" << endl;
        return 0;
    }
    
    reps(i, l, r) {
        ll sum = 0;
        
        rep(ii, n) {
            sum += (a[ii] - i) * (a[ii] - i);
        }
        
        ans = min(ans, sum);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
S = list(input())
ll = [0]*len(S)

index = []
for i in range(len(S) - 1):
    if S[i] == "R" and S[i+1] == "L":
        index.append(i)

l,r = 0,0
k = 0
flg = True
for i in range(len(S)):
    if S[i] == "R" and flg == True:
        r += 1
    elif S[i] == "L":
        l+=1
        flg = False
    elif S[i] == "R" and flg == False:
        if (r + l) % 2 == 0:
            t = (r+l)//2
            ll[index[k]] = t
            ll[index[k]+1] =t
        else:
            t = (r+l)//2
            if max(r,l) % 2 ==0 and r < l:
                ll[index[k]] = t+1
                ll[index[k]+1] =t
            elif max(r,l) % 2 ==0 and r > l:
                ll[index[k]] = t
                ll[index[k]+1] =t+1
            elif max(r,l) % 2 == 1 and r > l:
                ll[index[k]] = t+1
                ll[index[k]+1] =t
            elif max(r,l) % 2 == 1 and r < l:
                ll[index[k]] = t
                ll[index[k]+1] =t+1
        flg = True
        r = 1
        k+=1
        l = 0


if (r + l) % 2 == 0:
    t = (r+l)//2
    ll[index[k]] = t
    ll[index[k]+1] =t
else:
    t = (r+l)//2
    if max(r,l) % 2 ==0 and r < l:
        ll[index[k]] = t+1
        ll[index[k]+1] =t
    elif max(r,l) % 2 ==0 and r > l:
        ll[index[k]] = t
        ll[index[k]+1] =t+1
    elif max(r,l) % 2 == 1 and r > l:
        ll[index[k]] = t+1
        ll[index[k]+1] =t
    elif max(r,l) % 2 == 1 and r < l:
        ll[index[k]] = t
        ll[index[k]+1] =t+1


print(" ".join(map(str,ll)))


    


Measured memory_bytes: 13264
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

vector<ll> wh[200005];
ll num[200005];
ll cnt[200005];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<ll> v;
  rep(i,n){
      ll tmp; cin >> tmp;
      if(i==0){
          v.push_back(tmp);
      }else{
          if(v[v.size()-1] != tmp){
              v.push_back(tmp);
          }
      }
  }
  ll si = v.size();
  ll ans = 1;
  rep(i,si){
      ans += cnt[v[i]];
      ans %= MOD;
      cnt[v[i]] = ans;
  }
  cout << ans << endl;


}

Measured memory_bytes: 9328
#include<stdio.h>
 
int main(){
  int N,A[100],i,j,tmp,t=0,minj;
 
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
 

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

Measured memory_bytes: 600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string a; cin>>a;
    map<char,ll> m;
    ll n=a.size();
    ll ans=n*(n-1)/2+1;
    for(auto ch:a){
        if(m.count(ch)) m[ch]++;
        else m[ch]=1;
    }
    for(auto q:m){
        ans-=q.second*(q.second-1)/2;
    }
    cout<<ans<<endl;
}

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

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

    int ans = a - 1;
    if (b >= a) ans++;

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N, L;
    string S[110];
    string SUM;
    cin >> N >> L;
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    
    sort(S, S+N);
    
    for(int i=0; i<N; i++){
        SUM += S[i];
    }
    
    cout << SUM << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int INF = (int) 1e9 + 100;

const int N = 105;
char f[N][N];

int dp[N][N][2];

void upd(int &a, int b)
{
    a = min(a, b);
}

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, m;
    scanf("%d%d", &n, &m);

    for (int i = 0; i < n; i++)
        scanf("%s", f[i]);

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            for (int h = 0; h < 2; h++)
                dp[i][j][h] = INF;

    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            for (int h = 0; h < 2; h++)
                upd(dp[i][j][h ^ 1], dp[i][j][h] + 1);
            int ch = 0;
            if (f[i][j] == '#')
                ch = 1;
            dp[i][j][ch ^ 1] = dp[i][j][ch] + 1;
            //eprintf("%d %d : %d %d\n", i, j, dp[i][j][0], dp[i][j][1]);
            upd(dp[i + 1][j][ch], dp[i][j][ch]);
            upd(dp[i][j + 1][ch], dp[i][j][ch]);
        }
    int ans = dp[n - 1][m - 1][0] / 2;
    printf("%d\n", ans);

	return 0;
}




Measured memory_bytes: 384
#include<stdio.h>
#define N 100

int main(){
  int f=1,c=0,i=0,n,a[N],swap,y=0;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&a[i]);
  
  while(f!=0){
    f=0;
    
    for(i=n-1;i>=c+1;i--){      
      if(a[i]<a[i-1]){	
	swap=a[i-1];
	a[i-1]=a[i];
	a[i]=swap;
	f=1;
	y++;
      }
    }
    
    c++;
  }
  
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",y);
  return 0;
}
      



Measured memory_bytes: 2144
fn main() {
    let std_in = std::io::stdin();
    let mut br = std::io::BufReader::new(std_in.lock());
    let std_out = std::io::stdout();
    let mut bw = std::io::BufWriter::new(std_out.lock());

    let N = rn::<usize>(&mut br);
    let mut adjs: Vec<Vec<(usize, usize)>> = vec![Vec::new(); N];
    for _ in 0..N-1 {
        let tmp = rvn::<usize>(&mut br);
        let (u, v, w) = (tmp[0] - 1, tmp[1] - 1, tmp[2] % 2);
        adjs[u as usize].push((v, w));
        adjs[v as usize].push((u, w));
    }

    let mut sol = vec![0; N];
    let mut visited = vec![false; N];
    let mut que = VecDeque::<usize>::new();
    que.push_back(0);
    while !que.is_empty() {
        let now = que.pop_front().unwrap();
        visited[now] = true;
        for next in &adjs[now] {
            let v = next.0;
            let w = next.1;
            if visited[v] {continue;}
            sol[v] = sol[now] ^ w;
            que.push_back(v);
        }
    }
    for i in 0..N {
        writeln!(bw, "{}", sol[i]);
    }
}


//////////////////////////////////////////////////////////////////////////////////
use std::io::{BufReader, BufRead, StdinLock, Write};
use std::collections::vec_deque::VecDeque;

#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 14716
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const ll INF = 1ll << 60;
const double EPS = 1e-8;
const int MOD = 1000000007;

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n, -1){}
    bool unite(int x, int y) {
        if ((x = root(x)) != (y = root(y))){
            if (d[y] < d[x]) swap(x, y);
            d[x] += d[y]; d[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y){return root(x) == root(y);}
    int root(int x){return d[x] < 0 ? x : d[x] = root(d[x]);}
    int size(int x=-1) {return x<0 ? d.size() : -d[root(x)];}
};


int T, n, m;

int main(int argc, char *argv[]) {
    cin >> n >> m;
    vi p(n);
    REP(i, n) {
        cin >> p[i];
        p[i] --;
    }
    UnionFind uf(n);
    REP(i, m) {
        int x, y;
        cin >> x >> y; x--; y--;
        uf.unite(x, y);
    }
    int ans = 0;
    REP(i, n) ans += uf.find(i, p[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
x0=input().split()
a0=int(x0[0])
b0=int(x0[1])
min=int(x0[2])

a1=input().split()
al=[int(x) for x in a1]
b1=input().split()
bl=[int(x) for x in b1]

ar=[0]
ar0=0
for x in al:
  ar0+=x
  ar.append(ar0)
  if ar0>min:
    break
an=len(ar)
if an-1==len(al):
  ar.append(1000000001)
  an+=1

br=[0]
br0=0
for x in bl:
  br0+=x
  br.append(br0)
  if br0>min:
    break
bn=len(br)
if bn-1==len(bl):
  br.append(1000000001)
  bn+=1

#print(str(br))
ans=0
if an==2:
  ans=bn-2
elif bn==2:
  ans=an-2
else:
  bnow=0
  for i in range(an-2,-1,-1):
    #print("i="+str(i))
    if i+bn-2<=ans:
      break
    bcan=min-ar[i]
    for j in range(bnow,bn):
      if bcan>=br[j]:
        #print("j="+str(j))
        bnow+=1
      else:
        #print("j^="+str(j))
        ans1=i+j-1
        if ans1>ans:
          ans=ans1
        break
    if bnow==bn-2:
      break
      
print(ans)

Measured memory_bytes: 70252
import collections
def main():
    H, W, D = map(int, input().split())
    A = []
    for _ in range(H):
        A.append(list(map(int, input().split())))
    Q = int(input())
    queries = []
    for _ in range(Q):
        L, R = map(int, input().split())
        queries.append([L, R])

    d = collections.defaultdict(list)
    for i in range(H):
        for j in range(W):
            d[A[i][j] % D].append([A[i][j], i, j])
    for v in d:
        d[v] = sorted(d[v], key = lambda x: x[0])

    d1 = collections.defaultdict(list)
    for v in d:
        prefix = [0]
        if v == 0:
            prefix.append(0)
        for i in range(len(d[v])-1):
            mag = abs(d[v][i][1] - d[v][i+1][1]) + abs(d[v][i][2]-d[v][i+1][2])
            prefix.append(prefix[-1]+mag)
        d1[v] = prefix
    # print(d1)

    # print(A)
    for L, R in queries:
        if L == R:
            print(0)
        else:
            l = (R-L) // D
            i = L // D
            v = L % D
            magic = d1[v][i+l] - d1[v][i]
            print(magic)

if __name__ == '__main__':
    main()

Measured memory_bytes: 115160
N = int(input())

if 1<= N <= 81:
    for i in reversed(range(1, 10)):
        if N % i == 0:
            check = N/i
            for j in reversed(range(1,10)):
                if check /j == 1:
                    print("Yes")
                    exit()
    print("No")
    
else:
    print("No")

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace Structure_and_Class
{
    class Dice_III
    {
        static void Main(string[] args)
        {
            var diceA = new Dice3(Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray());
            var diceB = new Dice3(Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray());
            if (diceA.IsEqual(diceB)) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }

    public class Dice3
    {
        public int[] label = new int[6];

        public Dice3(int[] label)
        {
            this.label = label;
        }

        public bool IsEqual(Dice3 diceB)
        {
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('E');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;
            diceB.Move('N');
            if (RotaetCheck(diceB)) return true;

            return false;
        }

        private bool RotaetCheck(Dice3 diceB)
        {
            for (int i = 0; i < 4; i++)
            {
                diceB.Rotate();
                if (label.SequenceEqual(diceB.label)) return true;
            }
            return false;
        }

        public void Move(char c)
        {
            int[] res = new int[6];
            switch (c)
            {
                case 'E':
                    res[0] = label[3];
                    res[1] = label[1];
                    res[2] = label[0];
                    res[3] = label[5];
                    res[4] = label[4];
                    res[5] = label[2];
                    label = res;
                    break;
                case 'N':
                    res[0] = label[1];
                    res[1] = label[5];
                    res[2] = label[2];
                    res[3] = label[3];
                    res[4] = label[0];
                    res[5] = label[4];
                    label = res;
                    break;
                case 'S':
                    Move('N');
                    Move('N');
                    Move('N');
                    break;
                case 'W':
                    Move('E');
                    Move('E');
                    Move('E');
                    break;
            }
        }

        public void Rotate()
        {
            int[] res = new int[6];
            res[0] = label[0];
            res[1] = label[3];
            res[2] = label[1];
            res[3] = label[4];
            res[4] = label[2];
            res[5] = label[5];
            label = res;
        }
    }
}

Measured memory_bytes: 9916
from collections import deque
N = int(input())

alphabet = "abcdefghij"
visited = 1
st = deque([("a", visited)])

while len(st) > 0:
    str, visited = st.popleft()

    if len(str) == N:
        print(str)
    else:
        # すでに使った文字を使う
        for x in alphabet[0 : visited]:
            st.append((str + x, visited))
        # まだ使っていない文字を使う
        # len(str) < Nだから、visited < N
        st.append((str + alphabet[visited], visited + 1))

Measured memory_bytes: 19188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1005],b[1005];
int main(void){
    ll n,h,w; cin>>n>>h>>w;
    ll ans=0;
    for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		if(a[i]>=h&&b[i]>=w){
			ans++;
		}
	}
	cout<<ans<<endl;
    
}


Measured memory_bytes: 256
s = input().replace('BC', 'P').replace('C', 'X').replace('B', 'X')
n = len(s)

answer = 0
a = 0
for i in range(n):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'P':
        answer += a
    else:
        a = 0

print(answer)


Measured memory_bytes: 3500
import java.io.*;
import java.util.*;
 
class Main{
    public static void main(String[] args){
    BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
    try {
        String st, sp;
        while((st=sc.readLine())!=null){
        st = Integer.toBinaryString(Integer.valueOf(st));
        int m=1;
        for(int i=st.length()-1; i>=1; i--){
            if(st.charAt(i)=='1'){
            System.out.printf(m+" ");
            m*=2;
            }
            else
            m*=2;
        }
        System.out.println(m);
        }
    }
    catch(Exception e){
        System.out.println("Error");
    }
    }
}

Measured memory_bytes: 15108
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new CatSnukeVoyage();
			Instance.Exec();
		}
	}

	public class CatSnukeVoyage
	{
		public void Exec()
		{
			var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int n = nm[0];
			int m = nm[1];
			HashSet<int> ahash = new HashSet<int>();
			HashSet<int> bhash = new HashSet<int>();
			for (var j = 1; j <= m; ++j) {
				var ab = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
				if (ab[0] == 1) {
					ahash.Add(ab[1]);
				}

				if (ab[1] == n) {
					bhash.Add(ab[0]);
				}
			}

			bool canVoyage = false;

			foreach (var a in ahash) {
				if (bhash.Contains(a)) {
					canVoyage = true;
				}
			}

			string result = canVoyage ? "POSSIBLE" : "IMPOSSIBLE";
			Console.WriteLine(result);
			Console.Out.Flush();
			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 23572
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[101];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[21];

P u[1];
//queue<int> q;
//stack<int> s;
set<int> s;
map<int,int> p;

vector<int> v;

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

long long f(int n,int m)
{
  if(n==m) return r[n]-'0';
  return (r[m]-'0')+f(n,m-1)*10;
}

int main()
{
  scanf("%s",r+1);
  a=strlen(r+1);
  for(int t=1;t<=a;t++)
  for(int w=t;w<=a;w++)
  {
    if(t!=1&&w<a) x+=f(t,w)*(1<<(a-1-(w-t+2)));
    else if(t==1&&w==a) x+=f(t,w);
    else if(t==1) x+=f(t,w)*(1<<(a-w-1));
    else x+=f(t,w)*(1<<(t-2));
    //printf("%lld %lld\n",f(t,w),x);
  }
  printf("%lld",x);
}
//2
//21



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

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = a; i <= min(b, a + k - 1); i++) {
			cout << i << endl;
		}
	for (int j = max(b - k + 1, a + k); j <= b; j++) {
			cout << j << endl;
		}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long ac=0,wa=0,tle=0,re=0,n=0;
  cin>>n;
  string inp;
  for(int i=0;i<n;i++){
  cin>>inp;
    if(inp=="AC"){
      ac++;
    }
    if(inp=="WA"){
      wa++;
    }
    if(inp=="TLE"){
    tle++;
    }
    if(inp=="RE"){
    re++;
    }
  }
  cout<<"AC x "<<ac<<"\n";
  cout<<"WA x "<<wa<<"\n";
  cout<<"TLE x "<<tle<<"\n";
  cout<<"RE x "<<re<<"\n";
  return 0;
}

Measured memory_bytes: 3524
x = int(input())

if 400 <= x <= 599:
  print(8)
elif 600 <= x <= 799:
  print(7)
elif 800 <= x <= 999:
  print(6)
elif 1000 <= x <= 1199:
  print(5)
elif 1200 <= x <= 1399:
  print(4)
elif 1400 <= x <= 1599:
  print(3)
elif 1600 <= x <= 1799:
  print(2)
else:
  print(1)

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

int d[9];
char c[9], buf[2];
bool used[9];

bool dfs(int p, char b, int cnt, bool r) {
	bool ok = true;
	rep(i, 9)ok &= used[i];
	if (ok)return true;
	ok = false;
	if (cnt == 3) {
		ok = true;
		cnt = 0;
	}
	rep(i, 9) {
		if (!used[i] && (ok || c[i] == b)) {
			if (ok || (r&&d[i] == p + 1) || (!r&&d[i] == p)) {
				used[i] = true;
				if (dfs(d[i], c[i], cnt + 1, r))return true;
				if (ok) {
					if (dfs(d[i], c[i], cnt + 1, !r))return true;
				}
				used[i] = false;
			}
		}
	}
	return false;
}
int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		rep(j, 9)scanf("%d", &d[j]);
		rep(j, 9) {
			scanf("%s", buf);
			c[j] = buf[0];
		}
		memset(used, 0, sizeof(used));
		printf("%d\n", dfs(0, 0, 3, 0));
	}
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int dp[1010101][2];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin>>S;
  int N=S.length();
  rep(i,1010101) dp[i][0]=dp[i][1]=1e9;
  dp[0][0]=0,dp[0][1]=1;
  rep(i,N) rep(j,2){
    int X=S[i]-'0';
    if(j==0){
      dp[i+1][0]=min(dp[i+1][0],dp[i][0]+X);
      dp[i+1][1]=min(dp[i+1][1],dp[i][0]+X+1);
    }else{
      dp[i+1][0]=min(dp[i+1][0],dp[i][1]+10-X);
      dp[i+1][1]=min(dp[i+1][1],dp[i][1]+10-X-1);
    }
  }
  cout<<dp[N][0]<<endl;
  return 0;
}

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

int main(){

  int N;
  long ans=1;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++) cin >> A[i];
  sort(A, A+N);

  if(N%2==0){
    for(int i=0; i<N; i++){
      if(i%2!=0 && (A[i]!=i || A[i-1]!=i)){
        cout << "0" << endl;
        return 0;
      }
    }
    for(int i=0; i<N/2; i++){
      ans *= 2;
      ans %= 1000000007;
    }
    cout << ans << endl;

  }else{

    if(A[0]!=0){
      cout << "0" << endl;
      return 0;
    }

    for(int i=1; i<N; i++){
      if(i%2==0 && (A[i]!=i || A[i-1]!=i)){
        cout << "0" << endl;
        return 0;
      }
    }
    for(int i=0; i<(N-1)/2; i++){
      ans *= 2;
      ans %= 1000000007;
    }
    cout << ans << endl;
  }

  return 0;
}


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

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

    int N; cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; ++i) cin >> b[i];

    vector<int> ans;
    while (!b.empty()) {
        bool found = false;
        for (int j = (int)b.size() - 1; j >= 0; --j) {
            if (b[j] == j + 1) {
                found = true;
                ans.push_back(j + 1);
                b.erase(b.begin() + j);
                break;
            }     
        }
        if (!found) {
            cout << -1 << endl;
            return 0;
        }
    }

    for (int i = N - 1; i >= 0; --i) cout << ans[i] << '\n';

    return 0;
}

Measured memory_bytes: 384
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll mns=0;
    ll sum=0;
    ll mi=E;
    for(auto &I:a){
        cin>>I;
        if(I<0){mns++;}
        sum+=abs(I);
        mi=min(mi,abs(I));
    }
    if(mns&1){cout<<sum-2*mi<<endl;}
    else{cout<<sum<<endl;}
    
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
int t;
//cin>>t;
//while(t--){
int n , m;
cin>>n>>m;
int A[n];
int sum = 0;
int sum1 = 0;
for(int i=0 ; i<n ; i++){
    cin>>A[i];
    sum += A[i];
}

for(int i=0 ; i<n-1 ; i++){
   int tmp = A[i] + A[i+1];
   if(tmp<=m) continue;
   if(A[i]>m){
        A[i] = m;
        A[i+1] = 0;
   }
   else if(A[i]<=m){
    A[i+1] = m - A[i];
   }
}

for(int i=0 ; i<n ; i++){
    //cout<<A[i]<<" ";
   sum1 += A[i];
}
//cout<<endl;
cout<<sum - sum1<<endl;
//}
}


Measured memory_bytes: 4364
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,ar[N],dp[N];
ll maxval(ll i){
	if(i==n) return 0;
	if(i+1==n) return abs(ar[i]-ar[i+1]);

	if(dp[i]!=-1) return dp[i];
	ll a,b;
	a=maxval(i+1)+abs(ar[i]-ar[i+1]);
	b=maxval(i+2)+abs(ar[i]-ar[i+2]);
	return dp[i]=min(a,b);
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}	
	memset(dp,-1,sizeof(dp));
	ll an=maxval(1);
	cout<<an;
	return 0;	
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 2e5 + 5;

int n, A[N], B[N], PS[N], FEN[N];

void Add(int p) { for(p++; p < N; p += p & -p) FEN[p]++; }
int Get(int p) {
	int res = 0;
	for (; p > 0; p -= p & -p) res += FEN[p];
	return res;
}

bool isVal(int x) {

	memset(FEN, 0, sizeof FEN);
	PS[0] = n;
	for (int i = 0; i < n; i++) B[i + 1] = (A[i] < x ? -1 : +1), PS[i + 1] = PS[i] + B[i + 1];
	ll cnt = 1LL * n * (n + 1) / 2, cnt1 = 0, cnt0 = 0;
	for (int i = 0; i <= n; i++) cnt1 += Get(PS[i] + 1), Add(PS[i]);
	cnt0 = cnt - cnt1;
	return cnt0 < cnt / 2 + 1;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	int dw = 0, up = INF + 1;
	while (up - dw > 1) {
		int md = (dw + up) >> 1;
		if (isVal(md)) dw = md;
		else up = md;
	}
	cout << dw << endl;

	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

void printDP(vvi &dp){
    for(auto v: dp){
        for(auto x: v){
            cout << x << " ";
        }
        cout << endl;
    }
    cout << endl;
}

void inc(bitset<15> &a){
    a = a.to_ullong() +1;
}

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> testimonies(n);
    vvi dp(n,vi(n,-1));
    for(int i = 0 ; i < n ; i ++ ){
        int q;
        cin >> q;
        vector<pair<int,int>> xy(q);
        for(int j = 0 ; j < q;j++){
            int f,s;
            cin >> f>> s;
            f--;

            xy[j] = {f,s};
            dp[f][i] = s;
        }
        testimonies[i]  = xy;
    }

//    printDP(dp);
    bitset<15> bp;
    int maxScore = 0;
    while (bp.count() < n){
        inc(bp);
        bool isValid = true;
        for(int i = 0 ; i <n;i++ ){
            isValid = true;
            if(bp[i]){
                for(int j = 0 ; j < n ; j++){
                    if(dp[i][j] == 0 && bp[j]){
                        isValid = false;
                        break;
                    }
                }
            }else{
                for(int j = 0 ; j < n ; j++){
                    if(dp[i][j] == 1 && bp[j]){
                        isValid = false;
                        break;
                    }
                }
            }
            if(!isValid){
                break;
            }
        }
        if(isValid){
            maxScore = max(maxScore,(int)bp.count());
        }
    }
    cout << maxScore;
    return 0;
}



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

int main() {
	int M, D;
	cin >> M >> D;
	int ans=0;
	for(int i=22; i<=D; ++i){
	    if(i%10<2) continue;
	    if((i/10)*(i%10)<=M) ++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
H = gets.to_i

# 1以下になるまでの回数を数える
ans = 0
cnt = 0
ret = H
while ret > 1
  ret /= 2
  cnt += 1
end

# 549755813888
# 1099511627775
# 274877906944
# p cnt

(1..cnt).each do |i|
  _n = 2 ** i
  ans += _n
  # p "i:#{_n} ans:#{ans}"
end

puts ans+1


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a){cout<<((a)?"Yes":"No")<<endl;}
void YESNO(int a){cout<<((a)?"YES":"NO")<<endl;}
void AorB(int a,string b,string c){cout<<((a)?b:c)<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int h,w;
    cin>>h>>w;
    VVi a(h,Vi(w));
    REP(i,0,h) REP(j,0,w) cin>>a[i][j];
    Vi a1,a2,a3,a4;
    
    int x=0,y=0;
    for (int iter = 0; iter < h*w; ++iter) {
        int nx = x, ny = y;
        if (y % 2 == 0) {
            if (nx == w-1) ++ny;
            else ++nx;
        }else{
            if (nx == 0) ++ny;
            else --nx;
        }
        if(a[y][x]%2==1 && iter<h*w-1){
            a1.pb(y+1);
            a2.pb(x+1);
            a3.pb(ny+1);
            a4.pb(nx+1);
            a[ny][nx]++;
        }
        x = nx;
        y = ny;
    }
    cout<<a1.size()<<endl;
    REP(i,0,a1.size()) cout<<a1[i]<<" "<<a2[i]<<" "<<a3[i]<<" "<<a4[i]<<endl;
    return 0;
}


Measured memory_bytes: 8148
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

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

	int n, m, c;
	cin >> n >> m >> c;
	vi B(m);
	f_vI(B, m);
	vvi A(n, vi(m));
	f(i, 0, n) {
		f(j, 0, m) {
			cin >> A[i][j];
		}
	}
	LL sum = 0;
	LL ans = 0;
	f(i, 0, n) {
		sum = 0;
		f(j, 0, m) {
			sum += A[i][j] * B[j];
		}
		if (sum + c > 0) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<tuple<string, int, int>> a;

  for (int i = 1; i <= n; i++)
  {
    string S;
    int P;
    cin >> S >> P;
    P = -P;
    a.push_back(tie(S, P, i));
  }

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

  for (int i = 0; i < n; i++)
  {
    cout << get<2>(a[i]) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
    //cout.precision(10);
    int a, b;
    cin >> a >> b;
    if(a + b == 15){
        cout << "+" << endl;
        return 0;
    }
    if(a * b == 15){
        cout << "*" << endl;
        return 0;
    }
    cout << "x" << endl;
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define vl vector<long long>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define mp make_pair
#define isOn(S, j) (S & (1 << j))

vi k[16],u[16];



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,x,a,y;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<a;j++){
            cin>>x>>y;
            if(y==1){
                k[i+1].pb(x);
            }
            else{
                u[i+1].pb(x);
            }
        }
        
    }
    int ans = -1;
    for(int mask=0;mask<(1<<n);mask++){
        bool flag = true;
        for(int i=0;i<16;i++){
            if(isOn(mask,i)){
                for(int j=0;j<k[i+1].size();j++){
                    if(!isOn(mask,k[i+1][j]-1)){
                        flag = false;
                    }
                }
                for(int j=0;j<u[i+1].size();j++){
                    if(isOn(mask,u[i+1][j]-1)){
                        flag = false;
                    }
                }
                
            }
        }
        if(flag){
            ans = max(ans,__builtin_popcount(mask));
        }
        
    }
    cout<<ans;
    
    

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, t, gcd, ans=1;

ll f(ll p, ll q) {
	if(q==0) return p;
	return f(q, p%q);
}

int main() {
	cin >> n;
	while(n--) {
		cin >> t;
		gcd = f(ans, t);
		ans *= t / gcd;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
S = [*map(int, input().split())]

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    
    L = list(range(n1+1))
    R = list(range(n2+1))
    
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
        
    L[n1] = 100000000000
    R[n2] = 100000000000
    
    i = 0
    j = 0
    
    for k in range(left, right):
        if L[i] < R[j]:
            A[k] = L[i]
            i = i + 1
            
        else:
            A[k] = R[j]
            j = j + 1
            
    return right - left
            
def mergeSort(A, left, right):
    count = 0
    if left+1 < right:
        mid = int((left + right) / 2)
        count += mergeSort(A, left, mid) + mergeSort(A, mid, right)
        count += merge(A, left, mid, right)

    return count

count = mergeSort(S, 0, n)
print(*S)
print(count)


Measured memory_bytes: 63436
from math import sqrt, factorial
from fractions import gcd
from sys import setrecursionlimit
from itertools import combinations
from string import ascii_lowercase as abc
from operator import itemgetter
setrecursionlimit(10000000)

def inpl(): return list(map(int, input().split()))
N, K = inpl()
if K > (N-1)*(N-2)//2:
    print(-1)
else:
    ans = ["{} {}".format(i, N) for i in range(1, N)]
    cnt = (N-1)*(N-2)//2
    for a, b in combinations(range(1, N), r=2):
        if cnt == K:
            break
        else:
            ans.append("{} {}".format(a, b))
            cnt -= 1
    print(len(ans))
    print(*ans, sep="\n")

Measured memory_bytes: 5772
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long mod = 1e9 + 7;

int d, t, s;
void solve(int test){
    if(t * s < d)
        cout << "No";
    else
        cout << "Yes";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int t = 1;
    //cin >> t;
    //for(int test = 1; test <= t; test++){
        cin >> d >> t >> s;
        solve(1);
   // }
    return 0;
}

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

#define ll long long
#define pb push_back

const int maxn = 3e2 + 20;
int mod;

int c[maxn][maxn] , dp[maxn][maxn] , sum[maxn][maxn];

inline void mkay(int &a)
{
	if(a >= mod)
		a -= mod;
	else if(a < 0)
		a += mod;
}

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

	int n , k;
	cin >> n >> k >> mod;

	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= i; j++)
		{
			if(!j || i == j)
				c[i][j] = 1;
			else
				mkay(c[i][j] = c[i - 1][j] + c[i - 1][j - 1]);
		}

	for(int j = k; j >= 0; j--)
	{
		dp[0][j] = 1;
		mkay(sum[0][j] = sum[0][j + 1] + dp[0][j]);
	}

	for(int i = 1; i <= n; i++)
	{
		for(int j = k; j >= 0; j--)
		{
			for(int x = 1; x <= i; x++)
				mkay(dp[i][j] += (1LL * c[i - 1][x - 1] * sum[x - 1][j + 1] % mod) * dp[i - x][j] % mod);
			mkay(sum[i][j] = sum[i][j + 1] + dp[i][j]);
		}
	}

	cout << dp[n][0] << endl;
}
























Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <tuple>
using T = tuple<ll, ll, ll>;

#include <functional>
template<typename T>
class SegmentTreeOneAll {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    Func query_func;
    SegmentTreeOneAll(int _n, T _init, Func up, Func qu) {
        init = _init;
        update_func = up;
        query_func = qu;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int pos, T val) {
        pos += n - 1;
        data[pos] = update_func(data[pos], val);
        while (pos > 0) {
            pos = (pos - 1) / 2;
            data[pos] = query_func(data[2 * pos + 1], data[2 * pos + 2]);
        }
    }
    T query(int l, int r) {
        T res = init;
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                res = query_func(res, data[l]);
            }
            if (!(r & 1)) {
                res = query_func(res, data[r - 1]);
            }
        }
        return res;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<T> d;
    REP(i, 0, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        d.emplace_back(b, a, c);
    }
    sort(d.begin(), d.end());
    auto MIN = [](ll a, ll b) {
        return min(a, b);
    };
    const ll inf = 1LL << 60;
    SegmentTreeOneAll<ll> segtree(n + 1, inf, MIN, MIN);
    segtree.update(1, 0);
    REP(i, 0, m) {
        ll L, R, C;
        tie(R, L, C) = d[i];
        ll mi = segtree.query(L, R + 1);
        segtree.update(R, mi + C);
    }
    ll v = segtree.query(n, n + 1);
    if (v >= inf) {
        cout << -1 << endl;
    } else {
        cout << v << endl;
    }
    return 0;
}


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

#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define lim 100010
#define mod 1e9 + 7
#define INF 1e9
#define REP(i, n) for (int i = 0; i < n; i++)

ll GCD(int x, int y) { return x % y == 0 ? y : GCD(y, x % y); }

int main() {
  int N;
  scanf("%d", &N);
  int P;
  int min = N+1;
  int ans = 0;
  while(N--){
    scanf("%d", &P);
    if(min>P){
      ans++;
      min = P;
    }
  }

  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 256
function main(input) {
  const lines = input.split("\n");
  const N = parseInt(lines.shift());

  const upper = lines.shift().split(' ').map(x => parseInt(x));
  const downer = lines.shift().split(' ').map(x => parseInt(x));

  const cum_up = [upper[0]];
  const cum_down = [downer[0]];

  if (N==1){
    console.log(upper[0] + downer[0]);
    return
  }
  for(var i=1;i<N;i++){
    cum_up.push(cum_up[i-1]+upper[i])
    cum_down.push(cum_down[i-1]+downer[i])
  }

  var result = cum_up[0]+cum_down[N-1];
  for(var i=1;i<N;i++){
    var current = cum_up[i]+cum_down[N-1]-cum_down[i-1]
    if (current > result){result = current;}
  }

  console.log(result);

//  console.log(upper);
//  console.log(cum_up);

//  console.log(downer);
//  console.log(cum_down);

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x.at(i);
  int s = accumulate(x.begin(), x.end(), 0), p = (s + n / 2) / n;
  int ans = 0;
  for (int i = 0; i < n; i++) ans += (x.at(i) - p) * (x.at(i) - p);
  cout << ans << endl;
}


Measured memory_bytes: 256