akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  1 13:17:41 2020

@author: naoki
"""

import sys

# =============================================================================
# with open('C:/Users/naoki/Desktop/Atcoder/input.txt') as f:
#     A = [list(map(int,f.readline().split())) for _ in range(3)]
#     N = int(f.readline())
#     b_flat = [int(f.readline()) for _ in range(N)]
# =============================================================================

A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b_flat = [int(input()) for _ in range(N)]    
    
count3 = 0
count4 = 0
for j in range(3):
    count1 = 0
    count2 = 0
    for i in range(3):
        if A[j][i] in b_flat:
            count1 += 1
        if A[i][j] in b_flat:
            count2 += 1
    if count1 == 3 or count2 == 3:
        print("Yes")
        sys.exit()
    if A[j][j] in b_flat:
        count3 += 1
    if A[j][-(j+1)] in b_flat:
        count4 += 1
if count3 == 3 or count4 == 3:
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 3064
//
//  CF Handle : 2017_Scayre_TBIL_777
//
//  Sultan Niyazbekov.
//
//  Rating : Pupil -> 1382.
//

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>

#define ll long long
#define ull unsigned ll
#define ioi exit(0);

#define f first
#define s second

#define inf 1e9 + 7;

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define mp make_pair

#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)

#define pb push_back
#define ppb pop_back

#define nl "\n"

#define in(x) insert(x)

#define sz(x) (int)x.size()

#define rep(x,y,z) for(int x=y;x<=z;x++)
#define per(x,y,z) for(int x=y;x>=z;x--)

#define all(x) x.begin(),x.end()

#define pw2(x) (1<<x) //2^x

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))

using namespace std;

const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

string s;

int d[N];

int main(){
	
	#ifdef IOI2019
		freopen ("in.txt", "r", stdin);
	#endif

	NFS

	cin >> s;

	if(s[0]=='A'){
		s.erase(0,1);
	}
	if(s[s.size()-1]=='A'){
		s.erase(s.size()-1,1);
	}

	if(s=="KIHABAR"){
		cout << "YES" << endl;
		ioi
	}
	if(s=="KIHBAR"){
		cout << "YES" << endl;
		ioi
	}
	if(s=="KIHABR"){
		cout << "YES" << endl;
		ioi
	}
	if(s=="KIHBR"){
		cout << "YES" << endl;
		ioi
	}

	cout << "NO" << endl;

	ioi
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>data(N);
  for(int i=0;i<N;i++)cin>>data[i];
  int ans=0;
  for(int i=0;i<N;i++){
    if(data[i]>=K)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
a,b,k = map(int,input().split())
flag = 0
cnt = 0
ans = 0
for i in range(101,0,-1):
    if a % i == 0 and b % i == 0:
        cnt += 1
        if cnt == k:
            ans = i
            flag = 1
    if flag:
        break
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
#define ll long long
#define ld long double
#define ALL(x) begin(x),end(x)
  
int main(){
  ll n,t;
  cin >> n >> t;
  
  vector<ll> tt(n);
  rep(i,n) cin >> tt[i];
  
  ll x = 0;
  for(ll i = 1; i < n; i++){
    ll diff = tt[i]-tt[i-1];
    if(diff>t) x += t;
    else x += diff;
  }
  x += t;
  cout << x << endl;
}

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

int compare_ascending(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    if(n%3 == 0){
        qsort(a, n, sizeof(int), compare_ascending);
        int c=1;
        for(int i=1; i<n; i++){
            if(a[i-1] != a[i]){
                c++;
            }
        }
        if(c == 1 || c > 3){
            if(c==1 && a[0]==0){
                printf("Yes");
            }else{
                printf("No");
            }
        }else{
            int d[3], e[3] = {0};
            d[0] = a[0];
            e[0] = 1;
            int x = 0;
            for(int i=1; i<n; i++){
                if(a[i] != a[i-1]){
                    x++;
                    d[x] = a[i];
                }
                e[x]++;
            }
            int t = n/3;
            if((d[0]==0&&e[0]==t&&e[1]==2*t&&c==2)){
                printf("Yes");
            }else if(e[0]==t&&e[1]==t&&e[2]==t&&c==3){
                if((d[0]^d[1]) == d[2]){
                    printf("Yes");
                }else{
                    printf("No");
                }
            }else{
                printf("No");
            }
        }
    }else{
        int f=1;
        for(int i=0; i<n; i++){
            if(a[i] != 0){
                f=0;
                break;
            }
        }
        if(f){
            printf("Yes");
        }else{
            printf("No");
        }
    }

    return 0;
}

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

int MAX = 1e6 + 10;

bool used[1000000];
int fact[1000020];

void init() {
    rep(i, MAX + 1) fact[i] = i;
    for (int i = 2; i <= MAX; i++) {
        if (fact[i] != i) continue;
        for (int j = i; j <= MAX; j += i) {
            fact[j] = i;
        }
    }
}

int main() {
    init();
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i, n) cin >> a[i];
    bool pairwise = true;
    rep(i, n) {
        int x = a[i];
        vector<int>vec;
        while (x != 1) {
            if (used[fact[x]]) {
                pairwise = false;
                goto bou;
            }
            vec.push_back(fact[x]);
            x /= fact[x];
        }
        rep(i, vec.size()) {
            used[vec[i]] = true;
        }
    }
    bou:;
    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int bout = a[0];
    rep(i, n) {
        if (i == 0) continue;
        bout = gcd(bout, a[i]);
    }
    if (bout == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}


Measured memory_bytes: 11104
#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 <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

static const ll MAX = 200000;
static const ll waz = 76543217;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    --top;
    return S[top + 1];
}

int main()
{
    IO;

    ll N, Q; cin >> N >> Q;
    deque<pair<string, ll> > A(N);

    string str;
    ll b;

    for (ll i = 0; i < N; ++i) {
        cin >> str >> b;
        pair<string, ll> k;
        k = make_pair(str, b);
        A.push_back(k);
    }

    ll time = 0;

    while (A.size() != 0) {
        if (A[0].second <= Q) {
            time += A[0].second;
            if (time != 0) {
                cout << A[0].first << " " << time << endl;
            }
            A.pop_front();
        }
        else {
            time += Q;
            A[0].second -= Q;
            A.push_back(A[0]);
            A.pop_front();
        }
    }

}


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

int main(){
  const int Nab= 26;
  int N;
  string str;
  cin >> N >> str;

  vector<set<int>> data(Nab);
  for(int i=0; i<N; i++){
    data.at(str.at(i)-'a').insert(i+1); // 1-indexed
  }

  int Q;
  cin >> Q;

  int query,buf1,buf2;
  char bufc;
  for(int i=0; i<Q; i++){
    cin >> query;
    if(query==1){
      cin >> buf1 >> bufc;
      for(int j=0; j<Nab; j++){
        data.at(j).erase(buf1);
      }
      data.at(bufc-'a').insert(buf1);
    }
    else{
      cin >> buf1 >> buf2;
      int ans= 0;
      for(int j=0; j<Nab; j++){
        auto itr1= data.at(j).lower_bound(buf1);
        auto itr2= data.at(j).upper_bound(buf2);
        if(distance(itr1,itr2) > 0){ ans++; }
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 24196
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Yahoo2019
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            long[] kab = ReadLongs();
            long k = kab[0];
            long a = kab[1];
            long b = kab[2];
            if (b - 2 <= a)
            {
                Console.WriteLine(1 + k);
            }
            else
            {
                if (k <= a - 1)
                {
                    Console.WriteLine(1 + k);
                }
                else
                {
                    k -= a - 1;
                    long res = a;
                    long delta = b - a;
                    res += delta * (k / 2);
                    if (k % 2 > 0) res++;
                    Console.WriteLine(res);
                }
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
int f(int h, int a){
    if(h % a == 0)
        return (h/a);
    else
        return h/a+1;
}



int main(){
   IOS

   int N, D, A; cin>>N>>D>>A;

   vector<pii> x(N);

   for(int i= 0; i < N; i++){
       cin>>x[i].first>>x[i].second;
   }

   sort(all(x));

   ll res = 0;

   vi X(N), H(N);
   for(int i = 0; i < N; i++) X[i] = x[i].first, H[i] = x[i].second;

   vector<ll> CS(N+1,0);

   for(int i = 0; i < N; i++){
       if(x[i].second > CS[i]){
           int idx = upper_bound(all(X), X[i] + 2*D)-X.begin();
           ll cnt = (H[i]-CS[i] + A-1)/A, d = A*cnt;
           res += cnt;
           CS[i] += d;
           CS[idx] -= d;
        }
        CS[i+1] += CS[i];
   }

    cout<<res<<"\n";


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n, c=0;
 cin >> n;
 int a[n];
 for(int i;i<n;i++){
   cin >> a[i];
   if((i%2==0)&&(a[i]%2==1)) c++;
 }
 cout<< c;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

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

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    a--;
    ll lcm = c * d / gcd(c, d);
    ll g = lcm / c + lcm / d - 1;

    ll bb = b - ((b / lcm) * g + (b % lcm) / c + (b % lcm) / d);
    ll aa = a - ((a / lcm) * g + (a % lcm) / c + (a % lcm) / d);
    cout << bb - aa << endl;
    return 0;
}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        s: chars,
    }

    let mut ans = n;
    let mut sume = vec![0usize];
    let mut sumw = vec![0usize];
    for &c in &s {
        if c == 'E' {
            let v1 = *sume.last().unwrap();
            sume.push(v1 + 1);
            let v2 = *sumw.last().unwrap();
            sumw.push(v2);
        } else {
            let v1 = *sumw.last().unwrap();
            sumw.push(v1 + 1);
            let v2 = *sume.last().unwrap();
            sume.push(v2);
        }
    }
    for i in 0..n {
        let a = sumw[i] - sumw[0] + sume[n] - sume[i + 1];
        ans = min(ans, a);
    }
    println!("{}", ans);
}


Measured memory_bytes: 15388
while True:
    h,w  = map(int, input().split())
    
    if w == 0 and h == 0:
        break
    for x in range(h):
        for y in range(w):
            if x == 0 or x == (h-1) or y == 0 or y == (w-1):
                print ('#', end="")
            else: 
                print ('.', end="")
        print()
    print()
    
        
    
    
    
    


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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define PI acos(-1.0)

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  double a, b, x; cin >> a >> b >> x;
  if (x <= (a * a * b) / 2) printf("%.6f\n", atan2(a * b * b, 2 *x) * 180 / PI);
  else printf("%.6f\n", atan2(2 * (a * a * b - x), a * a * a) * 180 / PI);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> X(N + W), Y(N + W);
    rep(i, N) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        X[i] = x;
        Y[i] = y;
    }
    rep(w, W) {
        X[N + w] = H;
        Y[N + w] = w;
    }

    vector<int> idx(N + W);
    iota(all(idx), 0);
    sort(all(idx), [&](int l, int r) { return X[l] == X[r] ? Y[l] < Y[r] : X[l] < X[r]; });

    int D = 0;

    for (int i = 0, j; i < N + W; i = j) {
        for (j = i + 1; j < N + W; ++j) {
            if (X[idx[j]] != X[idx[i]]) break;
        }

        rep(k, i, j) {
            if (Y[idx[i]] < X[idx[i]] - D - 1) {
                //cerr << X[idx[i]] << " " << Y[idx[i]] << endl;
                int ans = X[idx[i]];
                write(ans);
                return 0;
            }
            else if (Y[idx[i]] == X[idx[i]] - D - 1) {
                //cerr << X[idx[i]] << " " << Y[idx[i]] << endl;
                int ans = X[idx[i]];
                write(ans);
                return 0;
            }
            else if (Y[idx[i]] == X[idx[i]] - D) {
                D++;
            }
            else break;
        }
    }
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<stack>

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define scantype int
#define lli long long int
#define N 200005

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}

using namespace std;

void scan(scantype &x);

int main(void)
{
  char st[N];
  scanf("%s",st);

  stack<char> stk;

  stk.push(st[0]);

  for(int i=1;st[i]!='\0';i++)
  {
         if(st[i]=='T' && !stk.empty() && stk.top()=='S')
            stk.pop();
         else stk.push(st[i]);
  }

  string res;

  int cnt=0;
  while(!stk.empty())
    {stk.pop();
    cnt++;}

  cout<<cnt;

  return 0;
}









void scan(scantype &x)
{
    /*register int c = getchar(); //for positive
    x = 0;
    for(;(c<48 || c>57);c = getchar());
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}*/

    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'

int n, m;
VI a(100100);

signed main()
{
    cin >> n >> m;

    REP(i, m){
        cin >> a[i];
    }
    a.resize(m);

    int sum = accumulate(ALL(a), 0);

    if (n < sum){
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }


    return 0;
}

Measured memory_bytes: 3844
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]

ans = [[0] * w for _ in range(h)]
cnt = 1
for i in range(h):
    tmp = 0
    if '#' in s[i]:
        for j in range(w):
            if s[i][j] == '#':
                tmp += 1
                if tmp > 1:
                    cnt += 1
            ans[i][j] = cnt
        cnt += 1
    else:
        if i > 0:
            ans[i] = ans[i - 1][:]

for p in range(h):
    if '#' in s[p]:
        first = p
        break
for q in range(first):
    ans[q] = ans[first][:]

for i in range(h):
    print(*ans[i])


Measured memory_bytes: 7552
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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

struct flow_network {
	int n;
	struct edge { int v; ll c; int rev; };
	vector< vector<edge> > G;
	flow_network(int _n) : n(_n), G(_n) {}
	void add_edge(int u, int v, ll c) {
		edge e = {v, c, (int)G[v].size()}, _e = {u, 0, (int)G[u].size()};
		G[u].push_back(e); G[v].push_back(_e);
	}
	ll dfs(int u, int t, ll f, vector<bool>& vis) {
		if (u == t) return f;
		vis[u] = true;
		for (int i = 0; i < G[u].size(); i++) {
			edge& e = G[u][i];
			if (vis[e.v] || e.c == 0) continue;
			ll d = min(e.c, dfs(e.v, t, min(f, e.c), vis));
			if (d == 0) continue;
			e.c -= d;
			G[e.v][e.rev].c += d;
			return d;
		}
		return 0;
	}
	ll max_flow(int s, int t) {
		ll res = 0;
		for (;;) {
			vector<bool> vis(n);
			ll f = dfs(s, t, LLONG_MAX, vis);
			if (f == 0) return res;
			res += f;
		}
	}
};

int main() {
	for (;;) {
		int n, m; cin >> n >> m;
		if (n == 0 && m == 0) break;
		vector<int> a(n), b(m);
		for (int i = 0; i < n; i++)
			cin >> a[i];
		for (int j = 0; j < m; j++)
			cin >> b[j];
		flow_network fn(n + m + 2);
		int s = n + m, t = n + m + 1;
		for (int i = 0; i < n; i++)
			fn.add_edge(s, i, 1);
		for (int j = 0; j < m; j++)
			fn.add_edge(n + j, t, 1);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				if (gcd(a[i], b[j]) != 1)
					fn.add_edge(i, n + j, 1);
		cout << fn.max_flow(s, t) << endl;
	}
}

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

int main(){
    ll ans = 0;
    string s;
    cin >> s;
    for(int i = 0; i < pow(2, s.size() - 1); i++){
        int l = 0, r = 0;
        for(int j = 0; j < s.size() - 1; j++){
            if(i & (1 << s.size() - 2 - j)){
                r = j + 1;
                ans += stoll(s.substr(l, r - l));
                l = r;
            }
        }
        ans += stoll(s.substr(l, s.size() - l));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int A[200001];
int root(int x){
  if(A[x]==x) return x;
  else return A[x]=root(A[x]);
}
int unite(int x,int y){
  x=root(x),y=root(y);
  if(x!=y) A[x]=y;
}
int main(){
    int n,m,x,y,z,ans=0;
    cin>>n>>m;
    rep(i,n) A[i+1]=i+1;
    rep(i,m) cin>>x>>y>>z,unite(x,y);
    rep(i,n) if(A[i+1]==i+1) ans++;
    cout<<ans;
}

Measured memory_bytes: 640
N = int(input())
ans  = False

for i in range(2, 10):
  if N % i == 0:
    if 1 <= N // i < 10:
      ans = True
      break;
  elif N == 1:
    ans = True
    break;
    
if ans:
  print('Yes')
else:
  print('No')

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

int gcd( unsigned int, unsigned int );
int main(void)
{
	unsigned int a, b, g, l;

	while( std::cin >> a >> b ){
		g = gcd( a, b );
		l = ( a / g ) * b;
		std::cout << g << ' ' << l << std::endl;
	}

	return 0;
}

int gcd( unsigned int a, unsigned int b ){
	int n, i;
	unsigned int tmp[3];

	tmp[0] = std::max( a, b );
	tmp[1] = std::min( a, b );

	for( n = 0;; n++ ){
		for( i = 1;; i++ ){
			tmp[( n + 2 ) % 3 ] = tmp[ n % 3 ] - tmp[( n + 1 ) % 3 ] * i;
			if( tmp[( n + 2 ) % 3 ] == 0 ){
				return tmp[( n + 1 ) % 3 ];
			}else if( tmp[( n + 2 ) % 3 ] < tmp[( n + 1 ) % 3 ] ){
				break;
			}
		}
	}

	return -1;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define MAX_V 10000 + 1
using namespace std;

struct node{
	int x, y;
};

struct edge{
	int from, to;
	double cost;
	
	bool operator < (const edge &other) const{
		return cost > other.cost;
	}
};

int V, E;
int root[MAX_V];
node n[MAX_V];
vector<edge> G;

void init(){
	for(int i = 1; i <= V; i++)
		root[i] = i;
}

int find(int x){
	if(x == root[x]) return x;
	return find(root[x]);
}

bool same(int a, int b){
	a = find(a);
	b = find(b);
	if(a != b){
		root[a] = b;
		return true;
	}
	else return false;
}

double Kruskal(){
	init();
	double sum = 0;
	sort(G.begin(), G.end());
		
	for(int i = 0; i < G.size(); i++){
		edge e = G[i];
		if(same(e.from, e.to))
			sum += e.cost;
	}
	
	return sum;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	double all = 0, ans = 0;
	
	cin >> V >> E;
	
	for(int i = 1; i <= V; i++)
		cin >> n[i].x >> n[i].y;
	
	for(int i = 0; i < E; i++){
		edge e;
		int from, to;
		cin >> from >> to;
		e.from = from, e.to = to;
		e.cost = sqrt((n[from].x - n[to].x) * (n[from].x - n[to].x) + (n[from].y - n[to].y) * (n[from].y - n[to].y));
		G.push_back(e);
		all += e.cost;
	}
	
	ans = Kruskal();
	ans = all - ans;
	printf("%.3lf", ans);
	
	return 0;
}


Measured memory_bytes: 3632
d, g = map(int, input().split())
PC = [0] + [[i for i in map(int, input().split())] for i in range(d)]

def dfs(g, i):
    if i == 0:
        return 10 ** 12
    
    cnt = min(g // (100 * i), PC[i][0])
    score = cnt * 100 * i
    
    if cnt == PC[i][0]:
        score += PC[i][1]
        
    if g > score:
        cnt += dfs(g - score, i - 1)
    
    return min(cnt, dfs(g, i - 1))

print(dfs(g, d))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int k = 0;
	for (int i = 1; i < n; i += 2) {
		k++;
	}
	for (int i = 1; i < n; i += 3) {
		if (i % 2 == 1) {
			for (int j = 2; j < n; j += 2) {
				k++;
			}
		}
		else {
			for (int j = 1; j < n; j += 2) {
				k++;
			}
		}
	}
	if (n % 3 == 1) {
		if (n % 6 == 1) {
			for (int j = 1; j < n; j += 2) {
				k++;
			}
		}
		else {
			for (int j = 2; j < n; j += 2) {
				k++;
			}
		}
	}
	
	cout << k << endl;
	for (int i = 1; i < n; i += 2) {
		cout << 0 << " " << i << endl;
	}
	for (int i = 1; i < n; i += 3) {
		if (i % 2 == 1) {
			for (int j = 2; j < n; j += 2) {
				cout << j << " " << i << endl;
			}
		}
		else {
			for (int j = 1; j < n; j += 2) {
				cout << j << " " << i << endl;
			}
		}
	}
	if (n % 3 == 1) {
		if (n % 6 == 1) {
			for (int j = 1; j < n; j += 2) {
				cout << j << " " << n - 1 << endl;
			}
		}
		else {
			for (int j = 2; j < n; j += 2) {
				cout << j << " " << n - 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>


using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long double ld;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


vector<vector<int> > g;
vector<vector<int> > gg;
vector<int> dep;
vector<int> p;
vector<int> v;
vector<ll> s;
ll sm = 0;
void build(int id,int pre){
    if(v[id]==0&&id!=0){
        s[pre]++;
        for(auto x:gg[id]){
            build(x,pre);
        }
    }else{
        if(id!=0){
            g[pre].push_back(id);
            dep[id] = dep[pre]+1;
        }
        for(auto x:gg[id]){
            build(x,id);
        }
    }
}

int uf[200002];
void init(int n){
    for (int i = 0; i < n; ++i) {
        uf[i]=i;
    }
}


int find(int x){
	if(x != uf[x]){
		uf[x] = find(uf[x]);
    }
    return uf[x];
}
     
void union_set(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	uf[x]=y;
    return ;
}

int main(){
    int n;
    cin >> n;
    p.resize(n);
    v.resize(n);
    gg.resize(n);
    g.resize(n);
    s.resize(n);
    dep.resize(n);
    p[0] = -1;
    rep(i,n-1){
        cin >> p[i+1];
        p[i+1]--;
        gg[p[i+1]].push_back(i+1);
    }
    rep(i,n){
        cin >> v[i];
    }
    build(0,0);
    rep(i,n){
        for(auto x:g[i]){
            p[x] = i;
        }
    }
    priority_queue<pair<ld,pair<int,ll> > > pq;
    vector<ll> ss(n);
    vector<ll> len(n);
    vector<ld> w(n);
    rep(i,n){
        sm += s[i];
        pq.push(MP((ld)s[i],MP(dep[i],i)));
        ss[i] = s[i];
        len[i] = 1;
    }
    
    ll qq = sm;
    vector<ll> res;
    vector<bool> flag(n);
    init(n);
    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        ll id = x.second.second;
        if(flag[id])continue;
        //cerr << id << " "  << p[id] << " " << x.first << endl;
        
        flag[id] = 1;
        if(p[id]==-1)continue;
        int pa = find(p[id]);
        union_set(id,pa);
        //cerr << id << " " << pa << endl;
        if(ss[pa]*len[id]<=ss[id]*len[pa]){
            ss[pa] += ss[id];
            len[pa] += len[id];
            pq.push(MP((ld)ss[pa]/(ld)len[pa],MP(dep[pa],pa)));
        }
        
    }
    rep(i,n){
        w[i] = (ld)ss[i]/(ld)len[i];
    }
    priority_queue<pair<ld,int> > q;
    q.push(MP(0,0));
    while(!q.empty()){
        auto x = q.top();
        q.pop();
        int id = x.second;
        res.push_back(s[id]);
        for(auto y:g[id]){
            q.push(MP(w[y],y));
        }
    }
    ll a = 0;
    ll b = 0;
    
    for(ll x:res){
        sm += b*x;
        b += 1;
    }
    if(v[0]==0){
        cout << sm-qq << endl;
    }else{
        cout << sm << endl;
    }
    return 0;   
}

Measured memory_bytes: 51560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
#define ll long long 
const int maxn = 1400 + 5;

int h, w;
int mem[maxn][maxn];
int dp[maxn][maxn];
int Max;

int solve()
{
    rep(i,w) if(mem[0][i] != 1) dp[0][i] = 1;
    rep(i,h) if(mem[i][0] != 1) dp[i][0] = 1;

    for(int i = 1; i < h; i++)
        for(int j = 1; j < w; j++){
            if(mem[i][j] == 1) dp[i][j] = 0;
            else{
                dp[i][j] = min(dp[i][j-1], min(dp[i-1][j-1], dp[i-1][j])) + 1;
                Max = max(Max, dp[i][j]);
            }
        }

    return Max*Max;
}

int main()
{
    cin >> h >> w;
    rep(i,h)
    rep(j,w){
        cin >> mem[i][j];
        if(!mem[i][j]) Max = 1;
    }
    cout << solve() << endl;
}


Measured memory_bytes: 18464
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	reverse(a,a+n);
	int p=0;
	long long int ans=0;
	for(int i=1;i<n;i++){
		if(p==0){ans+=a[0];p++;continue;}
		ans+=a[p];
		i++;
		if(i==n)break;
		ans+=a[p];
		p++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define mp make_pair
#define MAXN 200005
#define pb push_back
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 + c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int a[MAXN],b[MAXN];
int val[2][MAXN],len[2];
bool check(int p) {
    len[0] = len[1] = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(a[i] & (1 << p)) val[1][++len[1]] = a[i] & (1 << p) - 1;
        else val[0][++len[0]] = a[i] & (1 << p) - 1;
    }
    sort(val[1] + 1,val[1] + len[1] + 1);
    sort(val[0] + 1,val[0] + len[0] + 1);
    int64 res = 0;
    for(int i = 1 ; i <= N ; ++i) {
        int t = (1 << p) - (b[i] & (1 << p) - 1);
        int p0,p1;
        p0 = lower_bound(val[0] + 1,val[0] + len[0] + 1,t) - val[0] - 1;
        p1 = lower_bound(val[1] + 1,val[1] + len[1] + 1,t) - val[1] - 1;
        if(b[i] & (1 << p)) {res += p0;res += len[1] - p1;}
        else {res += p1;res += len[0] - p0;}
    }
    return res & 1;
}
void Solve() {
    read(N);
    for(int i = 1 ; i <= N ; ++i) {read(a[i]);}
    for(int i = 1 ; i <= N ; ++i) {read(b[i]);}
    int ans = 0;
    for(int i = 28 ; i >= 0 ; --i) {
        if(check(i)) ans |= (1 << i);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

vector<int64_t> x[3];
priority_queue<pair<int64_t,pair<int,pair<int,int>>>> pq;
set<pair<int,pair<int,int>>> S;
void upd(int i,int j,int k){
    if(i<0||j<0||k<0)return;
    if(S.find({i,{j,k}})!=S.end())return;
    S.insert({i,{j,k}});
    pq.push({x[0][i]+x[1][j]+x[2][k],{i,{j,k}}});
}
int main() {
    int nx[3],K;
    for(int i=0;i<3;++i)cin>>nx[i];
    cin>>K;
    for(int i=0;i<3;++i){
        for(int j=0;j<nx[i];++j){
            int64_t m;
            cin>>m;
            x[i].push_back(m);
        }
        sort(x[i].begin(),x[i].end());
    }
    upd(nx[0]-1,nx[1]-1,nx[2]-1);
    while(K--){
        int64_t cur=pq.top().first;
        pair<int,pair<int,int>> p=pq.top().second;
        pq.pop();
        cout<<cur<<endl;
        int i=p.first;
        int j=p.second.first;
        int k=p.second.second;
        upd(i-1,j,k);
        upd(i,j-1,k);
        upd(i,j,k-1);
    }
    return 0;
}


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

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
typedef long long ll;
#define F first
#define S second


int n,m,K,s;
ll cost[2];
vector<int> vv[100010];
int z[100010];
ll dp[100010];

int main(){
	cin>>n>>m>>K>>s;
	cin>>cost[0]>>cost[1];
	queue<int> q;
	rep(i,K){
		int a;
		cin>>a;
		z[a-1]=2;
		q.push(a-1);
	}
	rep(i,m){
		int a,b;
		cin>>a>>b;
		vv[a-1].push_back(b-1);
		vv[b-1].push_back(a-1);
	}
	rep(i,s+1){
		int qs=q.size();
		rep(j,qs){
			int top=q.front();q.pop();
			if(z[top]==1) continue;
			if(!z[top]) z[top]=1;
			for(int x:vv[top]){
				if(!z[x]) q.push(x);
			}
		}
	}
	priority_queue<pair<ll,int>> pq;
	pq.push(make_pair(0,0));
	rep(i,n) dp[i] = 1LL<<50;
	dp[0] = 0;
	while(pq.size()){
		auto top = pq.top();pq.pop();
		if(dp[top.S]<-top.F) continue;
		for(int x:vv[top.S]){
			if(z[x]==2) continue;
			if(dp[x]>-top.F+cost[z[x]]){
				dp[x] = -top.F+cost[z[x]];
				pq.push(make_pair(top.F-cost[z[x]],x));
			}
		}
	}
	cout<<dp[n-1]-cost[z[n-1]]<<endl;
}

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

const int MP = 999983;
int sv[MP+1] = {}, ac[MP+1] = {};

int main() {
	ios::sync_with_stdio(false);
	sv[0] = sv[1] = 1;
	for (int i=2; i*i<=MP; ++i) {
		if ( ! sv[i]) {
			for (int j=i*i; j<=MP; j+=i) {
				sv[j] = 1;
			}
		}
	}
	for (int i=1; i<=MP; ++i) {
		ac[i] = ac[i-1] + 1 - sv[i];
	}
	int n, p, m;
	while (cin >> n, n) {
		int ret = 0, X;
		for (int i=0; i<n; ++i) {
			cin >> p >> m;
			ret += ac[min(MP, p+m)] - ac[max(0, p-m-1)] - 1;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 9008
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int h,w;
  while(cin>>h>>w){
    vector<string> mat(h);
    REP(i,h)cin>>mat[i];
    int count[51][51]={};
    REP(i,51)count[0][i] = count[i][0] = 100000;
    count[1][0] = count[0][1] = 0;
    REP(y,h)REP(x,w){
      int k = mat[y][x]-'0';
      count[y+1][x+1] = min(count[y][x+1],count[y+1][x])+k;
    }
    cout<<count[h][w]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
const int N=55556;
vector<int> isprime(N,1);
vector<int> prime;
void  solve(){
	int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  int n1=a[n-1];
  int idx=0;
  rep(i,1,n){
    if(abs(2*a[i]-n1)< abs(2*a[idx]-n1))idx=i;
  }
  cout<<n1<<" "<<a[idx]<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 4020
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  vi a(n), lighted(n,0);
  rep(i,n) cin >> a[i];
  lighted[0] = 1;

  int now=1;
  rep(i,n){
    if(a[now-1]==2){
      cout << i+1 << endl;
      return 0;
    }
    lighted[a[now-1]-1] += 1;
    if(lighted[a[now-1]-1] == 2) break;
    now = a[now-1];
  }

  cout << "-1" << endl;
  return 0;
} 

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int t, x;
  cin >> t >> x;
  double res = (double) t / x;
  cout << fixed << setprecision(15) << res << endl;
  return 0;
}


Measured memory_bytes: 3792
import java.util.*;
import java.io.*;
public class Main{
 
	public static void main(String[] args) throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	String str = br.readLine();
      	if(str.charAt(2) == str.charAt(3) && str.charAt(4) == str.charAt(5))
          System.out.println("Yes");
      	else
          System.out.println("No");
    }
 
}

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

int main() {
    //input
    int a,b,c;
    cin >> a >> b >> c;
    int count = 3;
    if(a==b){
        count--;
    }
    if(b==c){
        count--;
    }else if(a==c){
        count--;
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

class Card {
	String s;
	int value;
	Card (String s, int value) {
		this.s = s;
		this.value = value;
	}
}

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int n = Integer.parseInt(in.readLine());


		Card[] a = new Card[n];
		Card[] b = new Card[n];
		for(int i = 0; i < n; i++) {
			String[] tmp = in.readLine().split(" ");
			a[i]= new Card(tmp[0],Integer.parseInt(tmp[1]));
			b[i]= new Card(tmp[0],Integer.parseInt(tmp[1]));
		}
		
		mergeSort(b, 0, n);
		quickSort(a, 0, n-1);
		
		boolean stable = true;
		for(int i = 0; i < n; i++) {
			if(!a[i].s.equals(b[i].s)) {
				stable = false;
			}
		}
		if(stable) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
		for(int i = 0; i < n; i++) {
			System.out.println(a[i].s + " " + a[i].value);
		}
		


	}
	static void quickSort(Card[] a, int p, int r) {
		if(p <= r) {
			int pivot = partition(a,p,r);
			quickSort(a,p,pivot-1);
			quickSort(a,pivot+1,r);
		}
	}
	static int partition(Card[] a, int p, int r) {
		int i = p-1;
		int x = a[r].value;
		
		for(int j = p; j < r; j++) {
			if(a[j].value <= x) {
				i++;
				Card tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
		Card tmp = a[i+1];
		a[i+1] = a[r];
		a[r] = tmp;
		return i + 1;
	}
	
	static void mergeSort(Card[] a, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(a, left, mid);
			mergeSort(a, mid, right);
			merge(a, left, mid, right);
		}
	}
	static void merge(Card[] a, int left, int mid, int right) {
		int n1 = mid-left;
		int n2 = right-mid;
		
		Card[] b = new Card[n1+1];
		for(int i = 0; i <n1; i++) {
			b[i] = a[left + i];
		}		
		b[n1] = new Card(null, Integer.MAX_VALUE);
		Card[] c = new Card[n2+1];
		for(int i = 0; i <n2; i++) {
			c[i] = a[mid + i];
		}
		c[n2] = new Card(null, Integer.MAX_VALUE);
		
		int i = 0, j = 0;
		for (int k = left; k < right; k++) {
			if(b[i].value <= c[j].value) {
				a[k] = b[i];
				i++;
			} else {
				a[k] = c[j];
				j++;
			}
			
		}
	}
	
}


Measured memory_bytes: 78188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[8] = {-1,0,1,-1,1,-1,0,1};
int sj[8] = {-1,-1,-1,0,0,1,1,1};

int main() {
  string s,t;
  cin >> s;
  cin >> t;

  int ans = M;
  for (int i = 0; i < s.size() - t.size()+1; i++){
    int c = 0;
    for (int j = 0; j < t.size(); j++){
      if (s[i+j] != t[j]) c++;
    }
    ans = min(ans, c);
  }

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


Measured memory_bytes: 3624
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int a[300000][2];
int cx[300000], cy[300000];
int main(void){
	int h=nextint();
	int w=nextint();
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i][0]=nextint()-1;
		a[i][1]=nextint()-1;
		cx[a[i][0]]++;
		cy[a[i][1]]++;
	}
	int bxm=0, bym=0;
	int bx=0, by=0;
	for(int x=0; x<h; x++){
		if(cx[x]>bxm){
			bxm=cx[x];
			bx=1;
		}else if(cx[x]==bxm){
			bx++;
		}
	}
	for(int y=0; y<w; y++){
		if(cy[y]>bym){
			bym=cy[y];
			by=1;
		}else if(cy[y]==bym){
			by++;
		}
	}
	if(bx*by>n){
		int ans=bxm+bym;
		printf("%d\n", ans);
	}else{
		int s=0;
		for(int i=0; i<n; i++){
			if(cx[a[i][0]]==bxm && cy[a[i][1]]==bym){
				s++;
			}
		}
		if(s==bx*by){
			int ans=bxm+bym-1;
			printf("%d\n", ans);
		}else{
			int ans=bxm+bym;
			printf("%d\n", ans);
		}
	}
}


Measured memory_bytes: 6272