akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w;
  cin >> h >> w;
  
  vector<vector<char>> s(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s.at(i).at(j);
    }
  }
  
  bool flag = true;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s.at(i).at(j) == '.') continue;
      bool check = true;
      for (int k = 0; k < 4; k++) {
        if (0 <= i + dx[k] && i + dx[k] < h && 0 <= j + dy[k] && j + dy[k] < w) {
          if (s.at(i + dx[k]).at(j + dy[k]) == '#') check = false;
        }
      }
      if (check) flag = false;
    }
  }
  
  if (flag) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 256
n = gets.to_i
ok = true
20.times do |i|
    ok = false if (1<<i) == n
end
if !ok
    puts "No"
    exit
end
a = []
2.times do |i|
    a << [i+1,i+2]
end
a << [3,1+n]
a << [n+1,n+2]
a << [n+3,n+2]
i = 4
((n-3)/2).times do
    a << [i,i+1]
    a << [i+1,1+n]
    a << [1+n,i+n]
    a << [i+n,i+1+n]
    i += 2
end
if n%2 == 0
    (1..n).each do |i|
        if (n^(2*i)^1) < n
            a << [n,i*2+n]
            a << [2*n,n^(2*i)^1]
            break
        end
    end
end
puts "Yes"
a.size.times do |i|
    puts "#{a[i][0]} #{a[i][1]}"
end

