akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int w = sc.nextInt();
			int h = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			int r = sc.nextInt();
			
			// 円の中心が存在するべき仮想的な長方形
			int[] virt_rectangle = {r,r,w-r,h-r};
			
			if(	virt_rectangle[0] <= x &&
				virt_rectangle[1] <= y &&
				virt_rectangle[2] >= x &&
				virt_rectangle[3] >= y) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}
			
		}
	}
}


Measured memory_bytes: 26420
#include <iostream>

using namespace std;


typedef struct Card {char suit; int value; } Card;

void printCards(Card* cards, int len) {
    for (int i = 0; i < len; i++) {
        if (i > 0) cout << ' ';
        cout << cards[i].suit << cards[i].value;
    }
    cout << endl;
}

void bubbleSort(Card* cards, int len) {
    for (int i = 0; i < len; i++) {
        for (int j = len - 1; j > i; j--) {
            if (cards[j].value < cards[j - 1].value) {
                Card tmp = cards[j];
                cards[j] = cards[j - 1];
                cards[j - 1] = tmp;
            }
        }
    }
}

void selectionSort(Card* cards, int len) {
    int min;

    for (int i = 0; i < len; i++) {
        min = i;
        for (int j = i; j < len; j++) {
            if (cards[j].value < cards[min].value) {
                min = j;
            }
        }

        if (min != i) {
            Card tmp = cards[min];
            cards[min] = cards[i];
            cards[i] = tmp;
        }
    }
}

bool isStable(Card* stable, Card* obj, int len) {
    for (int i = 0; i < len; i++) {
        if (stable[i].suit != obj[i].suit)
            return false;
    }
    return true;
}

int main() {
    int N;
    Card arr1[36];
    Card arr2[36];

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> arr1[i].suit >> arr1[i].value;
    }
    for (int i = 0; i < N; i++) arr2[i] = arr1[i];

    bubbleSort(arr1, N);
    selectionSort(arr2, N);
    printCards(arr1, N);
    cout << "Stable" << endl;

    printCards(arr2, N);
    if (isStable(arr1, arr2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
}


Measured memory_bytes: 3084
import sys
from collections import deque
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, D, A = map(int, input().split())
XH = list(tuple(map(int, input().split())) for _ in range(N))
XH.sort()

ans = 0
memo = deque()
cnt = 0
for x, h in XH:
    while memo and memo[0][0] < x:
        _, i = memo.popleft()
        cnt -= i
    h -= cnt * A
    h = max(h, 0)
    bomb = (h + A - 1) // A
    ans += bomb
    cnt += bomb
    memo.append((x + 2 * D, bomb))

print(ans)

Measured memory_bytes: 55748
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int m,n;
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    int now=0,turn=0;
    vi masu(1005,INF),sai(1005);
    rep(i,n)cin>>masu[i];
    rep(i,m)cin>>sai[i];

    rep(i,m){
      if(INF<=now||masu[now]==INF)break;
      now+=sai[i];
      now=max(now,0);
      now=now+masu[now];
      now=max(now,0);
      turn++;
    }
    cout<<turn<<endl;
  }
  return 0;
}

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

int main() {
    int N, A, B, p1, p2;
    cin >> N >> A >> B;

    p1 = N * A;
    p2 = B;
    if (p1 < p2) {
        cout << p1 << endl;
    } else {
        cout << p2 << endl;
    }
}


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

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

  deque<int> data;
  for(int i=0; i<N; i++){
    cin >> buf;
    if(i%2==0) data.push_front(buf);
    else       data.push_back(buf);
  }

  while(data.size() > 1){
    if(N%2==1){
      buf= data.front();
      data.pop_front();
    }
    else{
      buf= data.back();
      data.pop_back();
    }
    cout << buf <<" ";
  }
  cout << data.front() << endl;
}

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

#define debug(...)   printf( __VA_ARGS__ )
//#define debug(...)   /****nothing****/

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define nopos string::npos
#define fr(i,a,b) for(i=a;i<=b;i++)
#define frn(i,a,b) for(i=a;i>=b;i--)

int n,m,i,j,k,mn1,mn2;
pii ar1[60],ar2[60];
int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
    cin>>n>>m;
    fr(i,1,n)
     cin>>ar1[i].first>>ar1[i].second;

    fr(i,1,m)
     cin>>ar2[i].first>>ar2[i].second;

    fr(i,1,n)
     {
         mn1=2e9;
//         cout<<mn1<<'\n';
         mn2=80;
         fr(j,1,m)
          {
              int dis=abs(ar1[i].first-ar2[j].first)+abs(ar1[i].second-ar2[j].second);
//              cout<<i<<" "<<dis<<'\n';
              if(dis<mn1 )
                mn1=dis , mn2=j;
          }
        cout<<mn2<<'\n';
     }



    return 0;
}





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

