akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w, h, n;
  cin >> w >> h >> n;
  vector<vector<bool>> vec(w, vector<bool>(h,true));

  REP(i,n) {
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) FOR(j,0,x) FOR(k,0,h) vec[j][k] = false;
    if(a == 2) FOR(j,x,w) FOR(k,0,h) vec[j][k] = false;
    if(a == 3) FOR(j,0,w) FOR(k,0,y) vec[j][k] = false;
    if(a == 4) FOR(j,0,w) FOR(k,y,h) vec[j][k] = false;
  }

  int cnt = 0;
  REP(i,w) {
    REP(j,h) {
      if(vec[i][j]) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
//templete by private_yusuke

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


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
	return 0;
}

Measured memory_bytes: 256
def r_a(x) :
    if x == 'I' :
        return 1
    elif x == 'V' :
        return 5
    elif x == 'X' :
        return 10
    elif x == 'L' :
        return 50
    elif x == 'C' :
        return 100
    elif x == 'D' :
        return 500
    elif x == 'M' :
        return 1000
 
while True :
    try :
        R = list(input())
    except EOFError :
        break
    
    A = 0
    i = 0
    while True :
        if i == len(R)-1 :
            A += r_a(R[-1])
            break
        elif i > len(R)-1 :
            break
        a = R[i]
        b = R[i+1]
        if r_a(a) < r_a(b) :
            A +=  r_a(b) - r_a(a)
            i += 2
        else :
            A += r_a(a)
            i += 1
    print(A)
            


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

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

    int max_v = -2000000000;
    int min_v = r[0];

    for (int i = 1; i < n; ++i) {
        max_v = max(max_v, r[i] - min_v);
        min_v = min(min_v, r[i]);
    }

    cout << max_v << endl;

    return 0;
}


Measured memory_bytes: 3548
n, a, b = gets.strip.split.map(&:to_i)

# 各桁の和を求める
def digit_sum n
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    sum
end

ans = (1..n)
        .map { |i| [i, digit_sum(i)] }
        .select { |d| a <= d[1] && d[1] <= b }
        .inject(0) { |sum, d| sum + d[0] }

puts ans

Measured memory_bytes: 14440
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int p,d,n;
	cin>>n;
	int ara[n];
	for(int i=0;i<n;i++)
	cin>>ara[i];
	sort(ara,ara+n);
	p=n/2;
	d=p-1;
	cout<<ara[p]-ara[d]<<endl;
	return 0;
	
}
	

Measured memory_bytes: 640
s = input()
ind_A = 0
ind_Z = 0
for i in range(len(s)):
    if (s[i] == "A"):
        ind_A = i
        break

for i in reversed(range(len(s))):
    if (s[i] == "Z"):
        ind_Z = i
        break

print(ind_Z - ind_A + 1)


Measured memory_bytes: 3516
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut abv = vec![(0, 0); n];
    for i in 0..n {
        let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
        let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
        abv[i].0 = b;
        abv[i].1 = a;
    }
    abv.sort();
    let mut s = 0;
    let mut ans = true;
    for i in 0..n {
        let (b, a) = abv[i];
        s += a;
        if s > b {
            ans = false;
            break;
        }
    }
    println!("{}", if ans { "Yes" } else { "No" });
}


Measured memory_bytes: 6396
#include<iostream>
using namespace std;
 
int main(){
    int a, b, sum, digit;
    while(cin >> a >> b){
        sum = a + b;
        digit = 0;
        while(sum){
            sum = sum / 10;
            digit++;
        }
        cout << digit << endl;
    };
    return 0;
}


