akhauriyash/Code-Regression huggingface dataset:
n=int(input())
ans=set()
if n%2==0:
    i=1
    while i<n+1-i:
        x,y=i,n+1-i
        for j in range(1,n+1):
            if j!=x and j!=y:
                if (j,x) not in ans:
                    ans.add((x,j))
                if (j,y) not in ans:
                    ans.add((y,j))
        i+=1
else:
    i=1
    while i<n-i:
        x,y=i,n-i
        for j in range(1,n+1):
            if j!=x and j!=y:
                if (j,x) not in ans:
                    ans.add((x,j))
                if (j,y) not in ans:
                    ans.add((y,j))
        i+=1
    for j in range(1,n):
        if (j,n) not in ans:
            ans.add((n,j))
print(len(ans))
for i,j in ans:
    print(i,j)


Measured memory_bytes: 4028
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long int
#define pb push_back
#define bpc __builtin_popcount
#define f first
#define s second

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong sum1 = 0, sum2 = 0;
string s;

int main(){
    cin >> s;
    sum1 = s[0] - '0' - 1;
    for (int i = 1; i < s.size(); i ++){
        sum1 += 9;
    }for (int i = 0; i < s.size(); i ++){
        sum2 += (s[i] - '0');
    }llong mx = max(sum1, sum2);
    cout << mx;
    return 0;
}


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

int main(){
  int a, b;
  string op;
  while(true){
    cin >> a >> op >> b;
    if(op == "?"){break;}
    
    if (op == "+"){
      cout << a + b << endl;
    }else if(op == "-"){
      cout << a - b << endl;
    }else if(op == "/"){
      cout << a / b << endl;
    }else if(op == "*"){
      cout << a * b << endl;
    }
  }
}