const int N = 1e9 + 7;

int main(){
	
	int n;
	scanf("%d", &n);
	vector <int> arr(n), ans(n, N);
	for(int& i : arr){
		scanf("%d", &i);
	}
	ans[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j != i+3; j++){
			if(j < n){
				ans[j] = min(ans[j], ans[i]+abs(arr[i]-arr[j]));
			}
		}
	}
	printf("%d", ans[n-1]);
}

Measured memory_bytes: 3932
#include<iostream>
#include<vector>
#define INF 1e9
using namespace std;

struct activity {
    // Stores Happiness Points
    int A, B, C;
};

// Bottom Up DPS
int vacationBottomUp(vector<activity> arr, int n) {
    // 1 Based Indexing
    int dp[n + 1][3] = {0}; // Memory
    // Init. Base Cases
    dp[1][0] = arr[1].A;
    dp[1][1] = arr[1].B;
    dp[1][2] = arr[1].C;
    // Iteratively Calculating For All Other Valid Values
    for(int i = 2; i <= n; i++) {
        dp[i][0] = (arr[i].A + max(dp[i - 1][1], dp[i - 1][2]));
        dp[i][1] = (arr[i].B + max(dp[i - 1][0], dp[i - 1][2]));
        dp[i][2] = (arr[i].C + max(dp[i - 1][0], dp[i - 1][1]));
    }
    return (max(dp[n][0], max(dp[n][1], dp[n][2])));
}

int main() {
    int n;
    cin >> n;
    vector<activity> arr(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> arr[i].A;
        cin >> arr[i].B;
        cin >> arr[i].C;
    }
    // Bottom Up Approach
    cout << vacationBottomUp(arr, n) << endl;
    return 0;
}

Measured memory_bytes: 6640
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int ax, ay, bx, by,a,b;
	cin >> ax >> ay >> bx >> by;
	a = ax - bx;
	b = ay - by;
	cout << bx + b << " ";
	cout << by - a << " ";
	cout << ax + b << " ";
	cout << ay - a << endl;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
s=list(input())
sr=set()
sg=set()
sb=set()
for ii in range(n):
    if s[ii]=="R":
        sr.add(ii)
    if s[ii]=="G":
        sg.add(ii)
    if s[ii]=="B":
        sb.add(ii)
l=[len(sr),len(sg),len(sb)]
l.sort()

if l[0]==len(sr):
  s1=sr
  if l[1]==len(sg):
    s2=sg
    s3=sb
  else:
    s2=sb
    s3=sg
elif l[0]==len(sg):
  s1=sg
  if l[1]==len(sr):
    s2=sr
    s3=sb
  else:
    s2=sb
    s3=sr
else:
  s1=sb
  if l[1]==len(sr):
    s2=sr
    s3=sg
  else:
    s2=sg
    s3=sr
  
r=0
for ii in s1:
  for jj in s2:
    r+=len(s3)
    dt=abs(ii-jj)
    if ii+dt in s3:
      r-=1
    if ii-dt in s3:
      r-=1
    if jj+dt in s3:
      r-=1
    if jj-dt in s3:
      r-=1
    if (ii+jj)%2==0:
      if (ii+jj)//2 in s3:
        r-=1
      
print(r)

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