Measured memory_bytes: 2952
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int m = in.nextInt();
		int r = solve(n, m);
		System.out.println(r);
		in.close();
	}

	private static int solve(int n, int m) {
		int r = 0;
		if (n > 1)
			r += (n * (n - 1) / 2);
		if (m > 1)
			r += (m * (m - 1) / 2);
		return r;
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
int main() {
    ll ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;
    ll res = ao + 2 * (ai / 2) + 2 * (aj / 2) + 2 * (al / 2);
    if(ai >= 1 && aj >= 1 && al >= 1) {
        res = max(res, ao + 3 + 2 * ((ai - 1) / 2) + 2 * ((aj - 1) / 2) + (al - 1) / 2 * 2);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
n=int(input())
a=[]
b=[]
for _ in range(n):
    c=list(map(int,input().split()))
    a.append(c[0])
    b.append(c[1])
d=list(zip(b,a))
d.sort()
#print(d)

time=0
for i in range(n):
    time+=d[i][1]
    if d[i][0]<time:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 38280
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define PI 3.141592

using namespace std;

int main() {
	int N;
	cin >> N;

	int result = pow(N, 3);
	printf("%d", result);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() 
{
    int a,b,c,d;
    si(a);si(b);si(c);si(d);
    
    int mn=max(a,c);
    int mx=min(b,d);
    
    if(mn>mx){
        cout<<0<<endl;
        return 0;
    }
    
    cout<<mx-mn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long 
#define mod 1000000007
int main()
{
	ll n,m;
	cin>>n>>m;
	ll a[n+10][n+10],b[m+10][m+10];
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=2;j++)
		{
			cin>>a[i][j];
		}
	}
	for(ll i=1;i<=m;i++)
	{
		for(ll j=1;j<=2;j++)
		{
			cin>>b[i][j];
		}
	}
	for(ll i=1;i<=n;i++)
	{
		ll re=INT_MAX;
		ll aa=0;
		for(ll j=1;j<=m;j++)
		{
			ll q=abs(a[i][1]-b[j][1])+abs(a[i][2]-b[j][2]);
			if(q<re)
			{
				re=q;
				aa=j;
			}
		}
		cout<<aa<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
class Cards {
	int* cards;
	int* temp_cards;
	int size;
	void swap() {
		auto temp = cards;
		cards = temp_cards;
		temp_cards = temp;
	}
public:
	Cards(int s) {
		size = s;
		cards = new int[size];
		temp_cards = new int[size];
		for (auto i = 0; i < size; ++i) {
			cards[i] = i + 1;
		}
	}
	~Cards() {
		delete[] cards, temp_cards;
	}
	void reiffle_shuffle() {
		for (auto i = 0; i < size / 2; ++i) {
			temp_cards[i * 2] = cards[i];
			temp_cards[i * 2 + 1] = cards[i + size / 2];
		}
		swap();
	}
	void cut(int k) {
		for (auto i = 0; i < size; ++i) {
			temp_cards[i] = cards[(i + k) % size];
		}
		swap();
	}
	auto begin() {
		return cards;
	}
	auto end() {
		return cards + size;
	}
};
int main() {
	int n;
	std::cin >> n;
	Cards cards(2 * n);
	int m;
	std::cin >> m;
	int k;
	for (auto i = 0; i < m; ++i) {
		std::cin >> k;
		switch (k) {
		case 0: cards.reiffle_shuffle(); break;
		default: cards.cut(k);
		}
	}
	for (auto &card:cards) {
		std::cout << card << '\n';
	}
}

Measured memory_bytes: 3088
#include<stdio.h>
#define SIZE 5000001

int A[SIZE],B[SIZE],c = 1;

void maxheap(int H,int i){
  int l,r,largest;

  l = i*2;
  r = i*2+1;

  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i){
    l = A[i];
    A[i] = A[largest];
    A[largest] = l;
    maxheap(H,largest);
  }
}

void build(int H){
  int i;
  for(i = H/2;i > 0;i--) maxheap(H,i);
}

void extract(int H){
  B[c] = A[1];
  c++;
  A[1] = A[H];
  maxheap(H--,1);
  }

  void insert(int H){
    int v;
    if(H/2 > 0){
      if(A[H] > A[H/2]){
        v = A[H];
        A[H] = A[H/2];
        A[H/2] = v;
        insert(H/2);
      }
      else return;
    }
  else return;
  }

  int main(){
    int n,i = 0;
    char str[20];

    while(1){
      scanf("%s",&str);
      if(str[0] == 'i'){
        i++;
        scanf("%d",&A[i]);
        insert(i);
      }
      else if(str[1] == 'x'){
        extract(i);
        i--;
      }
      else{
          for(n = 1;n < c;n++){
            printf("%d\n",B[n]);
          }
          break;
        }
    }


    return 0;
  }



Measured memory_bytes: 7572
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll a[20][20];
ll d[65540];
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			cin >>a[i][j];
	for (int i=1;i<(1<<n);i++)
	{
		for (int j=0;j<n;j++)
		{
			if (!(i & (1<<j))) continue;
			for (int k=j+1;k<n;k++) if (i & (1<<k)) d[i]+=a[j][k];
		}
	}
	for (int i=1;i<(1<<n);i++)
		for (int j=i;j>0;j=(j-1)&i) d[i]=max(d[i],d[i^j]+d[j]);
	cout <<d[(1<<n)-1];
	return 0;
}

Measured memory_bytes: 768
use proconio::input;

fn main() {
    input! {
        n: u32,
        m: u32,
        mut a: [u32; n]
    }

    solve(m, &mut a);
}

fn solve(m: u32, a: &[u32]) {
    let s = a.iter().sum::<u32>();

    let cnt = a.iter().filter(|&x| 4 * m * x >= s).count() as u32;
    match cnt.cmp(&m) {
        std::cmp::Ordering::Less => println!("No"),
        _ => println!("Yes"),
    }
}


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

using namespace std;
using nagai = long long;
#define sz(x) int((x).size())

const int N=250250;
char ts[N];
int dir[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,q;
	cin>>n>>q;
	string s;
	cin>>s;
	for(int i=0;i<q;++i){
		 char s;
		 char c;
		 cin>>s>>c;
		 ts[i]=s;
		 dir[i]=c=='R'?1:-1;
	}
	int L=-1,R=n;
	while(R-L>1){
		int M=(L+R)/2;
		int cur=M;
		bool ok=false;
		for(int i=0;i<q;++i){
			 if(s[cur]==ts[i])
				 cur+=dir[i];
			 if(cur==n)
				 break;
			 if(cur==-1){
				  ok=true;
				  break;
			 }
		}
		if(ok)L=M;
		else R=M;
	}
	int kek=L;
	L=-1,R=n;
	while(R-L>1){
		int M=(L+R)/2;
		int cur=M;
		bool ok=false;
		for(int i=0;i<q;++i){
			 if(s[cur]==ts[i])
				 cur+=dir[i];
			 if(cur==-1)
				 break;
			 if(cur==n){
				  ok=true;
				  break;
			 }
		}
		if(ok)R=M;
		else L=M;
	}
	if(kek>=R)cout<<0<<'\n';
	else cout<<R-kek-1<<'\n';
	return 0;
}



Measured memory_bytes: 1556
#include <bits/stdc++.h>///7:07

using namespace std;

#define DIM 200009
#define INF ((long long)1e18+9ll)
#define MODULO 1000000007
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define endl '\n'
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define amen exit(0)

long long i,j,k,l,n,m,sz,C;

long long dp[1009][1009],a[1009][1009];

string s;

int main()
{
    fast;

    cin>>n>>m;
    dp[1][1]=1;
    for(i=1;i<=n;i++){
        cin>>s;
        for(j=1;j<=m;j++){
            if(s[j-1]=='.')dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%MODULO;
            else dp[i][j]=0;
        }
    }

    cout<<dp[n][m]<<endl;

    amen;
}



Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 17
#define B(x) (1<<(x))
using namespace std;
using LL = long long;
int n,a[M][M];
LL sum[1<<M], dp[1<<M];
bool vis[1<<M];

LL dfs(int x) {
    if (x==0) return 0;
    if (vis[x]) return dp[x];
    vis[x] = true;
    LL &res = dp[x];
    res = sum[x];

    for (int i=(x-1)&x; i>0; i=(i-1)&x)
        res = max(res, dfs(i) + dfs(x^i));
    return res;
}
int main()
{
    scanf("%d", &n);
    REP(i,1,n) REP(j,1,n) scanf("%d", &a[i][j]);

    sum[0] = 0;
    REP(i,1,B(n)-1) {
        int low = __lg(i & -i) + 1;
        int j = i ^ B(low-1);
        sum[i] = sum[j];
        REP(k,1,n) if (k!=low && (B(k-1) & i)) sum[i] += a[low][k];
    }

    printf("%lld\n", dfs(B(n)-1));
    return 0;
}


Measured memory_bytes: 4896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
 
using namespace std;
typedef long long ll;

int main(){
	int w, h;
	ll cost = 0;
	cin >> w >> h;	
	vector<pair<ll, ll> > p(w+h);
	for(int i = 0; i < w; i++){
		cin >> p[i].first;
		p[i].second = 0;
	}
	for(int i = w; i < w+h; i++){
		cin >> p[i].first;
		p[i].second = 1;
	}
	sort(p.begin(), p.end());
	int a = w+1;
	int b = h+1;
	for(int i = 0; i < w+h; i++){
		if(p[i].second == 0){
			a--;
			cost += b*p[i].first;
		}else{	
			b--;
			cost += a*p[i].first;
		}
	}
	cout << cost << endl;
	
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int L = 1010;

int main() {
  int N;
  while(cin >>N && N){
    vector<P> v(N);
    REP(i, N) cin >>v[i].first >>v[i].second;
    vector<int> cnt(L, 0);
    cnt[0] = 1;
    REP(i, N){
      vector<int> tmp(L, 0);
      REP(j, L){
        if(cnt[j] <= 0) continue;
        REP(k, v[i].second) if(j + v[i].first * (k + 1) < L) tmp[j + v[i].first * (k + 1)] += cnt[j];
      }
      REP(j, L) cnt[j] += tmp[j];
    }
    int M; cin >>M;
    REP(i, M){
      int p; cin >>p;
      cout <<cnt[p] <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  vector<int> c(m), d(m);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, m) cin >> c[i] >> d[i];

  rep(i, n){
    int p = -1;
    int mi = 1001001001;
    rep(j, m){
      int l = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(chmin(mi, l)) p = j;
    }
    cout << p + 1 << endl;
  }

  return 0;
}


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

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

int lcs(){
    int j,m,n;
    int sum=0;
    int c[1001][1001];
    m = strlen(x);
    n = strlen(y);
    for(i = 0;i < m + 1;i++) c[i][0]=0;
    for(j = 0;j < n + 1;j++) c[0][j]=0;
    for(i = 1;i < m + 1;i++){
        for(j = 1;j < n + 1;j++){
            if(x[i-1] == y[j-1]) c[i][j] = c[i-1][j-1] + 1;
            else c[i][j] = max(c[i-1][j],c[i][j-1]);
            sum = max(sum,c[i][j]);
        }
    }
    return sum;
}

int max(int l,int r){
    if(l<r)return r;
    else return l;
}


Measured memory_bytes: 5716
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort()
if N>=M:
    print(0)
elif N==1:
    print(X[M-1]-X[0])
else:
    L=[]
    for i in range(M-1):
        L.append(X[i+1]-X[i])
    L.sort()
    l=0
    for i in range(1,N):
        l=l+L[M-i-1]
    print(X[M-1]-X[0]-l)

Measured memory_bytes: 13960
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200015

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;

int N,M1,A[maxn],a,b,g[maxn],may[maxn],sol;
map<par,int> M;
int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> M1;

    for(int i=1;i<=N;i++)
        cin >> A[i];

    for(int i=1;i<=M1;i++){
       cin >> a >> b;
       if(a>b)
        swap (a,b);
       if(M.find(par(a,b))!=M.end() )
           continue;
       M[par(a,b)]=1;

       g[a]++,g[b]++;
       if(A[a] > A[b])
        may[a]++;
       if(A[a] < A[b])
        may[b]++;
    }

    for(int i=1;i<=N;i++)
        if(may[i] == g[i])
           sol++;

    cout << sol;







}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int w,n,i,r,l,tmp,res[31];
  for(i=1;i<=30;i++)
      res[i]=i;
  cin >> w;
  cin >> n;
  for(i=0;i<n;i++)
  {
    scanf("%d,%d",&l,&r);
    tmp=res[l];
    res[l]=res[r];
    res[r]=tmp;
  }
  for(i=1;i<=w;i++)
    cout << res[i] << endl;
  return 0;
}
  

Measured memory_bytes: 1240
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, m, q, a[550][550];
signed main() {
	cin >> n >> m >> q;
	for0(i, m) {
		int l, r; cin >> l >> r; a[l][r]++;
	}
	for1(i, n)for1(j, n) { a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1]; }
	for0(i, q) {
		int x, y; cin >> x >> y; x--;
		cout << a[y][y] - a[x][y] - a[y][x] + a[x][x] << endl;
	}
}

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

int main()
{
	int N;
	while (cin >> N, N)
	{
		int cnt = 0;
		for (int i=1; i<=N; i++)
		{
			int a=0, t=i;
			while (t%5 == 0)
			{
				a++;
				t /= 5;
			}
			cnt += a;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 0
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;

const int MAX_Q = 1e5, MAX_N = 1e5;
int q;
int l[MAX_Q], r[MAX_Q];

int judge[MAX_N + 1];
vector<int> p;

int main() {
    for (int i = 2; i <= MAX_N; i++) judge[i] = true;
    for (int i = 2; i <= MAX_N; i++) {
        if (judge[i]) {
            for (int j = i * 2; j <= MAX_N; j += i) {
                judge[j] = false;
            }
        }
    }

    for (int i = 2; 2 * i - 1 <= MAX_N; i++) {
        if (judge[i] && judge[2 * i - 1]) {
            p.push_back(2 * i - 1);
        }
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) scanf("%d %d", &l[i], &r[i]);
    for (int i = 0; i < q; i++) {
        int a = lower_bound(p.begin(), p.end(), l[i]) - p.begin();
        int b = upper_bound(p.begin(), p.end(), r[i]) - p.begin();
        printf("%d\n", b - a);
    }
    return 0;
}


Measured memory_bytes: 2172
// https://atcoder.jp/contests/abc145/tasks/abc145_a

#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll r;
  cin >> r;
  cout << (r * r) << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

string upperCamel(string& s){
	return (char)(s[0]-'a'+'A')+s.substr(1,s.size());
}

int main(void){
	string s;
	while(cin>>s){
		char c;cin>>c;
		if(c=='X')break;
		vector<string> splited;
		string tmp;
		for(int i=0;i<s.size();++i){
			if('A'<=s[i]&&s[i]<='Z'){
				if(i==0){
					tmp+=s[i]-'A'+'a';
					continue;
				}
				splited.push_back(tmp);
				tmp=s[i]-'A'+'a';
			}else if(s[i]=='_'){
				splited.push_back(tmp);
				tmp="";
			}else tmp+=s[i];
		}
		splited.push_back(tmp);
		if(c=='L'){
			for(int i=0;i<splited.size();++i){
				if(i) cout<<upperCamel(splited[i]);
				else cout<<splited[i];
			}
			cout<<endl;
		}else if(c=='U'){
			for(int i=0;i<splited.size();++i){
				cout<<upperCamel(splited[i]);
			}
			cout<<endl;
		}else if(c=='D'){
			for(int i=0;i<splited.size();++i){
				if(i)cout<<"_";
				cout<<splited[i];
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
	int a,b;
	cin>>a>>b;
	if((a>9)or(b>9))
	{
		cout<<-1;
	}
	else
	{
		cout<<a*b;
	}
}



Measured memory_bytes: 256
#include <atcoder/math.hpp>
#include <iostream>

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

using ll = long long;
using namespace std;
using namespace atcoder;

int main(void) {
    int t;
    cin >> t;

    rep(loop, t) {
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }

    return 0;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n>>m;
    	m = m*(m-1)/2;
    	n = n*(n-1)/2;
    	cout<<n+m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
a = [int(i) for i in input().split()]
sum = 0
for i in range(N) :
    sum+=a[i]
ans = 2000000000
suma = 0
for i in range(N) :
    suma += a[i]
    d = abs(sum - 2 * suma)
    if i + 1 < N :
        ans = min(d,ans)
print(ans)

Measured memory_bytes: 23788
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  int a,b,c;
  int rect,square;
  rect = square = 0;
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if((c*c) == (a*a) + (b*b))rect++;
    if(a == b)square++;
  }
  cout << rect << endl;
  cout << square << endl;
}

Measured memory_bytes: 1208
def main():
    from itertools import product
    H, W, K = map(int, input().split())
    G = [list(map(int, list(input()))) for _ in range(H)]

    ans = float('inf')
    for pattern in product([0, 1], repeat=H - 1):
        tmp_ans = 0
        div = [0] + [i for i, p in enumerate(pattern, start=1) if p == 1] + [100]
        grids = []
        for i in range(len(div) - 1):
            grids.append(G[div[i]: div[i + 1]])

        rows = []
        for grid in grids:
            row = []
            for w in range(W):
                v = 0
                for h in range(len(grid)):
                    v += grid[h][w]
                row.append(v)
            rows.append(row)

        w = 0
        d = set()
        df = False
        counts = [0] * len(rows)
        while w < W:
            for i, row in enumerate(rows):
                counts[i] += row[w]

            if [c for c in counts if c > K]:
                if w in d:
                    df = True
                    break
                d.add(w)
                tmp_ans += 1
                counts = [0] * len(rows)
            else:
                w += 1

            if df:
                break
        
        if not df:
            tmp_ans += len(div) - 2
            ans = min(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()

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

typedef long long int ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n, i, j, k, a;
    long double product = 1.0;
    bool flag = true;
    
    cin >> n;
    for (i = 0; i < n; ++i) {
        cin >> a;
        if (a == 0) {
            flag = true;
            product = 0;
            break;
        }
        product *= a;
        //cout << product << ' ';
        if (product > 1000000000000000000 || product <= 0) {
            flag = false;
        }
    }
    if (flag)
        cout << (ll)product << '\n';
    else
        cout << -1 << '\n';
    
    
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(reader.readLine());
		String[] inputs = reader.readLine().split(" ");
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = Integer.parseInt(inputs[i]);
		}
		
		int q = Integer.parseInt(reader.readLine());
		inputs = reader.readLine().split(" ");
		for (int i = 0; i < q; i++) {
			boolean canMakeNumber = checkIfCanMakeNumber(arr, Integer.parseInt(inputs[i]));
			if (canMakeNumber) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}

	private static boolean checkIfCanMakeNumber(int[] arr, int target) {		
		return checkIfCanMakeNumber(0, arr, target);
	}
	
	private static boolean checkIfCanMakeNumber(int idx, int[] arr, int target) {
		
		if (target == 0) {
			return true;
		}
		if (idx >= arr.length) {
			return false;
		}
		
		boolean ret1 = checkIfCanMakeNumber(idx + 1, arr, target);
		boolean ret2 = checkIfCanMakeNumber(idx + 1, arr, target - arr[idx]);
		
		if (ret1 == true || ret2 == true) {
			return true;
		}
		return false;
	}
	
	/*
	private static boolean checkIfCanMakeNumber(int[] arr, int target) {
		return checkIfCanMakeNumber(null, arr, target);
	}

	private static boolean checkIfCanMakeNumber(int[] base, int[] arr, int target) {

		boolean ret = false;		
		if (base != null && base.length > arr.length) {
			return ret;
		}

		int startPos = 0;
		int baseLen = 0;
		if (base != null) {
			baseLen = base.length;
			startPos = base[baseLen - 1] + 1;
		}

		int[] newBase = new int[baseLen + 1];
		for (int i = startPos; i < arr.length; i++) {
			int sum = 0;
			for (int j = 0; j < baseLen; j++) {
				sum += arr[base[j]];
				if (sum == target) {
					
					return true;
				}
				if (sum > target) {
					return false;
				}
				newBase[j] = base[j];
			}
			sum += arr[i];
			if (sum == target) {
				return true;
			}

			newBase[baseLen] = i;
			ret = checkIfCanMakeNumber(newBase, arr, target);
			if (ret == true) {
				return true;
			}
		}
		return ret;
	}
	*/
}


Measured memory_bytes: 24800
#include <bits/stdc++.h>
using namespace std;
int  main(){
    string a[101];
    int h, w; cin >> h >> w;
    for (int i = 0; i < h; ++i){
        cin >> a[i];
    }
    for (int i = 0; i < w + 2; ++i){
        cout << '#';
    }
    cout <<""<< endl;
    for (int i = 0; i < h; ++i) {
        cout << '#' << a[i] << '#' << endl;
    }
    for (int i = 0; i < w + 2; ++i){
        cout << '#';
    }
    cout <<""<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 int main(void)
  {
 char s[10];
  int i=0,cnt=0,max=0;
  scanf("%s", s);
  for(i=0;i<10;i++)
 {
   if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
   cnt++;
    else
   {
   if(cnt > max)
   max = cnt;
   cnt = 0;
   }
     }
    if(cnt > max)
   max = cnt;
  printf("%d", max);
   return 0;
  }

Measured memory_bytes: 128
#include<iostream>
#include<vector>

using namespace std;

int N, M;
vector<int> visited;
vector<vector<int>>G;
int num_visited = 0;
int ans = 0;

void dfs(int now) {
	visited[now]++;
	num_visited++;
	if (num_visited == N) {
		ans++;
	}
	for (int i = 0; i < G[now].size(); i++){
		int next = G[now][i];
		if (!visited[next]) {
			dfs(next);
		}
	}
	visited[now] = 0;
	num_visited--;
}

int main() {
	cin >> N >> M;
	G = vector<vector<int>>(N);
	visited = vector<int>(N, 0);
	for (int i = 0; i < M; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0);
	cout << ans << endl;

	return 0;
}

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

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

int main(){
  int n, m, k, a, b;
  cin >> n >> m >> k;
  UnionFind uf(n);
  vector<int> fr(n,0);
  for(int i=0; i<m; ++i){
    cin >> a >> b;
    --a; --b;
    ++fr[a], ++fr[b];
    uf.unite(a, b);
  }
  vector<int> ans(n);
  for(int i=0; i<n; ++i) ans[i] = uf.size(i) -fr[i] -1;
  for(int i=0; i<k; ++i){
    cin >> a >> b;
    --a; --b;
    if(uf.find(a) == uf.find(b)){
      --ans[a]; --ans[b];
    }
  }
  for(int i=0; i<n; ++i){
    if(i==n-1) cout << ans[i] << endl;
    else cout << ans[i] << " ";
  }
}

Measured memory_bytes: 2048
extension String {
    var asciiValue: UInt32 {
        guard let first = characters.first where characters.count == 1 else  { return 0 }
        return first.unicodeScalarsValue!
    }
    func asciiValueAt(pos pos: UInt32) -> UInt32 {
        guard characters.count > 0 && Int(pos) < characters.count else  { return 0 }
        return Array(characters)[Int(pos)].unicodeScalarsValue!
    }
}
extension Character {
    var unicodeScalarsValue: UInt32? {
        return String(self).unicodeScalars.first?.value
    }
}

var ss = Array(readLine()!.characters)
var K = Int(readLine()!)!

for i in 0 ..< ss.count {
    let number = Int(ss[i].unicodeScalarsValue!)
    if number == 97 {
        continue
    }
    let to = 123 - number
    if to <= K {
        K -= to
        ss[i] = Character("a")
    }
}

if K == 0 {
    print(String(ss))
} else {
    let last = ss.count - 1
    let unicodeScalar = UnicodeScalar((Int(ss[last].unicodeScalarsValue!) + K - 97) % 26 + 97)
    ss[last] = Character(unicodeScalar)
    print(String(ss))
}


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

int main()
{
  int N; cin >> N;
  bool res = false;
  for(int i = 9; i >= 1; i--)
  {
    if(N%i == 0 && N/i <= 9)
      res = true;
  }
  if(res) 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++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int n, l;
  cin >> n >> l;
  int d[200];
  REP(i, n)
  {
    d[i] = l + i;
  }

  int m = 101;
  int mi = -1;
  REP(i, n)
  {
    if (abs(d[i]) < m)
    {
      m = abs(d[i]);
      mi = i;
    }
  }
  int ans = 0;
  REP(i, n)
  {
    if (i == mi)
      continue;
    ans += d[i];
  }

  cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<char> S(N);
    for(int i=0;i<N;i++){
        cin >> S.at(i);
    }
    int count = 0;
    char c[] = {'P', 'W', 'G', 'Y'};
    vector<char> C;
    for(int i=0;i<4;i++){
        C.push_back(c[i]);
    }
    for(int i=0;i<C.size();i++){
        for(int j=0;j<N;j++){
            if(C.at(i) == S.at(j)){
                count++;
                break;
            }
        }
    }
    if (count == 3){
        cout << "Three" << endl;
    }
    else if(count == 4){
        cout << "Four" << endl;
    }
    return 0;
}

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

using namespace std;

#define PB push_back
#define MEM(n, val) memset(n, val, sizeof(n))
#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define ROF(i, j, k) for(int i = j; i >= k; i--)
#define LL long long
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define INF 1999999999
#define MP make_pair
#define LN (node * 2)
#define RN ((node * 2) + 1)
#define MOD 1000000007

int fx[] = {1, -1, 0, 0};
int fy[] = {0, 0, 1, -1};

int n;
LL ara[55];
LL tmp[55];
vector<PLL> ans;

bool jog()   {
    ans.clear();
    ///int mx = -10000000;
    int pos = 1;
    FOR(i, 1, n)   {
        tmp[i] = ara[i];
        ///mx = max(mx, ara[i]);
        if(ara[i] > ara[pos]) {
            ///mx = ara[i];
            pos = i;
        }
    }
    //cout << "pos : " << pos << "\n";
    if(tmp[pos] <= 0) {
        return 0;
    }

    FOR(i, 2, n)   {
        if(tmp[i] >= tmp[i - 1])    {
            continue;
        }
        while(tmp[i] < tmp[i - 1]) {
            ans.PB(MP(pos, i));
            tmp[i] += tmp[pos];
            if(tmp[i] > tmp[pos])    {
                pos = i;
                ///mx = ;
            }
            if(ans.size() > 2 * n)  {
                return 0;
            }
        }
    }
    return 1;
}

bool biyog()   {
    ans.clear();
    ///int mx = -10000000;
    int pos = 1;
    FOR(i, 1, n)   {
        tmp[i] = ara[i];
        if(ara[i] < ara[pos]) {
            ///mx = ara[i];
            pos = i;
        }
    }

    if(tmp[pos] >= 0) {
        return 0;
    }
    ROF(i, n - 1, 1)   {
        if(tmp[i] <= tmp[i + 1])    {
            continue;
        }
        while(tmp[i] > tmp[i + 1]) {
            ans.PB(MP(pos, i));
            tmp[i] += tmp[pos];
            if(tmp[i] < tmp[pos])    {
                pos = i;
                ///mx = ;
            }
            if(ans.size() > 2 * n)  {
                return 0;
            }
        }
    }
    return 1;
}

int main()  {
    std::ios_base::sync_with_stdio(false);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    FOR(i, 1, n)   {
        cin >> ara[i];
    }
    if(jog())   {
        //cout << "hi\n";
        cout << ans.size() << "\n";
        FOR(i, 0, (int)ans.size() - 1)   {
            cout << ans[i].F << " " << ans[i].S << "\n";
        }
        return 0;
    }
    //cout << ans.size() << "\n";
    /**
    FOR(i, 1, n)   {
        cout << tmp[i] << "\n";
    }
    */
    if(biyog())   {
        cout << ans.size() << "\n";
        FOR(i, 0, (int)ans.size() - 1)   {
            cout << ans[i].F << " " << ans[i].S << "\n";
        }
        return 0;
    }
    //cout << ans.size() << "\n";
    bool ha = 1;
    FOR(i, 1, n)   {
        if(ara[i])  {
            ha = 0;
        }
    }
    if(ha)  {
        //cout << "hi\n";
        cout << 0 << "\n";
        return 0;
    }
    ///cout << "hai";
    ///int a = 10 / 0;
    return 0;
}
/**
3
1000001 0 1000000

5
-1 1 -1 1 -1

4
0 0 -1 0


8
10 2 3 -100 1 2 -1000 -100

5
0 1 2 3 -1000



2 0 0
3
-2 -5 -1

3 1000000 1 -1000000

3 -1000000 1 -1000000
*/


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

using namespace std;
#define ll long long



int main(void){
  ll num,larg;
  cin >> num >> larg;
  vector<ll> lon(num);
  for(int i = 0;i < num;i ++){
    cin >> lon[i];
  }
  for(int i = 0;i < num-1;i ++){
    if(lon[i]+lon[i+1]>=larg){
      cout << "Possible" << endl;
      for(int j = 0;j < i;j ++){
        cout << j+1 << endl;
      }
      for(int j = num-1;j > i;j--){
        cout << j << endl;
      }
      return 0;
    }
  }
  cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 4056
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;

const int MAX = 10001;

string data[MAX];
int W,H,N;

struct Button{
  int lx,rx,ly,ry;
  string name;
};

map<string,vector<Button> > M;


void init(){
  M.clear();
  fill(data,data+MAX,"");
}

void input(){
  cin >> W >> H;
  for(int i = 0; i < N; i++){
    string s;
    int num;
    cin >> s >> num;
    if(i == 0) data[0] = s;

    for(int j = 0; j < num; j++){
      Button B;
      cin >> B.lx >> B.ly >> B.rx >> B.ry >> B.name;
      M[s].push_back(B);	
    }

  }
}

void solve(){
  int num;
  cin >> num;
  int index = 0;


  while(num--){
    string op;
    cin >> op;
    if(op == "click"){
      int x,y;
      cin >> x >> y;
      string now = data[index];

      for(int i = 0; i < M[now].size(); i++){
	if(M[now][i].lx <= x && x <= M[now][i].rx && M[now][i].ly <= y && y <= M[now][i].ry){
	  data[++index] = M[now][i].name;
	  fill(data+index+1,data+MAX,"");
	  break;
	}

      }

    }else if(op == "back" && index > 0) index--;
    else if(op == "forward" && data[index+1] != "") index++;
    else if(op == "show") cout << data[index] << endl;
  }
}

int main(){

  while(cin >> N && N){
    input();
    solve();
  }
  return 0;
}

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

int main(){
   ll N;
   cin >> N;
   vector<ll> p(N);
   for(int i =0; i<N; i++) cin >> p[i];
   ll count = 0;
   vector<ll> ps(N);
   ps = p;
   sort(p.begin(), p.end());
   for (int i = 0; i < N; i++){
      if(p[i] != ps[i]){
          count += 1;
      }
   }
   if(count == 0 || count == 2){
       cout << "YES" << endl;
   }else{
       cout << "NO" << endl;
   }

    
}

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

using namespace std;

bool Function(int x)
{
	for (float i = 1; i <= 9; ++i)
	{
		for (float j = 1; j <= 9; ++j)
		{
			if ((x / i) / j == 1.0f) return true;
		}
	}
	return false;
}

int main()
{
	int N;
	cin >> N;

	if (Function(N)) cout << "Yes";
	else cout << "No";

	return 0;
}


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

int     main()
{
    int a, b, c, d;
    
    cin >> a;
    b = a / 3600;
    c = a % 3600 / 60;
    d = a % 3600 % 60;
    
    
    cout << b << ":" << c << ":" << d << endl;
    return(0);
}


Measured memory_bytes: 3084
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 200010
using namespace std;
typedef long long ll;
ll a[MAXN],x,pre[MAXN],ans;
int n;
int main(){
	SF("%d%lld",&n,&x);
	for(int i=1;i<=n;i++){
		SF("%lld",&a[i]);
		pre[i]=pre[i-1]+a[i];
		ans+=a[i]*5ll+2ll*x;
	}
	for(int k=1;k<n;k++){
		ll res=k*x;
		for(int j=n,cnt=1;j>0;cnt++){
			int j1=max(0,j-k);
			ll sum=pre[j]-pre[j1];
			res+=max(5ll,cnt*2ll+1ll)*sum;
			if(res>ans)
				break;
			j=j1;
		}
		ans=min(ans,res);
	}
	PF("%lld",ans+1ll*n*x);
		
}

Measured memory_bytes: 3328
n,m=list(map(int,input().split(" ")))
list_x=list(map(int,input().split(" ")))

list_x.sort()
list_d=[]

if m<=n:
    print(0)
else:
    i=0
    while i<=m-2:
        list_d.append(list_x[i+1]-list_x[i])
        i+=1
    list_d.sort()
    print(sum(list_d[0:m-n:1]))

Measured memory_bytes: 13968
#include<iostream>
using namespace std;
int main(){

    int a,b,n1,n2,n3;
    cin>>a>>b;
    n1=a+b;
    n2=a-b;
    n3=a*b;

        if (n1 >= n2)
    {
        if (n1 >= n3)
            cout <<n1<<endl;
        else
            cout <<n3<<endl;
    }
    else
    {
        if (n2 >= n3)
            cout <<n2<<endl;
        else
            cout <<n3<<endl;
    }
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int numa = scan.nextInt();
        int numb = scan.nextInt();
        int numc = scan.nextInt();
        if(numa == numb && numb == numc && numa == numc){
            System.out.println("No");
        }else if(numa == numb){
            System.out.println("Yes");
        }else if(numa == numc){
            System.out.println("Yes");
        }else if(numb == numc){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        } 
    }   
}

Measured memory_bytes: 23892
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007


int main() {
	LL n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	if (a + b - 1 > n || a*b < n) {
		cout << -1 << endl;
		return 0;
	}
	while (n) {
		int x = min(n - b + 1, a);
		FOR(i, n - x + 1, n + 1) {
			printf("%d ", i);
		}
		n -= x;
		b--;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55;
int n,m,f[N],U[N],V[N],vis[N][N],tot,head[N],nex[N<<1],to[N<<1];
ll dp[N][1<<20];
bool vv[N];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
void dfs(int u,int p)
{
    vv[u]=true;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p)continue;
        dfs(v,u);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        scanf("%d%d",&U[i],&V[i]);
        add(U[i],V[i]);add(V[i],U[i]);
    }
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        vis[u][v]=vis[v][u]=i;
    }
    for(int i=1;i<n;i++)
    {
        memset(vv,false,sizeof(vv));
        dfs(U[i],V[i]);
        for(int j=1;j<=n;j++)
            for(int k=1;k<=n;k++)
            if(vv[j]!=vv[k]&&vis[j][k])
        {
            f[i]|=(1<<vis[j][k]-1);
        }
    }
    dp[0][0]=1;
    int up=1<<m;
    for(int i=0;i<n-1;i++)
        for(int j=0;j<up;j++)
        if(dp[i][j])
        {
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j|f[i+1]]+=dp[i][j];
        }
    printf("%lld\n",dp[n-1][up-1]);
}


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

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>data1(n);
  vector<int>data2(n);
  for(int i = 0;i < n;i++){
    cin >> data1.at(i);
  }
  for(int i = 0;i < n;i++){
    cin >> data2.at(i);
  }
  for(int i = 0;i < n;i++){
    if(data1.at(i)-data2.at(i) > 0){
      ans += data1.at(i)-data2.at(i);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256