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

int n;

int main(){
	cin >> n;
	int cnt = 0;
	map<pair<char, char>, int> mp;
	for(int i = 1; i <= n; i++){
		string str = to_string(i);
		mp[make_pair(str[0], str[(int)str.length() - 1])]++;
	}
	for(int i = 1; i <= n; i++){
		string str = to_string(i);
		cnt += mp[make_pair(str[(int)str.length() - 1], str[0])];
	}
	cout << cnt << "\n";
	return 0;
}


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

using namespace std;

int main()
{
    int N;
    vector<int> a;

    cin >> N;

    for(int i=0; i<N; i++){
        int ai;
        cin >> ai;

        a.push_back(ai);
    }
    
    sort(a.begin(), a.end(), greater<int>());

    int A = 0, B = 0;

    for(int i=0; i<N; i++){
        if(i%2==0){
            A += a.at(i);
        }
        else{
            B += a.at(i);
        }
    }

    cout << A - B << endl;

    return 0;
}

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

#define y1 as214
#define ii pair < int , ll >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)

#define ll long long
#define oo INT_MAX

const int N = 1e5 + 5;
ll n , mod = 1e9 + 7;
ll dp[N][3];
vector < int > g[N];

void DFS(int i , int j)
{
    dp[i][0] = dp[i][1] = 1;
    REP(s , g[i].size())
    {
        int u = g[i][s];
        if(u != j)
        {
            DFS(u , i);
            dp[i][0] = (dp[i][0] * (dp[u][0] + dp[u][1])) % mod;
            dp[i][1] = (dp[i][1] * dp[u][0]) % mod;
        }
    }
}