Measured memory_bytes: 3148
/**
 *
 * @author Daipayan Mukherjee
 * @Jadavpur University,Information Technology
 *
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        int[] heights = new int[n];
        for(int i=0;i<n;i++){
            heights[i] = Integer.parseInt(s[i]);
        }
        int[] dp = new int[n];
        Arrays.fill(dp,Integer.MAX_VALUE);
        
        dp[0] = 0;
        
        for(int i=1;i<n;i++){
            dp[i] = Math.min(dp[i],dp[i-1]+Math.abs(heights[i-1]-heights[i]));
            if(i>=2)
                dp[i] = Math.min(dp[i], dp[i-2]+Math.abs(heights[i-2]-heights[i]));
        }
        System.out.println(dp[n-1]);
    }
}


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

int su[200005];

int abs_(int x){
    if(x < 0) return -x;
    else return x;
}

int main(){
    int n;
    long long ans = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&su[i]);
        su[i] -= (i+1);
    }
    sort(su, su+n);
    int me = su[n/2];
    for(int i=0;i<n;i++) ans += abs_(su[i] - me);
    printf("%lld\n", ans);
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

type shop struct {
	index int
	city string
	point int
}

type sortCity []shop

func (s sortCity) Len() int {
	return len(s)
}

func (s sortCity) Less(i, j int) bool {
	return s[i].city < s[j].city
}

func (s sortCity) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type sortPointStable []shop

func (s sortPointStable) Len() int {
	return len(s)
}

func (s sortPointStable) Less(i, j int) bool {
	if s[i].city == s[j].city {
		return s[i].point > s[j].point
	}
	return s[i].city < s[j].city
}

func (s sortPointStable) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}


var n int

func main() {
	fmt.Scanf("%d", &n)

	list := make([]shop, n)

	var city string
	var point int

	for i := 0; i < n; i++ {
		fmt.Scanf("%s %d", &city, &point)
		list[i] = shop{index:i+1, city:city, point:point}
	}

	sort.Sort(sortCity(list))
	sort.Sort(sortPointStable(list))

	for _, shop := range list {
		fmt.Println(shop.index)
	}
}


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

int main() {
  int N , M;
  cin >> N >> M;
  vector<int> high(N);
  for (int i = 0; i < N; i++) {
    cin >> high.at(i);
  }
  vector<vector<int>> bridge(M , vector<int> (2));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> bridge.at(i).at(j);
    }
  }
  
  vector<int> A(N); //A = {1,2,...,N}
  for(int i = 0; i < N; i++) {
    A.at(i) = i + 1;
  }
  
  for (int i = 0; i < M; i++) {
    if (high.at(bridge.at(i).at(0) - 1) >= high.at(bridge.at(i).at(1) - 1)) {
      A.at(bridge.at(i).at(1) - 1) = 0;
    }
    if (high.at(bridge.at(i).at(0) - 1) <= high.at(bridge.at(i).at(1) - 1)) {
      A.at(bridge.at(i).at(0) - 1) = 0;
    }
  }
  
  int count = N;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) {
      count--;
    }
  }
  
  cout << count << endl;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	if(n>2 && m>2){
		ans=(n-2)*(m-2);
	}else if(n==2){
		ans=0;
	}else if(m==2){
		ans=0;
	}else if(n>2){
		ans=(n-2)*m;
	}else if(m>2){
		ans=(m-2)*n;
	}else{
		ans=n*m;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

int main() {
    int n, t;
    cin >> n >> t;
    int cnt = 0;
    int in;
    cin >> in;
    int last = in;
    REP(i,1,n) {
        cin >> in;
        if (last + t > in) {
            cnt += in - last;
            last = in;
        } else {
            cnt += t;
            last = in;
        }
    }
    cnt += t;
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $H, $W);

for ($i = 0; $i < $H; $i++) {
    fscanf(STDIN, "%s", $t);
    $s[$i] = str_split($t);
}

$answer = "Yes";

for ($i = 0; $i < $H; $i++) {
    for ($j = 0; $j < $W; $j++) {
        if ($s[$i][$j] === '#') {
            if (isset($s[$i-1][$j]) && $s[$i-1][$j] === '#') continue;
            if (isset($s[$i+1][$j]) && $s[$i+1][$j] === '#') continue;
            if (isset($s[$i][$j-1]) && $s[$i][$j-1] === '#') continue;
            if (isset($s[$i][$j+1]) && $s[$i][$j+1] === '#') continue;
            $answer = "No";            
        }
    }
}

echo $answer . PHP_EOL;


Measured memory_bytes: 4728
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s: String = read!(String);
    let sc: Vec<char> = s.chars().collect();

    let mut cnt_a = 0f64;
    let mut ans = 0f64;
    let mut i = 0;
    while i < sc.len() - 1 {
        if sc[i] == 'A' {
            cnt_a += 1.0;
            i += 1;
        } else if sc[i] == 'B' && sc[i + 1] == 'C' {
            ans += cnt_a;
            i += 2;
        } else {
            cnt_a = 0.0;
            i += 1;
        }
    }
    println!("{}", ans as i64);
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  ll ans = 0;
  ll gcnt = 0;
  rep(i,s.size()) {
    if(s[i] == 'p'){
      if(gcnt == 0){
        gcnt++;
        ans--;
      }else{
        gcnt--;
      }
    }
    else{
      if(gcnt == 0){
        gcnt++;
      }else{
        gcnt--;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
 
using namespace std;
 
void FiveTransportations()
{
  long long n;
  cin >> n;
  long long t;
  long long min;
 
  cin >> min;
  for (int i = 0; i < 4; i++)
  {
    cin >> t;
    if (min > t) min = t;
  }
 
  long long time;
  if (n % min == 0) time = n / min;
  else time = n / min + 1;
 
  cout << time+4 << endl;
  return;
}
 
 
int main()
{
  FiveTransportations();
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int n,i,flag=0;
  scanf("%d",&n);
  int a[n];

  for(i=0;i<n;i++){
    scanf("%d",a+i);
  }

  for(i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        flag=1;
        break;
      }
    }
  }


if(flag==0)printf("APPROVED");
else printf("DENIED");

  return 0;
}

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


int main(){
	int a[5];
	int x,y;
	while(cin>>x>>y,x|y){
		a[0]=x+y;
		for(int i=1;i<5;i++)cin>>x>>y,a[i]=x+y;
		int *p=max_element(a,a+5);
		cout<<(char)(p-a+'A')<<' '<<*p<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 

n,k,*a = list(map(int,read().split()))
for i in range(n): a[i] -= 1

def pow2(a,n):
    if n==0: return list(range(n))
    if n==1: return a
    if n%2:
        return mul(a,pow2(a,n-1))
    else:
        x = pow2(a,n//2)
        return mul(x,x)

def mul(a,b):
    return [a[bi] for bi in b]

x = pow2(a,k)
print(x[0]+1)

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     std::begin(_obj), std::end(_obj)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define ceilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define has(_obj, _val)               ((_obj).find(_val) != (_obj).end())
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
int cnt[3];
double dp[301][301][301];
double p[301][301][301];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    loop(n) {
        int x;
        cin >> x;
        ++cnt[x - 1];
    }
    const int sum = n;
    p[cnt[0]][cnt[1]][cnt[2]] = 1;
    for (int x3 = cnt[2]; x3 >= 0; --x3) {
        for (int x2 = sum; x2 >= 0; --x2) {
            for (int x1 = sum; x1 >= 0; --x1) {
                if (x1 + x2 + x3 == 0 || x1 + x2 + x3 > n) {
                    continue;
                }
                const int zero = sum - x1 - x2 - x3;
                double q = 1.0 * zero / sum;
                dp[x1][x2][x3] += p[x1][x2][x3] / (1 - q);
                if (x3 > 0) {
                    double curp = 1.0 * x3 / (x1 + x2 + x3);
                    p[x1][x2 + 1][x3 - 1] += p[x1][x2][x3] * curp;
                    dp[x1][x2 + 1][x3 - 1] += dp[x1][x2][x3] * curp;
                }
                if (x2 > 0) {
                    double curp = 1.0 * x2 / (x1 + x2 + x3);
                    p[x1 + 1][x2 - 1][x3] += p[x1][x2][x3] * curp;
                    dp[x1 + 1][x2 - 1][x3] += dp[x1][x2][x3] * curp;
                }
                if (x1 > 0) {
                    double curp = 1.0 * x1 / (x1 + x2 + x3);
                    p[x1 - 1][x2][x3] += p[x1][x2][x3] * curp;
                    dp[x1 - 1][x2][x3] += dp[x1][x2][x3] * curp;
                }
            }
        }
    }
    cout << fixed << setprecision(15) << dp[0][0][0] << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


Measured memory_bytes: 426240
n = [0]
a = []

def format_input(filename = None):
	global n
	global a
	if filename == None:
		n = int(input())
		a = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 2 * 10**5)
		a = [rng(1, n) for i in range(n)]

def get_answer():
	balls = [0] * (n+1)
	for i in a:
		balls[i] += 1

	selection = [0] * (n+1)
	selection_all = 0
	for j in range(n+1):
		selection[j] = balls[j] * (balls[j] - 1) // 2
		selection_all += selection[j]

	for k in range(n):
		correction = (balls[a[k]] - 1) * (balls[a[k]] - 2) // 2 - selection[a[k]]
		answer = selection_all + correction
		print(answer)

if __name__ == '__main__':
	format_input()

	get_answer()


Measured memory_bytes: 25584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n;
  cin >> n;
  vector<P> posA,negA,negB;
  rep(i,n) {
    string str;
    cin >> str;
    ll sum = 0, min_s = 1001001001;
    rep(i,(int)str.length()) {
      if (str[i] == '(') sum++;
      else sum--;
      chmin(min_s, sum);
    }
    if (sum >= 0) posA.emplace_back(P(min_s, sum));
    else {
      int ind = negA.size();
      negA.emplace_back(P(min_s, sum));
      negB.emplace_back(P(sum - min_s, ind));
    }
  }
  ll T = 0;
  bool ok = true;
  sort(all(posA), greater<P>()); //minが大きい順
  rep(i, (int)posA.size()) {
    if (T + posA[i].first < 0) {
      ok = false; break;
    }
    T += posA[i].second;
  }
  sort(all(negB), greater<P>()); //sum-minが大きい順
  rep(i,(int)negB.size()) {
    int ind = negB[i].second;
    if (T + negA[ind].first < 0) {
      ok = false; break;
    }
    T += negA[ind].second;
  }
  // debug(T);
  if (T != 0) ok = false;
  cout << (ok ? "Yes" : "No") << endl;
}

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

#define ll long long
#define llong long long
#define REP(i,n) for(auto i=0;i<n;++i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define FOR(i,a,b) for(auto i=a;i<b++i)
#define ALL(v) v.begin(),v.end()
#define pb push_back

using namespace std;

int win(vector<vector<int> > &v, vector<int> &c, int u){
  int n = v.size(), m = c.size();
  vector<vector<bool> > ismark(n, vector<bool>(n,false));
  map<int, pair<int, int> > idxs;
  for(int i = 0; i < n; i++)for(int j = 0; j < n; j++){
    idxs[v[i][j]] = make_pair(i,j);
  }
  vector<bool> bingo(2*n+2,false);
  for(int i = 0; i < m; i++){
    auto element = idxs.find(c[i]);
    if(element == idxs.end())continue;
    auto idx = element->second;
    ismark[idx.first][idx.second] = true;
    bool row = true, col = true;
    for(int j = 0; j < n; j++)
      if(!ismark[j][idx.second]){
        row=false;
        break;
      }
    for(int j = 0; j < n; j++)
      if(!ismark[idx.first][j]){
        col=false;
        break;
      }
    bingo[idx.first] = row || bingo[idx.first];
    if(n != 1){
      bingo[n+idx.second] = col || bingo[n+idx.second];
    }
    {
      bool s = true, bs = true;
      for(int j = 0; j < n; j++)
        if(!ismark[j][j]){
          s = false;
          break;
        }
      for(int j = 0; j < n; j++)
        if(!ismark[j][n-j-1]){
          bs = false;
          break;
        }
      if(n != 1){
        bingo[2*n] = s || bingo[2*n];
        bingo[2*n+1] = bs || bingo[2*n+1];
      }
    }
    int b = 0;
    for(auto e : bingo){
      if(e)b++;
    }
    if(b >= u)return i;
  }
  return m;
}

int main(){
  int n,u,v,m;cin >> n >> u >> v >> m;
  vector<vector<int> > usa(n,vector<int>(n)),nek(n,vector<int>(n));
  for(auto &v :usa)for(auto &e : v)cin >> e;
  for(auto &v :nek)for(auto &e : v)cin >> e;
  vector<int> c(m);
  for(auto &e : c)cin >> e;

  int usagi = win(usa, c, u);
  int neko = win(nek, c, v);
  if(usagi < neko)cout << "USAGI" << endl;
  else if(usagi > neko)cout << "NEKO" << endl;
  else cout << "DRAW" << endl;

  return 0;
}




Measured memory_bytes: 13096
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    REP(i, N) {
        ll a, b; cin >> a >> b;

        ll ok = 1, ng = a * b;
        while(ng - ok > 1) {
            ll mid = (ok + ng) / 2;

            if ((long double)(a) * b / mid <= mid) {
                ng = mid;
            } else {
                ok = mid;
            }
        }
        
        if (ng == 1) {
            print(0);
            continue;
        }

        ll ans = 2 * (ng - 1);

        if (a < ng) ans--;
        if (b < ng) ans--;
        if ((a * b - 1) / (ng - 1) == (ng - 1)) ans--;
        print(ans);
    }
    
}


Measured memory_bytes: 3632
#include<stdio.h>
main(){
  int n,A[100],mini,cnt=0,x;
  int i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    mini = i;
    for(j=i;j<n;j++){
      if(A[j] < A[mini]){
        mini = j;
      }
    }
    if(mini!=i){
      x = A[i];
      A[i] = A[mini];
      A[mini] = x;
      cnt++;
    }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[n-1],cnt);
}

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

using namespace std;

int sum[11][1005];
char str[11][1005];
int f[15][1005];
int top;
bool ok;
int ans = 0x3f3f3f3f;
int p[15][1005];
int k;
int stk[10001];
bool gao(int x, int y) {
	for (int i = 1; i <= top; i ++)
		if (p[i][y] - p[i][x - 1] > k) return false;
	return true;
}

int main( ){
	int n, m;
	scanf("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= n; i ++) {
		scanf("%s", str[i] + 1);
		for (int j = 1; j <= m; j ++)
			sum[i][j] = sum[i - 1][j] + (str[i][j] - '0');
	}

	for (int S = 0; S < (1 << n); ++ S) {
		top = 0;
		for (int i = 1; i <= n; i ++)
			if ((S >> (i - 1)) & 1) stk[++ top] = i;
		for (int i = 1; i <= top; i ++) 
			for (int j = 1; j <= m; j ++)
				f[i][j] = sum[stk[i]][j] - sum[stk[i - 1]][j];
		
		for (int j = 1; j <= m; j ++)
			f[top + 1][j] = sum[n][j] - sum[stk[top]][j];
		++ top;
		ok = false;
		for (int i = 1; i <= top; i ++)
			for (int j = 1; j <= m; j ++) {
				if (f[i][j] > k) ok = true;
				p[i][j] = p[i][j - 1] + f[i][j];
			}

		if (ok) continue;
		int cnt = 0;
		for (int i = 1; i <= m; i ++) {
			int tmp = i;
			while (tmp <= m && gao(i, tmp)) ++ tmp;
			-- tmp;
			++ cnt;
			i = tmp;
		}
		ans = min(ans, top - 1 + cnt - 1);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
//ProblemA

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <memory>
#include <cstdio>
#include <cstring>

using namespace std;

//ProblemA

class Solve {
private:

	void solve() {
		string s;
		cin >> s;

		int sum = s[0] - '0' + (s.length() - 1) * 9;
		for (size_t i = 1; i < s.length(); i++) {
			if (s[i] != '9') {
				sum -= 1;
				break;
			}
		}

		cout << sum << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 256
a=[]
for i in range(10):
    n=int(input())
    a.append(n)
a.sort(reverse=True)
b=[]
for j in range(10):
    m=int(input())
    b.append(m)
b.sort(reverse=True)
W=0
K=0
for k in range(3):
    W+=a[k]
    K+=b[k]
print(W,K)


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


int main(){
	string s;
	bool ok=true;
	cin >> s;
	
	for(int i=1;i<s.size()-1;i++){
		if(s.size()==2) break;
		if(s[i-1]!=s[i+1]){
			s.erase(s.begin()+i);
			ok=!ok;
			i=0;
		}
	}
	
	cout << (ok?"Second":"First") << endl;
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <limits.h>
#define ll long long
#define xx first
#define yy second

using namespace std;

int main () {
	ll n;
	scanf ("%lld", &n);
	n--;
	printf ("%lld\n", (1 + n) * n / 2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
const int mod = 1e9+7;
 
int main(){
	int n,a,cnt=0;
	long long ans=1;
	vector<pair<int,int> > v;
	
	cin >> n;
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin >> a;
			v.push_back(pair<int,int>(a,i));
		}
	}
	sort(v.begin(),v.end());
	
	for(int i=0;i<v.size();i++){
		if(v[i].second==1){
			if(cnt < 0) ans = ans * -cnt % mod;
			cnt++;
		}
		else{
			if(cnt > 0) ans = ans * cnt % mod;
			cnt--;
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int K, Q;
ll d[5000];

int main() {
	cin >> K >> Q;
	REP(i, K) cin >> d[i];
	
	while (Q--) {
		ll n, x, m;
		cin >> n >> x >> m;
		
		ll ans = n - 1;
		vector<ll> cd(K);
		REP(i, K) cd[i] = d[i] % m;
		vector<ll> sum(K + 1), sumz(K + 1);
		sum[0] = sumz[0] = 0;
		REP(i, K) {
			sum[i + 1] = sum[i] + cd[i];
			sumz[i + 1] = sumz[i] + (cd[i] == 0);
		}
		ll s = x % m;
		ll c = (n - 1) / K;
		s += sum[K] * c;
		ans -= sumz[K] * c;
		
		c = (n - 1) % K;
		s += sum[c];
		ans -= sumz[c];
		
		ans -= s / m;
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
def main():
    N = int(input())
    l = list(map(int,input().split(" ")))
    dic = {}
    count = 0
    for i in l:
        try:
            dic[i] += 1
        except Exception:
            dic[i] = 1

    for j in dic.items():
        count += j[1] - j[0] if j[1] >= j[0] else j[1]
    print(count)


if __name__=="__main__":
    main()

Measured memory_bytes: 18160
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; ++i) cin>>a[i];
  unordered_map<int,int> mp3,mp4;
  long long res=0;
  for(int i=0; i<n; ++i){
    res+=mp3[i+a[i]];
    res+=mp4[i-a[i]];
    mp3[i-a[i]]++;
    mp4[i+a[i]]++;
  }
  cout<<res;
  return 0;
}
  

Measured memory_bytes: 34680
#include<stdio.h>
int main(){
int a,b,i,c=0;
while(1){
scanf("%d\n",&a);
if(a==0){
break;
}
else{
a=a/4;
for(i=0;i<a;i++){
scanf("%d\n",&b);
c=c+b;
}
printf("%d\n",c);
c=0;
}
}
return 0;
}



Measured memory_bytes: 2052
require 'matrix'

class Matrix
  # v2.3 では代入不可
  def []=(i, j, x)
    @rows[i][j]=x
  end
end

n, m = gets.split.map(&:to_i)
rows = STDIN.readlines.map{|line| line.chomp.chars.map{|c| (c == '#') ? 1 : 0}}
a = Matrix.rows(rows.shift(n))
b = Matrix.rows(rows)
if n == 1 && a[0, 0] == b[0, 0]
  puts "Yes"
  exit
end
(n - m).times do |i|
  (n - m).times do |j|
    if a.minor(i, m, j, m) == b
      puts "Yes"
      exit
    end
  end
end
puts "No"

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

using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i < (n); --i)
#define all(x) (x).begin(), (x).end()
#define gsort(x, n) sort((x), (x + n) greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1e9 + 7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,m,cnt=0;
    cin>>n>>m;

    rep(i,0,n) cnt += i;

    rep(i,0,m) cnt += i;

    cout<<cnt<<'\n';
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int M = sc.nextInt();
    	int K = sc.nextInt();
    	if(M == 0) {
    		if(K == 0) {
    			System.out.println("0 0");
    		} else {
    			System.out.println(-1);
    		}
    		return;
    	}
    	if(M == 1) {
    		if(K == 0) {
    			System.out.println("0 0 1 1");
    		} else if(K == 1) {
    			System.out.println(-1);
    		} else {
    			System.out.println(-1);
    		}
			return;
    	}
    	if(K >= Math.pow(2, M)) {
    		System.out.println(-1);
    		return;
    	}
    	StringBuilder ans = new StringBuilder();
    	ans.append(K);
    	for(int i=0; i<Math.pow(2, M); i++) {
    		if(i == K) continue;
    		ans.append(" ");
    		ans.append(i);
    	}
    	ans.append(" ");
		ans.append(K);
    	for(int i=(int)Math.pow(2, M)-1; i>=0; i--) {
    		if(i == K) continue;
    		ans.append(" ");
    		ans.append(i);
    	}
    	System.out.println(ans);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


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

int main(){
  string str;
  int i;
  int gap;

  gap='a'-'A';
  std::getline(std::cin, str);
  for(i=0; i<str.size(); i++){
    if(str[i]!=' ' && str[i]!='.') str[i]-=gap;
  }
  cout<<str<<endl;

  return 0;
}

Measured memory_bytes: 0
N = int(input())
W = list(map(int, input().split()))
T = 1
S1 = 0
S2 = 0
res = 9999
while(T < N):
  for i in range(N):
    if(i + 1 <= T):
      S1 += W[i]
    else:
      S2 += W[i]
  tmp = abs(S1 - S2)
  if(res > tmp):
    res = tmp
  S1 = 0
  S2 = 0
  T += 1
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

void func(ll N, vi &count){
  if(N<0) return;
  N++;
  ll n = 2LL;
  int counter = 0;
  while(N >= n/2){
    count.at(counter) += (N/n) * (n/2);
    count.at(counter) += max(0LL, (N%n) - (n/2));
    n *= 2LL;
    counter++;
  }
}

int main(){
  ll A, B;
  cin >> A >> B;
  vi count1(40, 0), count2(40, 0);
  func(A-1, count1); func(B, count2);
  ll ans = 0;
  ll n = 1LL;
  for(int i = 0; i < 40; i++){
    if((count2.at(i) - count1.at(i)) % 2 != 0) ans += n;
    n *= 2LL;
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin>> N;
  
  string color;
  int count=0;
  for(int i=0 ; i<N ; i++){
    cin >> color;
    if(color=="Y")
      count++; 
    if(count>0)
      break;
  }
 
  if(count==0)
    cout<< "Three"<< endl;
  else cout<<"Four"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <list>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
#include <ctime>
#include <assert.h>
using namespace std;

const unsigned long long MOD = (unsigned long long)(1e9 + 7);

#define FROM_0(i, n) for(int i = 0; i < (n); i++)
#define FROM_S(i, s, e) for(int i = (s); i < (e); i++)
#define ITER_BEGIN_END(iter, vec) for(auto iter = vec.begin(); iter != vec.end(); iter++)

int main()
{
    string s;
    cin >> s;
    if (s[s.length() - 1] == 's')
    {
        cout << s + "es" << endl;
    }
    else
    {
        cout << s + "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;

int r, c;
bool s[15][10005];

int cansell(vector<bool>& sw) {
  int sum = 0;
  rep(j, c) {
    int t = 0;
    rep(i, r) {
      if (s[i][j] && !sw[i]) t++;
      else if (!s[i][j] && sw[i]) t++;
    }
    sum += max(t, r - t);
  }
  return sum;
}

int main() {
  rep(i, 15) {
    rep(j, 10005) {
      s[i][j] = false;
    }
  }
  while (1) {
    cin >> r >> c;
    if (r == 0 && c == 0) break;
    rep(i, 15) {
      rep(j, 10005) {
        s[i][j] = false;
      }
    }
    int ans = 0;
    rep(i, r) {
      rep(j, c) {
        cin >> s[i][j];
      }
    }

    rep(k, (1 << r)) {
      vector<bool> sw(r);
      rep(i, r) sw[i] = false;
      int kc = k, idx = 0;
      while (kc != 0) {
        if (kc % 2 == 1) sw[idx] = true;
        kc /= 2;
        idx++;
      }
      ans = max(ans, cansell(sw));
    }

    cout << ans << endl;
  }


  
  return 0;
}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

template<class Abel> struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n=1, Abel SUM_UNITY=0){
		init(n, SUM_UNITY);
	}

	// n要素で初期化
	void init(int n=1, Abel SUM_UNITY=0){
		par.resize(n);
		rank.resize(n);
		diff_weight.resize(n);
		REP(i, n){
			par[i]=i;
			rank[i]=0;
			diff_weight[i]=SUM_UNITY;
		}
	}

	// 重みを更新しながらxの根を求める
	int find(int x){
		if(par[x]==x){
			return x;
		}
		else{
			int r=find(par[x]);
			diff_weight[x]+=diff_weight[par[x]];
			return par[x]=r;
		}
	}

	Abel weight(int x){
		find(x);
		return diff_weight[x];
	}

	// weight(y)-weight(x)=wとなるようにxとyが属する集合を併合
	bool unite(int x, int y, Abel w){
		w+=weight(x);
		w-=weight(y);
		x=find(x);
		y=find(y);
		if(x==y){
			return false;
		}
		if(rank[x]<rank[y]){
			par[x]=y;
			diff_weight[x]=-w;
		}
		else{
			par[y]=x;
			diff_weight[y]=w;
			if(rank[x]==rank[y]){
				++rank[x];
			}
		}
		return true;
	}

	// xとyが同じ集合に属するか判定
	bool is_same(int x, int y){
		return find(x)==find(y);
	}

	Abel diff(int x, int y){
		return weight(y)-weight(x);
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, l, r, d;
	cin>>n>>m;
	UnionFind<int> uf(n);
	REP(i, m){
		cin>>l>>r>>d;
		--l;
		--r;
		if(uf.is_same(l, r)){
			int diff=uf.diff(l, r);
			if(diff!=d){
				cout<<"No"<<'\n';
				return 0;
			}
		}
		else{
			uf.unite(l, r, d);
		}
	}
	cout<<"Yes"<<'\n';
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec[i];
        vec[i]--;
    }
    int now = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        cnt++;
        now = vec[now];
        if (now == 1) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"
#ifdef DEBUG
#define dump(v) cerr << "["#v << ":" << (v) << "]" << endl;
#else
#define dump(v)
#endif
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
const ll MOD = (1e9+7);
const ll INF = (1e9+123456789);
const ll INFL = (INF*INF);
inline ll addm(ll a, ll b, ll m = MOD) {return ((a+b)%m);}
inline ll subm(ll a, ll b, ll m = MOD) {return (((a-b)%m+m)%m);}
inline ll mulm(ll a, ll b, ll m = MOD) {return ((a*b)%m);}
ll powm(ll a, ll b, ll m = MOD) {ll ret=(!b)?1:powm(a, b/2, m);return (!b)?1:mulm(mulm(ret,ret,m),b%2?a:1,m);}
ll inv(ll x, ll m = MOD) {return powm(x,m-2,m);}

void solve()
{
    ll N; cin >> N;
    ll ans = 0;
    for (ll d = 1; d*d <= N; d++) {
        if (N % d == 0) {
            ll m = d-1;
            if (m > 0 && N / m == N % m)
                ans += m;
            m = N/d-1;
            if (m > 0 && N / m == N % m)
                ans += m;
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ABC_174_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            if (X >= 30) Console.WriteLine("Yes\n");
            else Console.WriteLine("No\n");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 17444
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(void){
	char mozi[100000];
	scanf("%s",mozi);
	for(int i=0;i<strlen(mozi);i+=2){
		printf("%c",mozi[i]);
	}
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split(" ");
	var num = parseInt( input[0] + input[1], 10);
        var result = "No";
	for(var i= 1; i <= 1000 ; i++){
         if(num === i *i){
            result = "Yes";
            break;
         }
        }
	//出力
	console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string str;
	cin >> str;
	if(str == "RRR")
		cout << 3 << "\n";
	if(str == "RRS")
		cout << 2 << "\n";
	if(str == "RSR")
		cout << 1 << "\n";
	if(str == "RSS")
		cout << 1 << "\n";
	if(str == "SRR")
		cout << 2 << "\n";
	if(str == "SRS")
		cout << 1 << "\n";
	if(str == "SSR")
		cout << 1 << "\n";
	if(str == "SSS")
		cout << 0 << "\n";
}

Measured memory_bytes: 3612
INF = 1000000000
read(T) = parse(T, readline())
reads(T) = map(x->parse(T,x),split(readline()))

function main()
    n = read(Int)
    v = reads(Int)
    dp = [INF for i in 1:n]
    dp[1] = 0
    for i in 1:n-1
        if (i + 1 <= n) dp[i+1] = min(dp[i+1], dp[i] + abs(v[i] - v[i+1])) end
        if (i + 2 <= n) dp[i+2] = min(dp[i+2], dp[i] + abs(v[i] - v[i+2])) end
    end
    println(dp[n])
end

main()


Measured memory_bytes: 168660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int a,b,c; cin >> a >> b >> c;
    if(a==b && a!=c || a==c && a!=b || b==c && b!=a){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int> > VVi;
typedef vector<vector<ll> > VVl;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 28;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

int n;
Vi vd;

int main()
{
	cin >> n;
	vd.resize(n);

	REP(i, n) cin >> vd[i];

	int ans = 0;
	REP(i, n - 1)
		for (int j = i + 1; j < n; ++j)
			ans += vd[i] * vd[j];
	cout << ans << endl;
}


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

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

  int cnt = 0;

  if (n > 9) cnt += 9;
  else {
    cout << n << endl;
    return 0;
  }

  if (n > 99) {
    if (n > 999) cnt += 900;
    else cnt += n - 99;
  }
  if (n > 9999) {
    if (n > 99999) cnt += 90000;
    else cnt += n - 9999;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
s = deque(list(input()))
q = int(input())
sento = 0
for i in range(q):
    line = list(input().split(" "))
    if line[0] == "1":
        sento += 1
    elif line[1] == "1":
        if sento % 2 == 0:
            s.appendleft(line[2])
        else:
            s.append(line[2])
    else:
        if sento % 2 == 0:
            s.append(line[2])
        else:
            s.appendleft(line[2])
if sento % 2 ==1:
    s.reverse()
for i in range(len(s)):
    print(s[i],end ="")
print()

Measured memory_bytes: 93032
////////////////////////////////////////////////
//  ********  *      *    *******    * *      //                 :
//  *         *      *   *       *   *   *    //     64 BITS     C     64 BITS
//  *****     *      *  *         *  *     *  //                 +
//  *         *      *  ***********  *     *  //:  20 - 6 - 2020 +   20 - 6 - 2020 :
//  *         *      *  *         *  *   *    //                 1
//  *         ********  *         *  * *      //     64 BITS     7     64 BITS
////////////////////////////////////////////////                 :
#define ll long long
#define ui unsigned int
#define ud unsigned double
#define mp make_pair
#define pii pair<int,int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pdi pair<double,int>
#define pb push_back
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
const double pi = acos(-1.0);
int main()
{
    int s;
    int e;
    scanf("%d%d",&s,&e);
    int r = s + e;
    int v = r - 1;
    int a = v / e;
    cout<<a<<"\n";
    return 0;
}

Measured memory_bytes: 3752
V, E = map(int,input().split())

L = []
visited = [0 for i in range(V)]
edges = [[] for i in range(V)]
flag = 0

def visit(x):
  if visited[x] == 1:
    flag = 1
  elif not visited[x]:
    visited[x] = 1
    for e in edges[x]:
      visit(e)
    visited[x] = 2
    L.insert(0,x)

for i in range(E):
  s, t = map(int,input().split())
  edges[s].append(t)

for i in range(V):
  if not visited[i]:
    visit(i)

for i in L:
  print(i)



Measured memory_bytes: 8828
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val as = readLine.split(" ").map(_.toInt)
  val (odds, evens) = as.zipWithIndex.partition(_._2 % 2 == 0)
  val first = odds.map(_._1).sum - evens.map(_._1).sum
  def rains(l: Int): Array[Int] = as.scanLeft(l)((z, a) => (a - z / 2) * 2).init
  println(rains(first).mkString(" "))
}

Measured memory_bytes: 64856