Measured memory_bytes: 18940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll X,ans=0;
	cin >> X;
	FOR(b,1,1000){
		FOR(p,2,1000){
			ll w=1;
			FOR(i,0,p){
				w *= b;
				if(w>X)break;
			}
			if(X>=w)ans = max(ans,w);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    A = [a - (i + 1) for i, a in enumerate(A)]
    # argmin -> median of A
    A.sort()
    ans = 0
    for i in range(N // 2):
        ans += A[- (i + 1)] - A[i]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25196
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, ABC, BC) for(int I = ABC; I <= BC; I++)
#define rep(I, ABC, BC) for(int I = ABC; I < BC; I++)
#define rrep(I, BC, ABC) for(int I = BC; I >= ABC; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(BC) BC.begin(),BC.end()
#define rall(BC) BC.rbegin(),BC.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(ABC, BC) memset(ABC, BC, sizeof(ABC));
#define mem0(ABC) memset(ABC, 0, sizeof(ABC));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int ABC, BC; cin >> ABC >> BC; BC[ABC].pb(BC), BC[BC].pb(ABC);}
#define in_edges2(M) repp(I, 1, M){int ABC, BC; cin >> ABC >> BC; BC[ABC].pb(BC);}
#define endl "\n"

const ll MOD = 1000000007;

int gen(vector<int> v, int a){
    for(auto i : v) if(i == a) return 0;
    int mn = 1e9;
    rep(i, 1, 1 << v.size()){
        int c = -1, sum = 0;
        rep(j, 0, v.size()) if(i & 1 << j){c++, sum += v[j];}
        mn = min(mn, c*10 + abs(sum - a));
    }
    return mn;
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    int n, a, b, c;
    int x, y, z, res = 1e9;
    cin >> n >> a >> b >> c;
    vector<int> ABC(n), BC, C, A, B;
    for(auto &i : ABC) cin >> i;

    rep(i, 1, 1 << n){
        A.clear();
        BC.clear();
        rep(j, 0, n) if(i & 1 << j) A.pb(ABC[j]); else BC.pb(ABC[j]);
        x = gen(A, a);
        rep(j, 1, 1 << BC.size()){
            B.clear();
            C.clear();
            rep(k, 0, BC.size()) if(j & 1 << k) B.pb(BC[k]); else C.pb(BC[k]);
            y = gen(B, b);
            z = gen(C, c);
            res = min(res, x + y + z);
        }
    }
    cout << res;
}
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

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

int main(){
    int A,B;
    cin >> A >> B;

    int K;
    for(int i=0;i<1000000000;i++){
        if(abs(A-i)==abs(B-i)){
            cout << i << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
  long long a,b;
  cin>>a>>b;
  long long mod=2019;
  long long min=3000;
  if(b-a>=2018){
    cout<<0<<endl;
  }
  else{
    for(long long i=a;i<=b;i++){
      for(long long j=i+1;j<=b;j++){
        if((((i%mod)*(j%mod))%mod)<min){
          min=((i%mod*j%mod)%mod);
        }
      }  
    }
    cout<<min<<endl;
  }
}


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

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n=in.nextInt();
        int prevx=0,prevy=0,prevt=0;
        while(n-->0){
            int t=in.nextInt();
            int x=in.nextInt(),y=in.nextInt();
            int total=Math.abs(x-prevx)+Math.abs(y-prevy);
            if(t<total){
                System.out.println("No");
                return;
            }
            int diff=total-(t-prevt);
            if(diff%2!=0){
                System.out.println("No");
                return;
            }
            prevx=x;
            prevy=y;
            prevt=t;

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

Measured memory_bytes: 39796
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				
				int max=0;
				int[][] d=new int[10][10];
				int INF=1000000000;
				for(int i=0; i<=9; i++) {
					for(int j=0; j<=9; j++) {
						d[i][j]=INF;
					}
				}
				for(int i=1; i<=n; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					int c=sc.nextInt();
					max=Math.max(max, Math.max(a, b));
					d[a][b]=d[b][a]=c;
				}
				max++;
				for(int i=0; i<max; i++) {
					d[i][i]=0;
				}
				for(int k=0; k<max; k++) {
					//System.out.println("k="+k);
					for(int i=0; i<max; i++) {
						for(int j=0; j<max; j++) {
							d[i][j]=Math.min(d[i][j], d[i][k]+d[k][j]);
							//System.out.println("d["+i+"]["+j+"]="+d[i][j]);
						}
					}
				}
				int min=INF;
				int sum=0, mini=0;
				for(int i=0; i<max; i++) {
					sum=0;
					for(int j=0; j<max; j++) {
						sum+=d[i][j];
					}
					if(min>sum) {
						mini=i;
						min=sum;
					}
				}
				System.out.println(mini+" "+min);
				
			}



		}
	}
}


Measured memory_bytes: 26304
#ABC_174_C_Respect_review.py

K = int(input())
ans = 1

if K % 2 == 0:
	print(-1)
	exit()
if K % 5 == 0:
	print(-1)
	exit()

temp = 7
for i in range(1*10**6):
	if temp % K == 0:
		print(ans)
		exit()
	res = temp % K
	temp = res*10 + 7
	ans += 1
print(-1)

Measured memory_bytes: 63264
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,d,ans=0;
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	ans=max(b,d)-min(a,c);
	ans-=abs(b-d)+abs(a-c);
	printf("%d\n",max(0,ans)); 
	
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict

class UnionFind:  # 0-index
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n  # 親の番号 要素が根の場合は-(そのグループの要素数)を格納

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  # 要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す O(n)に注意
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # {根: [グループに含まれる要素のリスト], ...}の辞書を返す O(n)に注意
        ret = defaultdict(list)
        for i in range(self.n):
            ret[self.find(i)].append(i)
        return ret

# ---------------------- #

n, m = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
XY = [tuple(int(x) for x in input().split()) for _ in range(m)]
B = [(a, i) for i, a in enumerate(A)]

uf = UnionFind(n)
for x, y in XY:
    uf.union(x, y)

k = n - m
if k == 1:
    print(0)
    exit()
if n < 2 * k - 2:
    print("Impossible")
    exit()

ans = 0
used = set()
for root, members in uf.all_group_members().items():
    tmp, i = min((A[x], x) for x in members)
    used.add(i)
    ans += tmp

B.sort(reverse=True)
count = 0
while count < k - 2:
    a, i = B.pop()
    if i in used:
        continue
    else:
        ans += a
        count += 1

print(ans)


Measured memory_bytes: 110208
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,W;
int w[210];
int dp[210][10010];

int f(int i, int W) {
  if (i >= N) return W == 0;
  int ans = f(i+1,W-w[i]);
  for (int j = max(0LL,W-w[i]+1); j <= W; j++) {
    (ans += dp[N-i-1][j]) %= MOD;
  }
  return ans;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> W;
  REP(i,N) cin >> w[i];
  sort(w,w+N); reverse(w,w+N);
  dp[0][0] = 1;
  REP(i,N) REP(j,W+1) {
    (dp[i+1][j] += dp[i][j]) %= MOD;
    if (j-w[i] >= 0) {
      (dp[i+1][j] += dp[i][j-w[i]]) %= MOD;
    }
  }
  reverse(w,w+N);
  cout << f(0,W) << endl;

  return 0;
}


Measured memory_bytes: 18684
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut k: usize = sc.cin();
    let c: usize = sc.cin();
    let s: Vec<char> = sc.chars();

    let mut dp = vec![0; n + c + 2];
    for i in (0..n).rev() {
        if s[i] == 'x' {
            dp[i] = dp[i + 1];
        } else {
            dp[i] = max!(dp[i + 1], 1 + dp[i + c + 1]);
        }
    }
    trace!(&dp);

    {
        let mut i = 0;
        while k > 0 && i < n {
            if s[i] == 'x' {
                i += 1;
                continue }
            if dp[i+1] < k {
                put!(i + 1);
            }
            i += c + 1;
            k -= 1;
        }
    }

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 7676
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))



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

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