int main()
{
    //freopen("P.inp","r",stdin);
    cin >> n;
    FOR(i , 1 , n - 1)
    {
        int x , y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    DFS(1 , -1);
    cout << (dp[1][0] + dp[1][1]) % mod;
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
#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 bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; string s;
    cin >> n >> s;

    int ans = 0;
    char c = 0;

    REP(i, n) {
        if (c != s[i]) {
            ans++;
            c = s[i];
        } 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1, i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n;
vector<ll>a,b;
void input(){
    cin>>n;
    a.resize(n);
    b.resize(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
}
void src(){
    cout<<b[distance(a.begin(),max_element(ALL(a)))] + *max_element(ALL(a));
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

void solve(long long A, long long B, long long C){
    vll a; a.push_back(A); a.push_back(B); a.push_back(C);
    sort(a.begin(), a.end());
    ll cnt = 0;
    cnt += (a[2]-a[0])/2; a[0]+= (a[2]-a[0])/2 * 2;
    cnt += (a[2]-a[1])/2; a[1]+= (a[2]-a[1])/2 * 2;
    sort(a.begin(), a.end());
    if(a[0]== a[1] && a[1]==a[2]) 
        cout << cnt << endl;
    else if(a[0]==a[1]) 
        cout << cnt +1 << endl;
    else 
        cout << cnt +2 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


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

using namespace std;

bool graph[60][60];
bool ve[60];
int N;

void dfs(int x){
    if(ve[x]) return;
    ve[x]=true;

    for(int i=0;i<N;i++){
        if(graph[x][i])
            dfs(i);
    }
}

int main(){
    int M;
    cin>>N>>M;
    vector<int> a(M);
    vector<int> b(M);
    for(int i=0;i<M;i++){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
    }
    int ans=0;
    for(int i=0;i<M;i++){
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
        for(int j=0;j<N;j++){ve[j]=false;}
        dfs(0);
        bool connected = false;
        for(int j=0;j<N;j++){
            if(!ve[j])connected=true;
        }
        if(connected){
            ans++;
        }
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int ans = 0;
    int L, R, d;
    cin >> L >> R >> d;
    for(int i = L; i <= R; i++) {
        if(i % d == 0)
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 26236
while True:
    h,w = map(int,input().split())
    if int(h) == 0 and int(w) == 0:break
    for i in range(h):
        for j in range(w):
            flag=(i+j)%2
            if flag==0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7000
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


vector<vector<P>> G;
vector<int> color;

void dfs(int n) {
	for (P v : G[n]) {
		if (color[v.first] == -1) {
			if (v.second == 1) color[v.first] = color[n] ^ 1;
			else color[v.first] = color[n];
			dfs(v.first);
		}
	}
}


signed main() {

	int N;
	cin >> N;
	G.resize(N);
	color.resize(N);
	rep(i, N) color[i] = -1;


	rep(i, N - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		G[u].push_back( P(v, w % 2));
		G[v].push_back( P(u, w % 2));
	}

	color[0] = true;
	dfs(0);

	rep(i, N) {
		cout << color[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 9216
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long total = 0;
		for (int i = k + 1; i <= n; i++) {
			total += (n / i) * (i - k) + Math.max(n % i - k + 1, 0);
			if (k == 0) {
				total--;
			}
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    if (n / 10 == 0) {
        cout << n << "\n";
    } else if (n / 100 == 0) {
        cout << 9 << "\n";
    } else if (n / 1000 == 0) {
        cout << n - 90 << "\n";
    } else if (n / 10000 == 0) {
        cout << 909 << "\n";
    } else if (n / 100000 == 0) {
        cout << n - 9000 - 90 << "\n";
    } else {
        cout << 99999 - 9000 - 90 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn b179(){
    let n:usize = read();
    let data1 : Vec<Vec<usize>> = read_vec2(n as u32);

    let mut count = 0;
    for i in data1.iter(){
        if i[0] == i[1] {
            count += 1;
        }
        else {
            count = 0;
        }
        if count == 3 {
            break;
        }
    }
    if count == 3 {
        println!("{}","Yes");
    }
    else {
        println!("{}","No");
    }
}


fn main() {
    b179();
}

Measured memory_bytes: 2132
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        if (n >= 400 and n <= 599) {
            cout << 8 << endl;
        }
        else if (n >= 600 and n <= 799) {
            cout << 7 << endl;
        }
        else if (n >= 800 and n <= 999) {
            cout << 6 << endl;
        }
        else if (n >= 1000 and n <= 1199) {
            cout << 5 << endl;
        }
        else if (n >= 1200 and n <= 1399) {
            cout << 4 << endl;
        }
        else if (n >= 1400 and n <= 1599) {
            cout << 3 << endl;
        }
        else if (n >= 1600 and n <= 1799) {
            cout << 2 << endl;
        }
        else if (n >= 1800 and n <= 1999) {
            cout << 1 << endl;
        }
    }
    return 0;
}

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

using namespace std;

int main(){
  int N;
  string s;
  cin >> N >> s;
  if(s.size()<=N){
    cout << s << endl;
  }
  else{
    rep(i, N){
      cout << s[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

int main() {
    int w, h;
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    int wall[100][100];
    bool has_arrived[30][30];
    while (true) {
        queue<PP> q;
        cin >> w >> h;
        if (w == 0) {
            return 0;
        }
        for (int i=0; i<2*h-1; i++) {
            for (int j=0; j<w-1+i%2; j++) {
                cin >> wall[j][i];
            }
        }
        for (int y=0; y<h; y++) {
            for (int x=0; x<w; x++) {
                has_arrived[x][y] = false;
            }
        }
        q.push(PP(1, P(0, 0)));
        while (!q.empty()) {
            int count = q.front().first;
            int x = q.front().second.first;
            int y = q.front().second.second;
            if (x == w-1 && y == h-1) {
                break;
            }
            q.pop();
            for (int i=0; i<4; i++) {
                int nx = x+dx[i];
                int ny = y+dy[i];
                if (nx < 0 || w <= nx || ny < 0 || h <= ny) {
                    continue;
                }
                if (wall[(x+nx)/2][y+ny] == 1) {
                    continue;
                }
                if (has_arrived[nx][ny]) {
                    continue;
                }
                has_arrived[nx][ny] = true;
                q.push(PP(count+1, P(nx, ny)));
            }
        }
        if (q.empty()) {
            cout << 0 << endl;
        }
        else {
            cout << q.front().first << endl;
        }
    }
}

Measured memory_bytes: 1232
#include <iostream>
using namespace std;
typedef long long ll;


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

ll minimi(ll a, ll b){
  if (a>b){
    return b;
  } else{
    return a;
  }
}
int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  //ll a[N+1];	
  cin >>A >> B;
  if ((A+B)%3 == 0 || A%3 == 0 || B%3 == 0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  
}



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

int main(){
  int a, b; cin >> a >> b;
  int ans;
  if(a <= b){
    ans = a;
  }else{
    ans = a-1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

left = 0
stock = 0
accum = 0

N.times do |right|
  while accum + A[right] != accum ^ A[right]
    stock += right - left
    accum -= A[left]

    left += 1
  end

  accum += A[right]
end

length = N - left
stock += (length + 1) * length / 2

puts stock


Measured memory_bytes: 16292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;


// This code was written after I read the editorial
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<VI> a(n, VI(m));
  REP(i, 0, n) {
    REP(j, 0, m) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  set<int> kind;
  REP(i, 0, m) {
    kind.insert(i);
  }
  int mi = 1e8;
  REP(loop_cnt, 0, m) {
    PI ma(-1, -1);
    vector<int> cnt(m);
    REP(i, 0, n) {
      int k = -1;
      REP(j, 0, m) {
	if (kind.count(a[i][j])) {
	  k = a[i][j];
	  break;
	}
      }
      cnt[k] += 1;
    }
    REP(i, 0, m) {
      ma = max(ma, PI(cnt[i], i));
    }
    mi = min(mi, ma.first);
    int v = ma.second;
    // remove v
    kind.erase(v);
  }
  cout << mi << "\n";
}


Measured memory_bytes: 640
class Node {
  constructor(board = [], zeroIndex = null, parent = null) {
    this.board = board;
    this.zeroIndex = zeroIndex || this.getZeroIndex();
    this.parent = parent;
  }

  getZeroIndex() {return this.board.indexOf(0);}

  get depth() {
    let node = this, depth = 0;
    while ((node = node.parent)) depth++;
    return depth;
  }
}

class EightPazzle {
  init() {
    EightPazzle.inited = true;
    EightPazzle.correct_board = [1, 2, 3, 4, 5, 6, 7, 8, 0];
    EightPazzle.adjLists = [
      [1, 3], [0, 2, 4], [1, 5],
      [0, 4, 6], [1, 3, 5, 7], [2, 4, 8],
      [3, 7], [4, 6, 8], [5, 7]
    ];
  }

  constructor(begin_board) {
    EightPazzle.inited || this.init();
    this.cache = {begin_board: true};
    this.queue = [new Node(begin_board)];
  }

  solve() {
    const cb = EightPazzle.correct_board.toString();
    const isCorrect = (n) => n.board.toString() === cb;
    if (isCorrect(this.queue[0])) return this.queue[0];

    let node, newNode, board, zeroIdx, flg;
    while ((node = this.queue.shift()) !== undefined) {
      zeroIdx = node.zeroIndex;
      
      flg = EightPazzle.adjLists[zeroIdx].some(next => {
        board = [].concat(node.board);
        board[zeroIdx] = [board[next], board[next] = board[zeroIdx]][0];
        newNode = new Node(board, next, node);
        if (!this.cache[board]) {
          if (isCorrect(newNode)) return true;
          this.cache[board] = true;
          this.queue.push(newNode);
        }
        return false;
      });
      if (flg) return newNode;
    }
  }
}

(function main() {
  const board = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split(/[ \n]/).map(Number);
  const E = new EightPazzle(board);
  console.log(E.solve().depth);
})();



Measured memory_bytes: 129708
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/



int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<char>>A(H, vector<char>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	vector<char>T(W,'.');
	vector<int>Z(W, 0);
	int cnt = 1;
	vector<vector<int>>B(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		if (A[i] == T) B[i] = Z;
		else {
			for (int j = 0; j < W; j++) {
				B[i][j] = cnt;
				if (A[i][j] == '#')cnt++;
			}
			//if (A[i] != T&&A[i][W-1]!='#')cnt++;
		}
	}
	/*for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << B[i][j] << ' ';
		}
		cout << endl;
	}*/
	for (int i = 0; i < H; i++) {
		if (A[i][W - 1] == '.') {
			B[i][W - 1]--;
			for (int j = 0; j < W-1; j++) {
				if (B[i][W - j - 1] != B[i][W - j - 2]) {
					B[i][W - j - 2]--;
				}
				else break;
			}
		}
	}
	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (B[i][j] == -1) {
				B[i][j] = B[i - 1][j];
			}
		}
	}
	for (int i = 1; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (B[H-i-1][j] == -1) {
				B[H-i-1][j] = B[H-i-1+1][j];
			}
		}
	}



	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << B[i][j] << ' ';
		}
		cout << endl;
	}
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(void)
{

	int n, x;
	int m[101];
	int i;
	int a = 0;
	int b;
	int c;
	 m[0] = 0;

	scanf("%d %d", &n, &x);
	for (i = 0; i < n; i++) {
		scanf("%d", &m[i]);
		a += m[i];

	}
	b = x - a;
	c = m[0];

	for (i = 0; i < n; i++) {
		if (c > m[i]) {
			c = m[i];
		}
	}
	printf("%d", (b / c)+n);
	
	return 0;
}

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

int main(){
    int n,an;
    cin >> n ;
    int list[n]={0};

    for(int i=n-1;i>=0;i--){
        cin >> an;
        list[i]= an ;
    }
    for(int i=0;i<n-1;i++){
        cout << list[i] << " " ;
        
    }
    cout << list[n-1] << endl;

    return 0;

}


Measured memory_bytes: 3116
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,j=0,k=0;
  char x[100],y[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",x,y);
    if ( strcmp(x,y) == 0 ) {
      j++;
      k++;
    }else if ( strcmp(x,y) > 0 ){
      j=j+3;
    }else if ( strcmp(x,y) < 0 ) {
	k=k+3;
    }
  }
  printf("%d %d\n",j,k);
  return 0; 
}




Measured memory_bytes: 2100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

   	int x;
   	cin>>x;
   	int p = 100;
   	int cnt = 0;
   	while(p<x){
   		p += p/100;
   		cnt++;
   	}
   	cout<<cnt;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3616
#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i;
  int e,n,p;
  string s,t,u;
  map<string,int> a;
  a.clear();
  a["yotta"]=24;
  a["zetta"]=21;
  a["exa"]=18;
  a["peta"]=15;
  a["tera"]=12;
  a["giga"]=9;
  a["mega"]=6;
  a["kilo"]=3;
  a["hecto"]=2;
  a["deca"]=1;
  a["deci"]=-1;
  a["centi"]=-2;
  a["milli"]=-3;
  a["micro"]=-6;
  a["nano"]=-9;
  a["pico"]=-12;
  a["femto"]=-15;
  a["ato"]=-18;
  a["zepto"]=-21;
  a["yocto"]=-24;
  cin>>n;
  for(h=0;h<n;h++){
    cin>>s>>t;
    if(a[t])
      cin>>u;
    else
      u=t;
    while(s[0]=='0')
      s.erase(0,1);
    for(i=0;'1'>s[i]||s[i]>'9';i++);
    if((p=s.find('.'))==(int)string::npos){
      e=(int)s.length()-i-1;
      s.insert(i+1,1,'.');
    }else{
      if(p>i){
	e=p-i-1;
	s.erase(p,1);
	s.insert(i+1,1,'.');
      }else{
	e=p-i;
	s.erase(p,1);
	s.insert(i,1,'.');
      }
    }
    while(s[0]=='0')
      s.erase(0,1);
    if(s[s.length()-1]=='.')
      s.erase(s.length()-1,1);
    e+=a[t];
    cout<<s<<" * 10^"<<e<<" "<<u<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
n=str(input())

def solve(n):
  res=0
  if len(n)==1:
    return n
  v=n[0]
  p=int(n[0])
  for i in range(len(n)-1):
    v+='9'
    p+=9
  if v==n:
    return p
  for i in range(len(n)):
    if i==0:
      res+=int(n[0])-1
    else:
      res+=9
  return res
  
print(solve(n))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ios       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,a,n) for (ll i = a; i < (ll)(n); i++)
#define fon(i,n) for (ll i = (ll)n-1; i >=0; i--)
#define vi          vector<ll>
#define vii vector<pair<ll,ll>>
#define all(a)      (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ciin(v) forn(i,0,v.size()) cin>>v[i]
#define coutt(v) forn(i,0,v.size()) cout<<v[i]<<" "
using namespace std;
int main(){
    ios
    ll test;
    test=1;
    // cin>>test;
    while(test--){
      ll n,x;
      cin>>n>>x;
      vi v(n),p(n+1,1e18);
      ciin(v);
      x=min(n,x);
      p[0]=0;
      p[1]=abs(v[1]-v[0]);
      forn(i,2,n){
        for(ll j=max(0ll,i-x);j<i;j++){
          p[i]=min(p[i],p[j]+abs(v[j]-v[i]));
        }
      }
      cout<<p[n-1];
      

        
       
     
      
       
  }}  


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int h,a;
    cin >> h >> a;
    int hit = h;
    int cnt = 0;
    while(hit > 0){
        hit -= a;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N;
long A[88];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	long now=1000;
	for(int i=0;i<N-1;i++)
	{
		long X=now,Y=now%A[i]+now/A[i]*A[i+1];
		now=X<Y?Y:X;
	}
	cout<<now<<endl;
}

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

enum Sauce{ NOT_DETERMINED = 0, Tomato = 1, Cream = 2, Basil = 3 };
enum Seq{ SAME, DIFF };

const int divisor = 10000;

class Pasta{
public:
	Pasta(int _N);
	~Pasta();

	void setSauce(int A, Sauce B){ sauceary[A] = B; }
	int schedule(int i, Sauce yesterday, Seq seq);

private:
	int N;
	int*** memo;
	Sauce* sauceary;
};

Pasta::Pasta(int _N){
	N = _N;
	sauceary = new Sauce[N + 1];
	memo = new int**[N + 1];

	for (int i = 0; i <= N; i++) sauceary[i] = NOT_DETERMINED;

	for (int i = 0; i <= N; i++){
		memo[i] = new int*[4];
		for (int j = 0; j < 4; j++){
			memo[i][j] = new int[2];
			memo[i][j][SAME] = -1;
			memo[i][j][DIFF] = -1;
		}
	}
}

Pasta::~Pasta(){
	delete[] sauceary;
	delete[] memo;
}

int Pasta::schedule(int i, Sauce yesterday, Seq seq){
	if (i == N + 1) return 1;
	if (memo[i][yesterday][seq] >= 0) return memo[i][yesterday][seq];

	if (seq == SAME && yesterday == sauceary[i]){
		memo[i][yesterday][SAME] = 0;
		return 0;
	}

	if (sauceary[i] == NOT_DETERMINED){
		int tmpmemo = 0;

		for (int si = 1; si <= 3; si++){
			if ((Sauce)si == yesterday && seq == SAME) continue;
			else if ((Sauce)si == yesterday && seq == DIFF) tmpmemo += schedule(i + 1, (Sauce)si, SAME) % divisor;
			else tmpmemo += schedule(i + 1, (Sauce)si, DIFF) % divisor;
		}

		memo[i][yesterday][seq] = tmpmemo % divisor;
		return memo[i][yesterday][seq];
	}
	else {
		memo[i][yesterday][seq] = schedule(i + 1, sauceary[i], (yesterday == sauceary[i] ? SAME : DIFF)) % divisor;	
		return memo[i][yesterday][seq];
	}
}

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

	Pasta* pasta = new Pasta(N);

	for (int i = 0; i < K; i++){
		int A, B;
		cin >> A >> B;
		pasta->setSauce(A, (Sauce)B);
	}

	cout << pasta->schedule(1, NOT_DETERMINED, DIFF) << endl;

	delete pasta;
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int d;
    cin >> d;
    switch (d)
    {
        case 25:
            println("Christmas");
            break;
        case 24:
            println("Christmas Eve");
            break;
        case 23:
            println("Christmas Eve Eve");
            break;
        case 22:
            println("Christmas Eve Eve Eve");
            break;
    
    default:
        break;
    }
    return 0;
}

Measured memory_bytes: 3560
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)*}
    };
}

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)*}
    };
}

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

use std::collections::BTreeMap;

fn main() {
    input!{
        s: chars,
        t: chars
    }
    let mut map1: BTreeMap<char,char> = BTreeMap::new();
    let mut map2: BTreeMap<char,char> = BTreeMap::new();
    for i in 0..s.len() {
        if let Some(&c) = map1.get(&s[i]) {
            if c != t[i] {
                println!("No");
                return;
            }
        } else if let Some(&c) = map2.get(&t[i]) {
            if c != s[i] {
                println!("No");
                return;
            }
        } else {
            map1.insert(s[i],t[i]);
            map2.insert(t[i],s[i]);
        }
    }
    println!("Yes");
}


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

int main(){
  int N,K,i;
  cin >> N >> K;
  
  vector<int> a(N);

  for(i=0;i<N;i++)
    cin >> a[i];
  
  for(i=0;i<N-K;i++)
    if (a[i] < a[K+i])
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;

  return 0;
  
}

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

#define int long long int
#define double long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define inf LLONG_MAX


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

	int n;
	cin>>n;
	if(n>=30)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int n;
  while(cin>>n,n){
    vector<int> data(n);
    for(int i=0;i<n;i++){
      cin>>data[i];
    }
    sort(data.begin(),data.end());
    
    int sum=0;
    for(int i=1;i<n-1;i++){
      sum+=data[i];
    }
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}



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

#define _u(i,a,b) for(int i=a;i<=b;++i)
#define _d(i,a,b) for(int i=a;i>=b;--i)
#define endl "\n"
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define FIO() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FI(task) freopen(task".inp","r",stdin)
#define FO(task) freopen(task".out","w",stdout)

using namespace std;

const int N = 1e5+7;
const int M = 1e9+7;

bool f[N];
int a[N];
int n, k;

#define task "test"

int main(){
    FIO();
    //FI(task);
    ///FO(task);

    cin >> n >> k;
    _u(i,1,n) cin >> a[i];
    _u(i,1,k) _u(j,1,n){
        if(i<a[j]) continue;
        f[i] |= !(f[i-a[j]]);
    }
    cout << (f[k]?"First":"Second");
    return 0;
}


Measured memory_bytes: 384
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N, A, B;
  cin >> N >> A >> B;

  ll now = il();

  ll fatigue = 0;
  rep(i, N-1){
    ll bef = now;
    now = il();
    if ((now - bef)*A>=B) fatigue += B;
    else fatigue += (now - bef)*A;
  }

  cout << fatigue << endl;
  
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int a, b, c;

  void solve() {
    cin >> a >> b >> c;
    if (a == b && b == c) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  Problem::Solver sol;
  sol.solve();
  return 0;
}


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

int main(){
  int N,X;cin>>N>>X;
  vector<int> L(N); for(auto &e:L)cin>>e;
  vector<int> D(N+1);
  D[0] = 0;
  for(int i=1;i<=N;++i) {
    D[i] = D[i-1]+L[i-1];
  }
  int sum = 0;
  for(int i=0;i<=N;++i) {
    if (D[i]>X) break;
    sum++;
  }
  cout<<sum<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll N, X, Y, d, tmp, l, r, lrs;
  cin >> N >> X >> Y;
  d = Y - X;
  
  ll mat[2010][2010]={};
  ll ans[2010]={};
  
  FOR(i, 0, N){
    FOR(j, i+1, N){
      if((i>=(X-1)) && (j<=(Y-1))){
        mat[i][j] = min((ll)(j-i), Y-1-j+i-(X-1)+1);
        //cout << i << " " << j << " " << mat[i][j] << endl;
      }else if(i>=(Y-1)){
        mat[i][j] = j-i;
      }else if(j<=(X-1)){
        mat[i][j] = j-i;
      }else if((i>=(X-1)) && (j>(Y-1))){
        mat[i][j] = min((ll)(Y-1-i), i-(X-1)+1) + j-(Y-1);
      }else if((i<(X-1)) && (j<=(Y-1))){
        mat[i][j] = min((ll)(j-(X-1)), Y-1-j+1) + (X-1)-i;
      }else{
        mat[i][j] = j-i-(Y-X)+1;
      }
    }
  }
  
  FOR(i, 0, N){
    FOR(j, i+1, N){
      ans[mat[i][j]-1]++;
      //cout << i << " " << j << " " << mat[i][j] << endl;
    }
  }
  
  rep(i, N-1) cout << ans[i] << endl;
  
  /*vector<ll> diff;
  vector<ll> ans;
  
  rep(i, N) {
    if(i < d){
      diff.push_back(0);
    }else{
      lrs = i-d+1;
      l = Y - i;
      r = X + i;
      if(l <= 0) lrs += (l-1);
      if(r > N) lrs -= (r-N);
      diff.push_back(lrs);
    }
  }
  rep(i,2000) diff.push_back(0);
  
  rep(i, N-1) {
    cout << i+1 << " " << diff[N-i] << " " << diff[N-1-i] << endl;
    ans.push_back(i+1+diff[N-i+(d-1)]-diff[N-1-i]);
  }
  
  for (int i = 0; i < ans.size(); i++){
    cout << ans[ans.size()-1-i] << endl;
  }*/

  
}

Measured memory_bytes: 31872
str = input()

q = int(input())

for i in range(q):
    
    command = input().split()
    #print(str, command)
    if command[0] == 'replace':
        a, b, p = command[1:]
        str = str[:int(a)] + p + str[int(b) + 1:]
        
    elif command[0] == 'reverse':
        a, b = [int(x) for x in command[1:]]
        str = str[:a] + ''.join(list(reversed(str[a:b + 1]))) + str[b + 1:]
        
    elif command[0] == 'print':
        a, b = [int(x) for x in command[1:]]
        print(str[a:b + 1])
        


Measured memory_bytes: 5620
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)

sort_arr = arr.uniq.sort
ans = sort_arr[1] || sort_arr[0]
while ans > 1 do
  fail_count = 0
  arr.each do |num|
    fail_count += 1 if num % ans != 0
    break if fail_count >= 2
  end
  break if fail_count < 2

  if ans == sort_arr[1]
    ans = sort_arr[0]
  else
    ans -= 1
  end
end
puts ans


Measured memory_bytes: 9604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long int LL;
typedef pair<int, int> PII;

int main(void){
  int n;
  cin >> n;
  int sum[n];
  int min_diff = 10000;

  for (int i = 0; i < n; i++) {
    sum[i] = 0;
  }

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

  for (int i = 0; i < n; i++) {
    int s1 = sum[i];
    int s2 = sum[n-1] - sum[i];
    min_diff = min(min_diff, abs(s2-s1));
  }

  cout << min_diff << endl;
  return 0;
}

Measured memory_bytes: 256
#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 n;
	ll d; 
	cin >> n >> d;
	int ans = 0;
	rep(i,n) {
		ll x,y;
		cin >> x >> y;
		if(x*x+y*y <= d*d) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		int n;
		cin>>n;
		if(n%1000==0){
			cout<<0<<endl;
		}
		else
		cout<<1000-(n%1000)<<endl;
		return 0;
	}


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

using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n, d) for (int i = (s); i < (int)(n); i += (d))
#define allpt(v) (v).begin(), (v).end()
#define allpt_c(v) (v).cbegin(), (v).cend()
#define allpt_r(v) (v).rbegin(), (v).rend()

const int mod = 1e9 + 7, mod2 = 998244353, mod3 = 1e9 + 9;
const ll inf = 1e18;

const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

template <typename T>
void show1dvec(const vector<T> &v)
{
    if (v.size() == 0)
        return;
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << wsp;
    cout << v[n] << rt;

    return;
}

template <typename T>
void show2dvec(const vector<vector<T>> &v)
{
    int n = v.size();
    rep(i, n) show1dvec(v[i]);
}

template <typename T, typename S>
void show1dpair(const vector<pair<T, S>> &v)
{
    int n = v.size();
    rep(i, n) cout << v[i].first << wsp << v[i].second << rt;
    return;
}

template <typename T, typename S>
void pairzip(const vector<pair<T, S>> &v, vector<T> &t, vector<T> &s)
{
    int n = v.size();
    rep(i, n)
    {
        t.push_back(v[i].first);
        s.push_back(v[i].second);
    }
    return;
}

template <typename T>
void maxvec(vector<T> &v)
{
    T s = v[0];
    int n = v.size();
    rep(i, n - 1)
    {
        if (s > v[i + 1])
        {
            v[i + 1] = s;
        }
        s = v[i + 1];
    }
}

template <typename T, typename S>
bool myfind(T t, S s)
{
    return find(t.cbegin(), t.cend(), s) != t.cend();
}

bool check(int y, int x, int h, int w)
{
    return 0 <= y && y < h && 0 <= x && x < w;
}

VL cumsum(const VL &v)
{
    int s = 0;
    VL ret = {0};

    rep(i, v.size())
    {
        s += v[i];
        ret.push_back(s);
    }
    return ret;
}

bool iskadomatsu(int a, int b, int c)
{
    return (a != b && b != c && c != a) && ((a > b && b < c) || (a < b && b > c));
}

VS split(string s, char c)
{
    VS ret;
    string part;
    s += c;
    rep(i, s.length())
    {
        if (s[i] == c)
        {
            ret.emplace_back(part);
            part = "";
        }
        else if (s[i] != c)
        {
            part += s[i];
        }
    }
    return ret;
}



int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, x;
    cin >> n;
    VI buka(n);
    rep(i, n - 1)
    {
        cin >> x;
        x--;
        buka[x]++;
    }
    for (auto i : buka)
        cout << i << rt;
    return 0;
}


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

S_list = []
for _ in range(N):
	S_list.append(input().strip())

data = []
for s in S_list:
	bottom = 0
	height = 0
	for c in s:
		if c == ")":
			height -= 1
			if bottom > height:
				bottom = height
		else:
			height += 1
	if height == 0:
		k1 = 1
		k2 = 0
	elif height > 0:
		k1 = 0
		k2 = -bottom
	else:
		k1 = 2
		k2 = bottom - height
	data.append((k1, k2, bottom, height, s))

data.sort()

def check():
	height = 0
	for k1, k2, b, h, s in data:
#		print(height, b, h, s)
		if height + b < 0:
			return False
		height += h
	return height == 0

if check():
	print("Yes")
else:
	print("No")



Measured memory_bytes: 106912
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string s; cin >> s;
    cout << ("ABC" + s) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
typedef long long ll;


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    int k, n; cin >> k >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<int> dis(n,0);
    for(int i = 0; i < n-1; ++i) {
        dis[i] = abs(a[i] - a[i+1]);
    }
    dis[n-1] = abs(a[n-1] - k) + a[0];
    ll ans = 0;
    ll ma = 0;
    for(int i = 0; i < n; ++i) {
        ans += dis[i];
        ma = max(ma, (ll)dis[i]);
    }
    ans -= ma;
    cout << ans << endl;

    
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    b.at(i)=a.at(i);
  }
  
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  
  if(b.at(0)==b.at(1)){
    for(int i=0;i<n;i++)
      cout << b.at(0) << endl;
  }
  else{
    for(int i=0;i<n;i++){
      if(a.at(i)==b.at(0))
        cout << b.at(1) << endl;
      else
        cout << b.at(0) << endl;
    }
  }
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iterator>

using namespace std;

int main()
{
	int N, M, K;
	cin >> N >> M >> K;
	vector<long long> A(N), B(M);
	for (auto& A_i : A) {
		cin >> A_i;
	}
	for (auto& B_i : B) {
		cin >> B_i;
	}

	vector<long long> accA(1, 0);
	vector<long long> accB(1, 0);

	partial_sum(A.begin(), A.end(), back_inserter(accA));
	partial_sum(B.begin(), B.end(), back_inserter(accB));

	int ans = 0;

	for (int i = 0; i <= N; ++i) {
		if (accA[i] > K) {
			continue;
		}
		int j = upper_bound(accB.begin(), accB.end(), K - accA[i]) - accB.begin() - 1;
		ans = max(ans, i + j);
	}


	cout << ans << endl;
}


Measured memory_bytes: 11120