int main(){
  int N,K,sum=0;
  cin >> N >> K;
  
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if (x>=K) sum+=2*(x-K);
    else if(K>x&&K-x<x) sum += 2*(K-x);
    else sum+=x*2;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
function Main(input) {
    var N = parseInt(input[0], 10);
    var S = input[1].split('');
    var T = input[2].split('');
    var result = '';

    for(var i = 0; i < N; i++) {
        result += S[i];
        result += T[i];
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
ll x;
int main(){
	cin>>x;
	if(x>=1200)puts("ARC");
	else puts("ABC");
	return 0;
}


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

using namespace std;

vector<string> ans;

void addChar(int n, string s, char mx) {
    if (!n) ans.push_back(s);
    else for (char c = 'a'; c <= mx + 1; ++c) {
        addChar(n - 1, s + c, max(mx, c));
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    addChar(n - 1, "a", 'a');
    sort(ans.begin(), ans.end());
    for (auto i = ans.begin(); i != ans.end(); ++i) cout << *i << endl;
    return 0;
}


Measured memory_bytes: 7796
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll a,b,c; cin >> a >> b >> c; ll ans = 0;
  ll am = a % 2; ll bm = b % 2; ll cm = c % 2;
  
  ll d = am+bm+cm;
  
  if(d == 1 or d == 2) ans++;
  if(d == 1){
    if(am == 0) a++;
    if(bm == 0) b++;
    if(cm == 0) c++;
  }
  if(d == 2){
    if(am == 1) a++;
    if(bm == 1) b++;
    if(cm == 1) c++;
  }
  
  ll e = max({a,b,c});
  
  ans += (e-a)/2 + (e-b)/2 + (e-c)/2;
  
  cout << ans << endl;
  
  
}
  
  
  
  
    

Measured memory_bytes: 3608
from operator import mul
from functools import reduce

def nCr(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int, input().split())
MOD = 10 ** 9 + 7

for i in range(1, K + 1):
    if i > N - K + 1:
        ans = 0
    else:
        ans = nCr(K - 1, i - 1) * nCr(N - K + 1, i) % MOD
    print(ans)


Measured memory_bytes: 3944
def main():

    N, A, B = map(int, input().split())
    S = input()
    cnt = 0
    cnt1 = 0
    for i in range(N):
        if S[i] == "a":
            if cnt < A+B:
                cnt += 1
                print("Yes")
            else:
                print("No")
        elif S[i] == "b":
            if cnt < A+B and cnt1 < B:
                cnt += 1
                cnt1 += 1
                print("Yes")
            else:
                print("No")
        else:
            print("No")

if __name__ == '__main__':
    # print(main())
    main()

Measured memory_bytes: 4016
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] a = in.nextIntArray(3);
            out.println(a[0] * a[1] / 2);
        }

    }

    static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        public InputReader(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
            st = new StringTokenizer("");
        }

        public String nextString() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

    }
}



Measured memory_bytes: 21460
from sys import stdin
input = stdin.readline

N = int(input())
x1,y1,t1 = 0,0,0
for _ in range(N):
    t2,x2,y2 = map(int, input().split())
    X, Y, T = abs(x2 - x1), abs(y2 - y1), t2 - t1
    if X + Y > T or (T - X - Y) % 2 == 1:
        print('No')
        exit()
    x1, y1, t1 = x2, y2, t2
print('Yes')

Measured memory_bytes: 3064
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("C_input.txt")
else:
    f=sys.stdin
mod=1
ans=0
N=int(f.readline().strip())
if N%2==0 or N%5==0:
    print("-1")
else:
    if N%7==0:
        A=N*9/7
    else:
        A=N*9
    while True:
        ans+=1
        mod=(10*mod)%A
        if mod==1:
            print(ans)
            break
f.close()

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

using ll=long long;

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  for (int i=0;i<N;i++){
    if(v.at(i)!=i+1 && v.at(v.at(i)-1)==i+1){
      v.at(v.at(i)-1)=v.at(i);
      v.at(i)=i+1;
      break;
    }
  }
  bool flag=true;
  for (int i=0;i<N;i++){
    if(v.at(i)!=i+1)
       flag=false;
  }
  if(flag)
    cout <<"YES"<< endl;
  else
    cout<<"NO"<<endl;
   
}

Measured memory_bytes: 256
#include <iostream> 
#include <stdlib.h> 
#include <string.h> 
#include <string> 
#include <sstream>
#include <cstring> 
#include<cmath>
using namespace std;
int main()
{
    string x; int a = -1, b = 0;
    cin >> x;
    for (int i = 0; i < x.size(); i++) {
        if (x[i] == 'A' && a == -1) {
            a = i;
        }
        if (x[i] == 'Z' && a != -1)
            b = i;
    }
    cout << b - a + 1;
    return 0;
}

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