int main() {
	long N, M;

	cin >> N >> M;
	vector<pll> v(N);
	for (long i = 0; i < N; i++) {
		cin >> v[i].first >> v[i].second;
	}
	long long res = 0;

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

	for (int i = 0; i < N && M > 0; ++i) {
		res += v[i].first * min(M, v[i].second);
		M -= min(M, v[i].second);
	}

	cout << res << endl;
}


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

int main()
{
    int n; cin >> n;
    vector<int> a(n),b(n+1),c(n);

    for(int i=0; i<n ; i++) 
        cin >> a[i];
    for(int i=1; i<=n; i++) 
        cin >> b[i];
    for(int i=1; i<n; i++) 
        cin >> c[i];
    int ans = 0;
    for(int i=0;i<n;i++){
        if(i==0) ans += b[a[i]];
        else{
            ans += b[a[i]];
            if(a[i] - a[i-1] ==1)
                ans += c[a[i-1]];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
   int n;cin>>n;
   int a[n];
   rep(i,n)cin>>a[i];
   vector<bool>v(1000005,false);
   bool f=true;
   rep(i,n){
       if(a[i]==2){
           if(v[2])f=false;
           v[2]=true;
           continue;
       }
       if(a[i]==1){
           continue;
       }
       rep(j,sqrt(a[i])+1){
           if(j==1||j==0)continue;
           if(a[i]%j==0){
               if(v[j])f=false;
               if(v[a[i]/j])f=false;
               v[j]=true;
               v[a[i]/j]=true;
           }
       }
       if(v[a[i]])f=false;
       v[a[i]]=true;
       if(!f)break;
   }
   if(f){
       cout<<"pairwise coprime"<<endl;
       return 0;
   }
   int g =a[0];
   rep(i,n){
       g=__gcd(g,a[i]);
   }
   if(g==1)cout<<"setwise coprime"<<endl;
   else
   {
       cout<<"not coprime"<<endl;
   }
   
}


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

int main(void){
    long long int n, a, b, c, d, e, k;
    scanf("%lld %lld %lld %lld %lld %lld", &n, &a, &b, &c, &d, &e);
    long long int min = n;
    if(a<min) min = a;
    if(b<min) min = b;
    if(c<min) min = c;
    if(d<min) min = d;
    if(e<min) min = e;
    printf("%lld\n", (n+min-1)/min + 4);
}

Measured memory_bytes: 128
#include <stdio.h>
int main(int argc, char *argv[])
{
	char a[1010];
	while(scanf("%s",a)!=EOF)
	{
	int s=0,n=0,w=0,e=0;
	for(int i=0;a[i]!='\0';i++)
	{
		if(a[i]=='S') s++;
		else if(a[i]=='N') n++;
		else if(a[i]=='E') e++;
		else if(a[i]=='W') w++;
	}  
	if(s==0&&n!=0) printf("No\n");
	else if(s!=0&&n==0) printf("No\n");
	else if(w==0&&e!=0) printf("No\n");
	else if(w!=0&&e==0) printf("No\n");
	else printf("Yes\n");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

class Die {
public:
  Die(vector<int> numbers) : top_(1) {
    vertical_ = vector<int>(4);
    horizontal_ = vector<int>(4);
    vertical_[0] = numbers[0];
    vertical_[1] = numbers[4];
    vertical_[2] = numbers[5];
    vertical_[3] = numbers[1];
    horizontal_[0] = numbers[0];
    horizontal_[1] = numbers[2];
    horizontal_[2] = numbers[5];
    horizontal_[3] = numbers[3];
  }

  int get_top() const { return top_; }
  void rotate_north()
  {
    rotate(vertical_.rbegin(), vertical_.rbegin() + 1, vertical_.rend());
    top_ = vertical_[0];
    horizontal_[0] = vertical_[0];
    horizontal_[2] = vertical_[2];
  }
  void rotate_south()
  {
    rotate(vertical_.begin(), vertical_.begin() + 1, vertical_.end());
    top_ = vertical_[0];
    horizontal_[0] = vertical_[0];
    horizontal_[2] = vertical_[2];
  }
  void rotate_east()
  {
    rotate(horizontal_.rbegin(), horizontal_.rbegin() + 1, horizontal_.rend());
    top_ = horizontal_[0];
    vertical_[0] = horizontal_[0];
    vertical_[2] = horizontal_[2];
  }
  void rotate_west()
  {
    rotate(horizontal_.begin(), horizontal_.begin() + 1, horizontal_.end());
    top_ = horizontal_[0];
    vertical_[0] = horizontal_[0];
    vertical_[2] = horizontal_[2];
  }

private:
  int top_;
  vector<int> vertical_, horizontal_;
};

int main()
{
  vector<int> nums(6);
  for (int i = 0; i < 6; ++i) {
    fscanf(stdin, "%d", &nums[i]);
  }
  string commands;
  cin >> commands;
  Die die(nums);
  int ncomms = commands.size();
  for (int i = 0; i < ncomms; ++i) {
    if (commands[i] == 'N') {
      die.rotate_north();
    }
    else if (commands[i] == 'S') {
      die.rotate_south();
    }
    else if (commands[i] == 'E') {
      die.rotate_east();
    }
    else if (commands[i] == 'W') {
      die.rotate_west();
    }
  }
  fprintf(stdout, "%d\n", die.get_top());
  return 0;
}

Measured memory_bytes: 1256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String[] n = scanner.next().split("");
		List<Boolean> result = new ArrayList<>();
		
		scanner.close();
		
		for (int i = 0; i < n.length; i++) {
			
			if ("7".equals(n[i])) {
				result.add(true);
			} else 
				result.add(false);
		}
		
		if (result.stream().anyMatch(e -> e == true)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35912
#include "bits/stdc++.h"
#include <stdint.h>

#pragma optimize("O3")

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;

#define sync                    \
ios_base::sync_with_stdio(0); \
cin.tie(0);                   \
cout.tie(0)
#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define fopen freopen("input.txt", "r", stdin); freopen("output.txt","w", stdout)
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, b, a) for(ll i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define REPR(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define MP make_pair
#define endl '\n'

const ll MOD = 1e9 + 7;
const ll INF = 2*1e9 + 7;
const int base = 2e5+1;
const int MAX =1e5+2;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 2*1e5+1;




int main()
{
    int n;
    cin >> n;
    ull sum = 0;
    bool ok = 1;
    ull x = INF;
    FOR(i,0,n)
    {
        ull a, b;
        cin >> a >> b;
        if(a!=b)
        {
            ok = 0;

        }
        if(a > b)
        {
            x = min(x, b);
        }
        sum += a;
    }

    if(ok) cout << 0;
    else cout << sum - x;
    return 0;
}




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

inline void PaintMass(vector<vector<int>>& Mass, queue<pair<int,int>>& Blacks)
{
	const auto& black = Blacks.front();
	const int h = black.first, w = black.second;
  	
  	// 上下左右を塗る
    if( h > 0 && !Mass[h-1][w]){
    	Mass[h-1][w] = true;
      	Blacks.emplace(h-1, w);
    }
          
    if( w > 0 && !Mass[h][w-1]){
        Mass[h][w-1] = true;
       	Blacks.emplace(h, w-1);
    }
          
    if( h < Mass.size() - 1 && !Mass[h+1][w]){
    	Mass[h+1][w] = true;
       	Blacks.emplace(h+1, w);
    }
          
    if( w < Mass[h].size() - 1 && !Mass[h][w+1]){
        Mass[h][w+1] = true;
       	Blacks.emplace(h, w+1);
    }
  
  	Blacks.pop();
}

int main()
{
 	size_t h,w;
 	cin >> h >> w;
	vector<vector<int>> Mass(h, vector<int>(w));
	queue<pair<int,int>> Blacks;
  
	for(size_t i = 0; i < h; ++ i)
    	for(size_t j = 0; j < w; ++ j)
    	{
        	char col;
        	cin >> col;
      		if(Mass[i][j] = col == '#')
            	Blacks.emplace(i, j);
     	}

  	int Paint = 0;
  	while(!Blacks.empty())
    {
    	size_t cnt = Blacks.size();
      	while(cnt--)
    		PaintMass(Mass, Blacks);
      	++ Paint;
    }
  
  	cout << (Paint-1);
	return 0; 
}


Measured memory_bytes: 12432
def main():
    s = list(input())
    t = list(input())
    n = len(s)
    memo1 = {}
    memo2 = {}

    for i in range(n):
        c1 = s[i]
        c2 = t[i]
        if c1 in memo1:
            if memo1[c1] != c2:
                print('No')
                exit()
        else:
            memo1[c1] = c2
        if c2 in memo2:
            if memo2[c2] != c1:
                print('No')
                exit()
        else:
            memo2[c2] = c1

    print('Yes')


main()


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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

constexpr ll mod = 1e9+7;

int main(){
    string s;
    cin>>s;
    string ss = "CODEFESTIVAL2016";
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=ss[i]) ans++;
    }
    cout << ans << endl;
}


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

#define pb push_back
#define mp make_pair
// #define N 200001
// vector< pair<int, int> > ej;
typedef long long ll;

// int is[N] = {0};
// ll ans[50] = {0};

int main(){
	ll k, n = 50;
	cin >> k;
	// vector<ll> ans(50, k/n);
	cout << n << endl;
	if(k < 50){
		for(int i = 0; i < k; i++){
			cout << 50-i << " ";
		}
		for(int i = k; i < 50; i++){
			cout << "0 ";
		}
		cout << endl;
		return 0;
	}
	ll rm = k%50;
	if(rm == 0)
		rm = 50;
	for(ll i = 0; i < 50; i++){
		ll nm = 50ll-i+(k-rm)/n;
		if(i < rm)
			nm++;
		cout << nm-1ll << " ";
	}
	// for(ll i = rm; i < 50; i++){
	// 	cout << (k-rm)/n << " ";
	// }
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
const int nax=1e5+7;
ll s[nax];
int n;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n;
		rep(i,0,n) cin>>s[i];
		ll ans=0;
		ll count=0;
		ll m=1e18;
		rep(i,0,n) {
			ans+=llabs(s[i]);
			m=min(m,llabs(s[i]));
			if(s[i]<0) count++;
		}
		if(count%2==0) cout<<ans;
		else cout<<ans-m*2LL;
		return 0;
}

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

void solveA(){
  int n,a,b;
  cin >> n >> a >> b;

  cout << min(a,b) << " " << max(0,a+b-n) << endl;
}
void solveB(){
  int n,t,ci,ti;
  cin >> n >> t;
  int ans = 2000;
  
  for(int i=0;i<n;i++){
    cin >> ci >> ti;
    if (ci<=ans && ti<=t) ans = ci;
  }
  if (ans==2000) cout << "TLE" << endl;
  else cout << ans << endl;  
}

void solveC(){
}
void solveD(){
}

int main(){
  solveA();
}


Measured memory_bytes: 256
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << x;
#define OUTL(x) cout << x << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

struct UnionFind
{
    vector<ll> par;
    vector<ll> siz;
    UnionFind(ll n) : par(n), siz(n, 1)
    {
        rep(i, n) par[i] = i;
    }
    ll root(ll x)
    {
        while (par[x] != x) x = par[x] = par[par[x]];
        return x;
    }
    //グループを統合して、違うグループだったかを返す
    bool unite(ll x, ll y)
    {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return false;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return true;
    }
    //同じグループに属するか
    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }
    //属するグループの大きさ
    ll size(ll x)
    {
        return siz[root(x)];
    }
};

void solve()
{
    IN(n, m);
    UnionFind uf(n);
    rep(i, m) {
        IN(a, b); --a, --b;
        uf.unite(a, b);
    }
    set<ll> s;
    rep(i, n) s.emplace(uf.root(i));
    cout << s.size() - 1 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 8408
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,ex=0;
    cin>>n;
    vector<int>v;

    for(int i=0; i<n; i++)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }
    set<pair<int,int> >s;
    sort(v.begin(),v.end());
    for(int i=0; i<n; i++)
    {
        if(v[i]>=1 && v[i]<=399)
        {
            s.insert({1,399});
        }
        if(v[i]>=400 && v[i]<=799)
        {
            s.insert({400,799});
        }
        if(v[i]>=800 && v[i]<=1199)
        {
            s.insert({800,1199});
        }
        if(v[i]>=1200 && v[i]<=1599)
        {
            s.insert({1200,1599});
        }
        if(v[i]>=1600 && v[i]<=1999)
        {
            s.insert({1600,1999});
        }
        if(v[i]>=2000 && v[i]<=2399)
        {
            s.insert({2000,2399});
        }
        if(v[i]>=2400 && v[i]<=2799)
        {
            s.insert({2400,2799});
        }
        if(v[i]>=2800 && v[i]<=3199)
        {
            s.insert({2800,3199});
        }
        if(v[i]>=3200)
            ex++;
    }
    int mn,mx;
    mn=s.size();
    mx=s.size();
    if(mn==0)
        mn=1;
    mx+=ex;
        cout<<mn<<" " <<mx<<endl;


    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {
    int maxlen = 0, maxcount = 0;
    string s, lens, counts;
    map<string, int> mp;
    while (cin >> s) {
        if (maxlen < s.size()) {
            maxlen = s.size();
            lens = s;
        }
        mp[s]++;
        if (maxcount < mp[s]) {
            maxcount = mp[s];
            counts = s;
        }
    }
    cout << counts << " " << lens << endl;
    
    return 0;
}

Measured memory_bytes: 1196
#include"bits/stdc++.h"
using namespace std;

#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 all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    ll n, d, a; cin >> n >> d >> a;
    vector<pair<ll, ll>> m(n);
    rep(i, n) cin >> m[i].fi >> m[i].se;
    sort(all(m));
    
    queue<pair<ll, ll>> q;
    ll tot = 0, ans = 0;
    rep(i, n){
        ll l = m[i].fi;
        ll h = m[i].se;
        while(!q.empty() && q.front().fi < l){
            tot -= q.front().se; q.pop();
        }
        h -= tot;
        if(h > 0){
            ll cnt = (h + a - 1) / a;
            ans += cnt;
            ll damage = cnt * a;
            tot += damage;
            q.push({l+2*d, damage});
        }
    }
    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: 7908
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n = int(input())
ac = 0; wa = 0; tle = 0; re = 0
for _ in range(n):
    s = input().rstrip()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    elif s == "RE":
        re += 1

print("AC x", ac) 
print("WA x", wa) 
print("TLE x", tle) 
print("RE x", re) 

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>=0&&4*a*b<(c-a-b)*(c-a-b)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3636
fun main(args:Array<String>) {
    val (s, t) = readLine()!!.split(" ")
    val (a, b) = readLine()!!.split(" ").map { m -> m.toInt() }
    val u = readLine()!!
    
    if (u == s) {
        println("${a - 1} $b")
    } else {
        println("$a ${b - 1}")
    }
}

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

int main() {
    string s;
    cin >> s;
    bool flg = true;
    for (int i = 0; i < s.size(); i++) {
        if (s.rfind(s[i]) != i) {
            cout << "no" << endl;
            flg = false;
            break;
        }
    }
    if (flg) cout << "yes" << endl;
}

Measured memory_bytes: 256
import os
import sys
from collections import Counter

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

W = sys.stdin.readline().rstrip()

if any([w % 2 for w in Counter(list(W)).values()]):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 38384
N, M, X = map(int, input().split())
listA = [list(map(int, input().split())) for i in range(N)]
ans = -1

for i in range(2**N):
    price = 0
    point = [0]*M
    for j in range(N):
        if (i >> j) & 1 == 1:
            price += listA[j][0]
            for k in range(M):
                point[k] += listA[j][k+1]
    if min(point) >= X:
        ans = min(ans, price) if ans != -1 else price
print(ans)

Measured memory_bytes: 9244
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        output = []
        for i, c in enumerate(line.rstrip("\n")):
            if i % 2 == 0:
                output.append(c)
        print("".join(output))

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 3332
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n; readV(n);
  int[] s; readC(n, s);

  auto t = s.sum;
  if (t%10 != 0) {
    writeln(t);
  } else {
    auto f = s.filter!"a%10 != 0";
    if (f.empty) {
      writeln(0);
    } else {
      writeln(t-f.reduce!min);
    }
  }
}


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

#define NIL -1
#define N 100000

typedef struct node {
	int parent;
	int left;
	int right;
} Node;

Node T[N];

int getDepth(int id) {
	int depth = 1;

	if (T[id].parent == NIL) return 0;
	depth += getDepth(T[id].parent);
	return depth;
}

void printChild(int id) {
	if (id == NIL) return;
	if (T[id].right == NIL) {
		printf("%d",id);
		return;
	}
	printf("%d, ",id);
	printChild(T[id].right);
}

int main() {
	int i,j,n;
	int id,degree,child,tmp;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		T[i].parent = NIL;
		T[i].left = NIL;
		T[i].right = NIL;
	}

	for (i = 0; i < n; i++) {
		scanf("%d %d", &id, &degree);
		for (j = 0; j < degree; j++) {
			scanf("%d", &child);
			T[child].parent = id;
			if (j == 0) T[id].left = child;
			else T[tmp].right = child;
			tmp = child;
		}
	}

	for (i = 0; i < n; i++) {
		printf("node %d: parent = %d, depth = %d,",i,T[i].parent, getDepth(i));
		if (T[i].parent == NIL) printf(" root,");
		else if (T[i].left != NIL) printf(" internal node,");
		else printf(" leaf,");
		printf(" [");
		printChild(T[i].left);
		printf("]\n");
	}

	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	long long ans = 0;
	rep(i, n) {
		ans += a[i] / 2;
		if ((a[i] % 2) > 0 && i < n - 1 && a[i + 1] > 0) {
			a[i]--;
			a[i + 1]--;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int W,H,x,y,r,No,Yes;
	cin>>W>>H>>x>>y>>r;
	if ((x-r)<0||(x+r)>W||(y-r)<0||(y+r)>H){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3120
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)

print(f'{x3} {y3} {x4} {y4}')

Measured memory_bytes: 9068
#include<stdio.h>
int main(){
    int max = -2000000000, data[200000] = {};
    int n, i, r, min;
    scanf("%d", &n);
    for( i = 0; i < n; i++ ){
        scanf("%d", &data[i]);
    }
    min = data[0];
    max = data[1] - data[0];
    for( r = 1; r < n; r++ ){
        if( data[r] - min > max ){
            max = data[r] - min;
        }
        if( data[r] < min ){
           min = data[r];
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 1388
//const ll LIM = 1e6;
//ll f(ll b, ll n){
//    ll ans = 0;
//    while(n > 0){
//        ans += n%b;
//        n /= b;
//    }
//    return ans;
//}
//ll _(){
//    ll n,s;
//    cin >> n >> s;
//    rep(b,2,LIM)
//        if(f(b,n) == s)
//            return b;
//    for(int k = LIM; k >= 1; --k){
//        ll b = (n+k-s)/k;
//        if(b < 2) continue;
//        if(f(b,n) == s)
//            return b;
//    }
//    if(f(n+1,n) == s)
//        return n+1;
//    return -1;
//}
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
const ll LIM = 1e6;
ll f(ll b, ll n){
    ll ans = 0;
    while(n > 0){
        ans += n%b;
        n /= b;
    }
    return ans;
}
ll _(){
    ll n,s;
    cin >> n >> s;
    rep(b,2,LIM)
        if(f(b,n) == s)
            return b;
    for(int k = LIM; k >= 1; --k){
        ll b = (n+k-s)/k;
        if(b < 2) continue;
        if(f(b,n) == s)
            return b;
    }
    if(f(n+1,n) == s)
        return n+1;
    return -1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 120000;

int n;
int cc[MAXN];
int a[MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i), ++cc[a[i]];
	int ans = 0;
	for (int i = 0; i < MAXN; ++i) {
		if (cc[i] > 1)
			ans += cc[i] - 1;
	}
	cout << n - 2 * ((ans + 1) / 2) << "\n";
	return 0;
}




Measured memory_bytes: 1024
import itertools
H,W,K = map(int,input().split())
init_map = []
for i in range(H):
    row = list(input())
    init_map.append(row)
ans = 0
 
for paint_h in range(2 ** H):
    for paint_w in range(2 ** W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (paint_h >> i)&1 == 0 and (paint_w >> j)&1 == 0:
                    if init_map[i][j] == "#":
                        cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9204
function main(input) {
  input = input.trim();
  const [a,b,c] = input.split(" ").map(Number);
 
  if(a<=c && b>=c){
    console.log("Yes");
  }else{
    console.log("No");
  }
    
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29468
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long int;

const int SIZE = 200000;
const ll MOD = 1000000007LL;
ll fact[SIZE+10], finv[SIZE+10];

ll mod_pow(ll N, ll K) {
    ll ret = 1;
    for(; K>0; K>>=1) {
        if(K & 1) (ret *= N) %= MOD;
        (N *= N) %= MOD;
    }
    return ret;
}

void init_array() {
    fact[0] = 1;
    for(int i=1; i<SIZE; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    finv[SIZE-1] = mod_pow(fact[SIZE-1], MOD-2);
    for(int i=SIZE-1; i>=1; i--) {
        finv[i-1] = (finv[i] * i) % MOD;
    }
}

ll comb(int n, int r) {
    if(n < r) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

int main() {
    init_array();
    int N, M; cin >> N >> M;
    map<int, int> div;
    for(int k=2; k*k<=M; k++) {
        while(M % k == 0) div[k]++, M /= k;
    }
    if(M != 1) div[M]++;

    ll ans = 1;
    for(auto x : div) {
        int val = x.second;
        (ans *= comb(N - 1 + val, val)) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <ctype.h>

using namespace std;

int main(void)
{
	string s, t;

	bool flag = true;

	cin >> s;
	cin >> t;

	if (s.length() > 10)
	{
		return 0;
	}

	for (auto a : s)
	{
		if (isupper(a))
		{
			return 0;
		}
	}

	if (t.length() - s.length() == 1)
	{
		for (int i = 0; i < s.length(); i++)
		{
			if (s[i] != t[i])
			{
				flag = false;
				break;
			}
		}
	}
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int ans=0;
  for(auto p:mp){
    int a=p.second;
    ans=max(ans,a);
  }
  for(auto p:mp){
    int a=p.second;
    string t=p.first;
    if(ans==a){
      cout << t<<endl;
    }
  }
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    if(s.size() >= 5 && s[3] == 'A' && s[4] == 'C'){ Cout("Yes"); return 0; }
    if(s.size() >= 4 && s[2] == 'A' && s[3] == 'C'){ Cout("Yes"); return 0; }
    if(s.size() >= 3 && s[1] == 'A' && s[2] == 'C'){ Cout("Yes"); return 0; }
    if(s.size() >= 2 && s[0] == 'A' && s[1] == 'C'){ Cout("Yes"); return 0; }
    Cout("No");
}





Measured memory_bytes: 256