int main(){
	int n,pa,pb,ca,cb[100],bc,tc = 0,tmp;
	cin >> n >> pa >> pb >> ca;
	for(int i = 0;i < n;++i){
		cin >> cb[i];
	}
	sort(cb,cb+n,greater<int>());
	bc = ca /pa;
	for(int i = 0;i < n;++i){
		tc += cb[i];
		tmp = (tc + ca) / (pa + (pb * (i + 1)));
		if(tmp > bc){
			bc = tmp;
		}
	}
	cout << bc << endl;
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<stack>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
typedef long long ll;
using namespace std;
typedef pair<int, int> P;
char a[52][52];
int def[52][52];
int H, W;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 };
int main() {
	IOS;	
	cin >> H >> W;
	memset(a, '0', sizeof(a));
	int i, j;
	int cnt = 0;
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			cin >> a[i][j];
			if (a[i][j] == '.')cnt ++;
		}
	}
	memset(def, -1, sizeof(def));
	def[1][1] = 0;
	queue<P> que;
	que.push(P(1, 1));
	while (!que.empty()) {
		P p = que.front();
		que.pop();
		if (p.first == H && p.second == W)break;
		for (i = 0; i < 4; i++) {
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if (nx > 0 && nx <= W&&ny > 0 && ny <= H&&a[ny][nx] == '.'&&def[ny][nx] == -1) {
				def[ny][nx] = def[p.first][p.second] + 1;
				que.push(P(ny, nx));
			}
		}
	}
	if (def[H][W] == -1)cout << -1 << endl;
	else {
		int ans = cnt - def[H][W] - 1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
using System;

namespace _1_2c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] hoge = Console.ReadLine().Split(' ');
            int a = int.Parse(hoge[0]);
            int b = int.Parse(hoge[1]);
            int c = int.Parse(hoge[2]);

            if (a < b)
            {
                if (b < c)
                {
                    Console.WriteLine("{0} {1} {2}", a, b, c);
                }
                else if( c < a)
                {
                    Console.WriteLine("{0} {1} {2}", c, a, b);
                }
                else
                {
                    Console.WriteLine("{0} {1} {2}", a, c, b);
                }

            }
            else
            {
                if (a < c)
                {
                    Console.WriteLine("{0} {1} {2}", b, a,c);
                }
                else if (b > c)
                {
                    Console.WriteLine("{0} {1} {2}", c, b, a);
                }
                else
                {
                    Console.WriteLine("{0} {1} {2}", b, c, a);
                }
            }

          
        }
    }
}



Measured memory_bytes: 15980
/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock()*1.0 / CLOCKS_PER_SEC << endl;
#define ffe freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
 
int main() {
  ioso
  #ifndef ONLINE_JUDGE
  ffe
  #endif
  ll n; cin >> n;

  cout << ((n==0) ? 1 : 0)<< endl;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> ans(n);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        a--;
        ans[a] = i;
    }
    for(int i = 0; i < n; i++){
        cout << ans[i]+1;
        if(i == n-1) cout << endl;
        else cout << " ";
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int h, w, K;
    cin >> h >> w >> K;
    int sx, sy, gx, gy;
    cin >> sx >> sy >> gx >> gy;
    string s[h+2];
    rep(i,h+2){
        if(i == 0 || i == h + 1){
            rep(j,w+2)s[i] += '@';
        }else{
            string ss;
            cin >> ss;
            s[i] = '@' + ss + '@';
        }
    }

    pair<int,P> p;
    priority_queue<pair<int,P>,vector<pair<int,P>>,greater<pair<int,P>>> que;

    int dp[h+2][w+2];
    int look[h+2][w+2][4];
    rep(i,h+2){
        rep(j,w+2){
            if(s[i][j] == '@') dp[i][j] = -1;
            else dp[i][j] = 1001001001;
            rep(k,4)look[i][j][k] = 0;
        }
    }

    p.first = 0;
    p.second.first = sx;
    p.second.second = sy;
    dp[sx][sy] = 0;

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

    que.push(p);
    while(que.size() > 0){
        p = que.top();
        que.pop();
        int val = p.first;
        int x = p.second.first;
        int y = p.second.second;
        if(val > dp[x][y])continue;
        // cout << x << y << endl;
        rep(i,4){
            if(look[x][y][i] == 1) continue;
            srep(j,1,K+1){
                int nx = x + dx[i] * j;
                int ny = y + dy[i] * j;
                if(s[nx][ny] == '@')break;
                if(s[nx][ny] == '.' && dp[nx][ny] > dp[x][y] + 1){
                    dp[nx][ny] = val + 1;
                    p.first = val + 1;
                    p.second.first = nx;
                    p.second.second = ny;
                    que.push(p);
                    if(j < K)look[nx][ny][i] = 1;
                    int ii = i + 1;
                    if(ii % 2 == 0)ii -= 2;
                    look[nx][ny][ii] = 1;
                }else if(dp[nx][ny] <= dp[x][y]){
                    break;
                }
            }
            look[x][y][i] = 1;
        }
    }


    if(dp[gx][gy] == 1001001001) dp[gx][gy] = -1;
    cout << dp[gx][gy] << endl;
    return 0;
}




Measured memory_bytes: 66684
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# dfsの様々な実装例 in Python
# https://qiita.com/drken/items/a803d4fc4a727e02f7ba
# BEGIN CUT HERE


# v : 現在探索中の頂点，p : vの親（v が親のときは -1）
def dfs_tree(G,v,p):
    '''木上のdfsの実装例'''
    for nv in G[v]:
        if nv == p:
            continue
        dfs_tree(G, nv, v)
def main1():
    N = ii()
    G = [[] for i in range(N)]
    for i in range(N - 1):
        a, b = mi()
        G[a].append(b)
        G[b].append(a)
    
    root = 0
    dfs_tree(G, root, -1)

# 0を頂点とした木の根からの深さ，各頂点を根とした部分木のサイズを求める
# さっきのやつからすこし改造する
depth = [0] * (10 ** 5 + 10)
subtree_size = [0] * (10 ** 5 + 10)
# d : 頂点 v の深さ
def dfs_tree_kai(G, v, p, d):
    
    depth[v] = d
    for nv in G[v]:
        if nv == p:
            continue
        else:
            dfs_tree_kai(G, nv, v, d + 1)
    
    # 帰りがけ時に，部分木のサイズを求める
    subtree_size[v] = 1  # 自分自身
    for c in G[v]:
        if c == p:
            continue
        subtree_size[v] += subtree_size[c]
    return depth, subtree_size

def main2():
    '''木DPの簡単な例（部分木のサイズを求める）'''
    N = ii()
    G = [[] for i in range(N)]
    for i in range(N - 1):
        a, b = mi()
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    
    root = 0  # 仮に頂点0を根とする
    dfs_tree_kai(G, root, -1, 0)
    
    for v in range(N):
        print(v, ": depth = ", depth[v], ", subtree_size = ", subtree_size[v])
    
def EDPC_P():
    N = ii()
    dp = [[1, 1] for _ in range(N)]
    G = [[] for i in range(N)]
    for _ in range(N - 1):
        a, b = mi()
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    def dfs_EDPC_P(G, v, p):
        for nv in G[v]:
            if nv == p:
                continue
            dfs_EDPC_P(G, nv, v)
        for c in G[v]:
            if c == p:
                continue
            dp[v][0] *= (dp[c][0] + dp[c][1]) % (10 ** 9 + 7)
            dp[v][1] *= dp[c][0]
    dfs_EDPC_P(G,0,-1)
    print((dp[0][0]+dp[0][1])%(10**9+7))
    
# END CUT HERE

if __name__ == '__main__':
    EDPC_P()

Measured memory_bytes: 131116
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int a[3];
    rep(i, 0, 3)
        cin >> a[i];
    sort(a, a + 3);
    
    int diff = a[2] * 2 - a[1] - a[0];
    int ans;
    if (diff % 2 == 0)
        ans = diff / 2;
    else
    {
        ans = (diff + 1 + 2) / 2;
    }
    cout << ans <<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

ll dp[1000005][4];

int main(){
    ll n;
    cin >> n;
    dp[0][0] = 1;
    dp[0][1] = 0;
    dp[0][2] = 0;
    dp[0][3] = 0;
    rep(i, n){
        dp[i+1][0] = (dp[i][0] * 8) % mod;
        dp[i+1][1] = (dp[i][0] + (dp[i][1] * 9) % mod) % mod;
        dp[i+1][2] = (dp[i][0] + (dp[i][2] * 9) % mod) % mod;
        dp[i+1][3] = (dp[i][1] + dp[i][2] + (dp[i][3] * 10) % mod) % mod;
    }
    cout << dp[n][3] << endl;
}

Measured memory_bytes: 34688
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++ ) {
			A[i] = scan.nextInt();
		}
		scan.close();
		int r = selectionSort(A, N);
		for(int i=0; i<=N-1; i++) {
			if(0<i) {
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		System.out.println(r);
	}

	private static int selectionSort(int[] A, int N) {
		int replaceCount = 0;
		for(int i=0; i<=N-1; i++) {
			int minj = i;
			for(int j=i; j<=N-1; j++) {
				if(A[j] < A[minj]) {
					minj = j;
				}
			}
			int t = A[i];
			A[i] = A[minj];
			A[minj] = t;
			if(i!=minj) {
				replaceCount++;
			}
		}
		return replaceCount;
	}

}


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

bool p[1 << 10][10];//lock, nextorder
bool used[1 << 10][10];
int N;
string s;

struct State{
	int lock, nextorder;
};
int main(){
	while(cin >> N,N){
		cin >> s;
		s = 'u' + s;
		N++;
		int Lock = 0;
		int nextOrder;
		bool deadLock = false;
		// single thread
		REP(i,N){
			if(s[i] == 'u' && s[i + 1] == 'u') continue;
			int nowOrder = s[i] - '0';
			if(isdigit(s[i])){
				if(Lock & (1 << nowOrder)){
					deadLock = true;
					break;
				}
				Lock |= (1 << (nowOrder));
			}else{
				Lock = 0;
			}
			if(i + 1 < N && isdigit(s[i + 1])){
				nextOrder = s[i + 1] - '0';
				p[Lock][nextOrder] = true;
			}
		}
		// multi thread
		REP(lock_s,1 << 10){
			if(deadLock) break;
			REP(next_s,10){
				if(!p[lock_s][next_s]) continue;
				queue<State> que;
				que.push({lock_s, next_s});
				while(!que.empty()){
					State state = que.front();
					que.pop();
					int lock_i = state.lock;
					int next_i = state.nextorder;
					REP(lock_j,1 << 10){
						if(lock_i & lock_j) continue;
						REP(next_j,10){
							if(!p[lock_j][next_j]) continue;
							int locks = lock_i | lock_j;
							if((1 << next_i) & lock_j && (1 << next_j) & lock_i){
								deadLock = true;
								break;
							}
							if((lock_j & (1 << next_i)) && !used[locks][next_j]){
								que.push({locks, next_j});
								used[locks][next_j] = true;
							}
							if((lock_i & (1 << next_j)) && !used[locks][next_i]){
								que.push({locks, next_i});
								used[locks][next_i] = true;
							}
						}
						if(deadLock) break;
					}
					if(deadLock) break;
				}
				if(deadLock) break;
			}
		}
		if(deadLock){
			cout << "UNSAFE" << endl;
		}else{
			cout << "SAFE" << endl;
		}
		fill(p[0], p[1 << 10], false);
		fill(used[0], used[1 << 10], false);
	}
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr int INF = 1 << 30;

ll h, w;
string a[22];
int dx[4] = {0, -1, 1, 0};
int dy[4] = {1, 0, 0, -1};


int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> h >> w;
  REP(i, h) cin >> a[i];

  int ans = 0;
  for(int i = 0; i < h; ++i) 
    for(int j = 0; j < w; ++j) 
      for(int k = 0; k < h; ++k) 
        for(int l = 0; l < w; ++l) {
          if (a[i][j] == '#' || a[k][l] == '#') continue;
          vector<vector<int>> dist(h, vector<int>(w, INF));
          queue<pair<int,int>> q;
          dist[i][j] = 0;
          q.emplace(i, j);
          while(q.size()) {
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            for(int d = 0; d < 4; ++d) {
              int ny = y + dy[d];
              int nx = x + dx[d];
              if(0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.') {
                if (dist[ny][nx] > dist[y][x] + 1) {
                  dist[ny][nx] = dist[y][x] + 1;
                  q.emplace(ny, nx);
                }
              }
            }
          }
          ans = max(ans, dist[k][l]);
        }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	
	int x;
	cin >> x;
	if (x < 1200)cout << "ABC";
	else cout << "ARC";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B,C,D;
  cin >> N;
  A=N/1000;
  B=(N-A*1000)/100;
  C=(N-A*1000-B*100)/10;
  D=(N-A*1000-B*100-C*10);
  if(A==B && B==C){
    cout << "Yes" << endl;
  }
  else if(B==C && C==D){
    cout << "Yes" << endl;
  }
  else if(A==B && B==C && C==D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;

vector<int> to[100005];
vector<int> dist;
int n;

void dfs(int v, int s = 0, int p = -1) {
	dist[v] = s;
	for (int u : to[v]) {
		if (u == p) continue;
		dfs(u, s + 1, v);
	}
}

vector<int> calcDist(int s) {
	dist = vector<int>(n);
	dfs(s);
	return dist;
}

int main() {
	int u, v;
	cin >> n >> u >> v;
	--u; --v;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int ans = 0;
	vector<int> A = calcDist(u);
	vector<int> T = calcDist(v);
	for (int i = 0; i < n; ++i) {
		if (A[i] < T[i]) {
			ans = max(ans, T[i]-1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10744
s=input()
K=int(input())
 
def rec(s):
    length=len(s)
    ret=set()
    for depth in range(length):
        string=s[depth]
        ret.add(string)
        for i in range(depth+1,depth+K):
            if i<length:
                string+=s[i]
                ret.add(string)
    return ret
  
ret=rec(s)
print(sorted(ret)[K-1])

Measured memory_bytes: 4464
#include<iostream>
#include<string>
#include <cctype>
#include<cmath>

using namespace std;

int main(void) {
	int N, cou, cou2;
	cin >> N;
	cou = 0;
	cou2 = 0;

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

		for (int j = 1; j <= N; j++) {
			if (i % 2 == 1) {
				if (i % j == 0) {
					cou++;
					
				}
			}
		}
		if (cou == 8) {
			cou2++;
		}
		cou = 0;
	}
	cout << cou2 << endl;


}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int h,w; cin >> h >> w;
    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    vvi c(h, vi(w));
    int idx = 0;
    rep(i,h){
        if(i & 1){
            rrep(j,w){
                if(a[idx] == 0) idx++;
                c[i][j] = idx + 1;
                a[idx]--;
            }
        }else{
            rep(j,w){
                if(a[idx] == 0) idx++;
                c[i][j] = idx + 1;
                a[idx]--;

            }
        }
    }
    rep(i,h) cout << join(c[i], " ") << endl;
    return 0;
}

Measured memory_bytes: 3744
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

def sumDigits(n):
    sum = 0
    while n > 0:
        sum += n%10
        n = n // 10
    return sum
N = II()
Sn = sumDigits(N)
if N%Sn == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int sum=0;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        sum+=b-a+1;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define MP make_pair
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;

/*** chmax, chmin ***/
// a < b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
// a > b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b; 
		return true;
	}
	return false;
}
/*** chmax, chmin ここまで ***/

void Main()
{
  	int h, w;
	cin >> h >> w;
    vvi data(h,vector<int>(w,1));
    string s;
    rep(i,h) {
      	cin >> s;
        rep(j,w){
    		if(s[j] == '.'){
            	data[i][j] = 0;
           	}
        }
    }
    
    vvi seen(h,vector<int>(w));
    vvi dist(h,vector<int>(w));
    vvi zero(h,vector<int>(w,0));
    queue<pii> q;
    int tempi,tempj,mx;
    int ans = 0;
    	 
    auto inrange = [&](int x, int y){
      return (x>=0 && x<h && y>=0 && y<w && seen[x][y] == 0);
    };
  	
  	vector<int> adjx = {1, -1, 0, 0};
  	vector<int> adjy = {0, 0, 1, -1};
  
    rep(i,h){
        rep(j,w){
            // bfs(i,j);
          	mx = 0;
            if(data[i][j] == 0){
                seen = data;
                dist = zero;
                seen[i][j] = 1;
                q.push(MP(i,j));
                while(!q.empty()){
                    tempi = q.front().first;
                    tempj = q.front().second;
                    q.pop();
                  	rep(k,4){
                      	int tempx = tempi+adjx[k];
                      	int tempy = tempj+adjy[k];
                  		if(inrange(tempx, tempy)) {
                        	q.push(MP(tempx, tempy));
                        	seen[tempx][tempy] = 1;
                        	dist[tempx][tempy] = dist[tempi][tempj]+1;
                          	chmax(mx, dist[tempx][tempy]);
                        }
                    }                  
                }
            	chmax(ans, mx);
            }
        }
    }
  
    cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;
int main(){
	string s;
  cin >> s;
  if(s == "SUN"){
  	cout << 7;
  }else if(s == "MON"){
  	cout << 6;
  }else if(s == "TUE"){
  	cout << 5;
  }else if(s == "WED"){
  	cout << 4;
  }else if(s == "THU"){
  	cout << 3;
  }else if(s == "FRI"){
  	cout << 2;
  }else if(s == "SAT"){
  	cout << 1;
  }
}

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

const int maxn = 2005;
int a[maxn];
int d[maxn][2];

signed main() {
#ifdef LOCAL
  assert(freopen("d.in", "r", stdin));
#endif
  int n, A, B;
  cin >> n >> A >> B;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int res = abs(a[n - 1] - B);
  for (int i = n - 2; i >= 0; --i) {
    d[i][0] = d[i][1] = abs(a[i] - a[n - 1]);
    for (int j = i + 1; j < n - 1; ++j) {
      d[i][0] = min(d[i][0], d[j][1]);
      d[i][1] = max(d[i][1], d[j][0]);
    }
    res = max(res, d[i][0]);
  }
  cout << res << '\n';
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
bad = set()
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        bad.add(b)
    elif h[b-1] > h[a-1]:
        bad.add(a)
    elif h[a-1] == h[b-1]:
        bad.add(a)
        bad.add(b)

print(n-len(bad))


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

int main() {
	int n, t;
	cin >> n >> t;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (x[i] - x[i - 1] >= t) ans += t;
		else ans += x[i] - x[i - 1];
	}
	cout << ans + t << endl;
	return 0;
}

Measured memory_bytes: 3900
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,k,s,mn=1e9;
int a[5010];
bool f[5010];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x>=k)continue;
		a[++s]=x;
	}
	sort(a+1,a+s+1);
	f[0]=true;
	for(int i=s;i>=1;i--)
	{
		bool ff=false;
		for(int j=k-1;j>=0;j--)
		{
			if(f[j])
			{
				if(j+a[i]<k)f[j+a[i]]=true;else ff=true;
			}
		}
		if(ff)
		{
			mn=min(mn,i);
		}
	}
	if(mn==1e9)printf("%d",s);else printf("%d",mn-1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,M,p,x,sum1,sum=0;
    cin>>N;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sum1=sum;
    cin>>M;
    int a2[M];
    for(int j=0;j<M;j++){
        cin>>p>>x;
        sum1-=a[p-1];
        sum1+=x;
        a2[j]=sum1;
        sum1=sum;
    }
    for(int z=0;z<M;z++)
        printf("%d\n",a2[z]);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  cout << n*(n+1)/2 << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<deque>
#include<utility>
#include<string>
#include<set>
#include<math.h>
#include<iterator>
#include<queue>
#include<algorithm>
using namespace std;

long long i, n, k, sum;
long long a[10000];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for (i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	for (i = 1; i <= k; i++) {
		sum += a[i];
	}
	cout << sum;
}

Measured memory_bytes: 3608
#include<stdio.h>

double r,l;
int i,a[9],b[9];

int main(){
	for(i=0;i<5;i++)a[i]=b[i]=0;
	while(scanf("%lf%lf",&l,&r)!=EOF){
		if(l<0.2)a[3]++;
		else if(l<0.6)a[2]++;
		else if(l<1.1)a[1]++;
		else a[0]++;
		if(r<0.2)b[3]++;
		else if(r<0.6)b[2]++;
		else if(r<1.1)b[1]++;
		else b[0]++;
	}
	for(i=0;i<4;i++)printf("%d %d\n",a[i],b[i]);
	
	return 0;
}

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

int main(){
    string s;
    cin >> s ;
    int size=s.size();
    int count1 =0,count2=0;
    if(size==1){
        cout << 0 << endl;
        return 0;    
    }
    for(int i=0;i<size;i++){
        if(i%2==0){
            if(s.at(i)!='1'){count1++;}
            if(s.at(i)!='0'){count2++;}
        }else{
            if(s.at(i)!='0'){count1++;}
            if(s.at(i)!='1'){count2++;}
        }
    }

    int ans=min(count1,count2);

    cout << ans << endl;
    
}

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

using namespace std;
typedef long long ll;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint
{
   ll x; // typedef long long ll;
   mint(ll x = 0) : x((x % mod + mod) % mod) {}
   mint operator-() const { return mint(-x); }
   mint &operator+=(const mint a)
   {
      if ((x += a.x) >= mod)
         x -= mod;
      return *this;
   }
   mint &operator-=(const mint a)
   {
      if ((x += mod - a.x) >= mod)
         x -= mod;
      return *this;
   }
   mint &operator*=(const mint a)
   {
      (x *= a.x) %= mod;
      return *this;
   }
   mint operator+(const mint a) const { return mint(*this) += a; }
   mint operator-(const mint a) const { return mint(*this) -= a; }
   mint operator*(const mint a) const { return mint(*this) *= a; }
   mint pow(ll t) const
   {
      if (!t)
         return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1)
         a *= *this;
      return a;
   }

   // for prime mod
   mint inv() const { return pow(mod - 2); }
   mint &operator/=(const mint a) { return *this *= a.inv(); }
   mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

int main()
{
   int N;
   cin >> N;
   mint ans[4] = {1, 0, 0, 0};
   for (int i = 0; i < N; i++)
   {
      ans[3] = ans[1] + ans[2] + ans[3] * 10;
      ans[2] = ans[0] + ans[2] * 9;
      ans[1] = ans[0] + ans[1] * 9;
      ans[0] = ans[0] * 8;
   }
   cout << ans[3];

   return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
using namespace std; using ll=long long; const int m=1e9+7; using P=pair<int,int>;

int main() {
  ll n,k; cin>>n>>k;
  ll l=k*(k-1)/2, r=n*(n+1)/2;
  ll an=0;
  // 0 1 2 3 4 5 6
  // n*(n+1)/2 - (n-k)*(n-k+1)/2
  for(ll i=k;i<=n+1;i++) {
    ll l=i*(i-1)/2, r=n*(n+1)/2 - (n-i)*(n-i+1)/2;
    an+=r-l+1; an%=m;
  }
  cout<<an<<endl;
}

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

using namespace std;

typedef long long ll;

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

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

class review {
    public:
    string name;
    int score;
    int n;
};

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

    vector<review> reviews;
    reviews.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> reviews[i].name >> reviews[i].score;
        reviews[i].n = i + 1;
    }

    sort(reviews.begin(), reviews.end(), [](const review &a, const review &b) {
            if (a.name != b.name) {
            return a.name < b.name;
            } else {
            return a.score > b.score;
            }
            });

    for (int i = 0; i < N; i++) {
        cout << reviews[i].n << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n;
    deque<int> deq;
    cin >> n;
    for (int i=1;i<n+1;i++) {
        deq.emplace_back(i);
    }
    do {
        for (int j=0;j<deq.size();j++) {
            if ( j==deq.size()-1 ) {
                cout << deq[j] << endl;
            } else {
                cout << deq[j] << " ";
            }
        }
    } while (next_permutation(deq.begin(),deq.end()));
    
    
}



Measured memory_bytes: 3096