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

int main(){
    int x, y;
    cin >> x >> y;
    
    int z = max(x, y);
    int w = min(x, y); 
    x = z;
    y = w;
    while(y > 0){
        int i = 0;
        while(x - (y * i) >= 0){
            i++;
        }
        int a = x - (y * (i - 1));
        x = y;
        y = a;
    }
    cout << x << endl;
}


Measured memory_bytes: 3084
HL=list()
WL=list()
while True:
    H,W=map(int,input().split())
    HL.append(H)
    WL.append(W)
    if H==0 and W==0:
        break
for i in range(len(HL)):
    for j in range(HL[i]):
        if j%2==0:
            if int(WL[i])%2==0:
                for k in range(int(WL[i])//2):
                    print("#.",end="")
                print("")
            else:
                for k in range(int(WL[i]//2)):
                    print("#.",end="")
                print("#",end="")
                print("")
        else:
            if int(WL[i])%2==0:
                for k in range(int(WL[i])//2):
                    print(".#",end="")
                print("")
            else:
                for k in range(int(WL[i]//2)):
                    print(".#",end="")
                print(".",end="")
                print("")
        if j==HL[i]-1:
            print("")




Measured memory_bytes: 6444
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
string s;
signed main() {
	cin >> s;
	int n = s.size();
	if (n % 2 == 1)puts("No");
	else {
		int cnt = 0;
		rep(i, n / 2) {
			if (s[i] == 'p' && s[n - 1 - i] == 'q')cnt++;
			else if (s[i] == 'q' && s[n - 1 - i] == 'p')cnt++;
			else if (s[i] == 'd' && s[n - 1 - i] == 'b')cnt++;
			else if (s[i] == 'b' && s[n - 1 - i] == 'd')cnt++;
		}
		if (cnt == n / 2)puts("Yes");
		else puts("No");
	}
	ggr
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

struct Segtree{
    ll n;
    vector<ll> elm;
    Segtree(ll n): n(n), elm(2 * n, 0){}
    void set(ll x, ll val){
        x += n;
        elm[x] = val;
        x >>= 1;
        while(x){
            elm[x] = max(elm[2 * x], elm[2 * x + 1]);
            x >>= 1;
        }
    }
    ll get(ll x, ll y){
        x += n;
        y += n - 1;

        ll val = 0;

        while(x <= y){
            if(x & 1){
                val = max(val, elm[x++]);
            }
            if(!(y & 1)){
                val = max(val, elm[y--]);
            }
            x >>= 1;
            y >>= 1;
        }
        return val;
    }
};

signed main()
{
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(auto& x : h){
        cin >> x;
        --x;
    }
    vector<ll> a(n);
    for(auto& x : a)
        cin >> x;

    Segtree dp(n);
    for(ll i = 0; i < n; ++i){
        dp.set(h[i], dp.get(0, h[i]) + a[i]);
    }
    cout << dp.get(0, n) << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int a, p;
  cin >> a >> p;
  cout << (3*a+p)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
w[4444][4444];
n,k;i,j,x,y,c;ans;now;f;
g(u,v){return w[u+k][v+k]-w[u][v+k]-w[u+k][v]+w[u][v];}
main(){
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d%d %c",&x,&y,&c);
		if(c=='B')x+=k;
		x%=2*k,y%=2*k;
		w[x+1+k][y+1+k]++;
	}
	for(i=1;i<=4*k;i++)for(j=1;j<=4*k;j++)w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
	for(i=0;i<k;i++)for(j=0;j<k;j++){
		now=g(i+k,j+2*k)+g(i+2*k,j+k)+g(i,j+k)+g(i+k,j);
		if(ans<now)ans=now;
		now=g(i+2*k,j+2*k)+g(i,j+2*k)+g(i+k,j+k)+g(i+2*k,j)+g(i,j);
		if(ans<now)ans=now;
	}
	printf("%d\n",ans);
}

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

int n;
int d[55];

int main(){
  cin >> n;
  rep(i,n) cin >> d[i];
  int ans = 0;
  for (int i = 0; i < (n); ++i){
    for (int j = i+1; j < (n); ++j){
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
"use strict";

function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)>>1]<e?a=c:b=c;return d[a]<e?b:a};

function Main(arg) {
    const N = arg.split("\n")[0]-0;
    const L = arg.split("\n")[1].split(" ").map(v=>v-0);
 
    let ans = 0;

    let a, b, c;
    L.sort((a,b)=>a-b);
  
    for (let i=0; i<N - 2; i++){
        a = L[i];
      
        for (let j = i+1; j < N - 1; j++){
            b = L[j];
            let tmp = lower_bound(L, j + 1, N, a + b) - 1;
            ans += (tmp - j);
        }
    }


    console.log(ans);
}

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


Measured memory_bytes: 7748
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,q;
  cin>>n>>q;
  vector<tuple<int, int, int>> stx(n);
  for(int i=0;i<n;i++){
    cin >> get<1>(stx[i]) >> get<2>(stx[i]) >> get<0>(stx[i]);
  }
  sort(ALL(stx));
  set<pair<int,int>> d;
  for(int i=0;i<q;i++) {
    int x;cin>>x;
    d.emplace(x,i);
  }
  vector<ll> ans(q,-1);
  for(int i=0;i<n;i++){
    auto first=d.lower_bound(make_pair(get<1>(stx[i])-get<0>(stx[i]),0));
    auto last=d.upper_bound(make_pair(get<2>(stx[i])-get<0>(stx[i])-1,q));

    for(auto it=first;it!=last;it++){
      ans[(*it).second]=get<0>(stx[i]);
    }
    d.erase(first,last);
  }
  for(int i=0;i<q;i++)cout<<ans[i]<<"\n";
}


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

int main()
{
    int N, count = 0, min_number = 1e9;
    cin >> N;
    vector<int> P(N), Q(N);

    for (int i = 0; i < N; i++)
    {
        cin >> P.at(i);
    }

    for (int i = 0; i < N; i++)
    {
        if (P.at(i) <= min_number)
        {
            min_number = P.at(i);
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1792
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


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

    S = iss()
    ret = 0
    tmp = 0
    for s in S:
        if s == 'R':
            tmp += 1
        else:
            tmp = 0
        ret = max(tmp, ret)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9816
from sys import stdin
import numpy as np
import copy


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    H, W, K = list(map(int, _in[0].split(' ')))  # type:list(int)
    c_arr = []
    for i in range(H):
        _ = list(_in[i + 1])  # type:list(str)
        c_arr.append(_)
    c_arr = np.array(c_arr)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    c_arr[c_arr == '#'] = 1
    c_arr[c_arr == '.'] = 0
    c_arr = c_arr.astype(np.int8)

    ans = 0

    # 列方向
    for bitw in range(1 << W):
        for bith in range(1 << H):
            board = copy.deepcopy(c_arr)
            # bit = 1: selected
            for i in range(W):
                if bitw & (1 << i):
                    board[:, i] *= 0
            for i in range(H):
                if bith & (1 << i):
                    board[i, :] *= 0
            black = board.sum()
            if black == K:
                ans += 1
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27388
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}













bool compare(pi a,pi b){
     if(a.fi-a.se>b.fi-b.se)return  true;
     else if(a.fi-a.se==b.fi-b.se&&a.se<b.se)return true;
     return false;
}






int main()
{
     int h,n;
     cin>>h>>n;
     ll a[n],b[n];
     for(int i=0;i<n;i++)cin>>a[i]>>b[i];
     ll dp[h+1];
     for(int i=0;i<=h;i++)dp[i]=1LL<<60;
     dp[0]=0;
     for(int i=1;i<=h;i++){
          for(int j=0;j<n;j++){
               if(i<a[j]){
                    dp[i]=min(dp[i],b[j]);
               }
               else dp[i]=min(dp[i],b[j]+dp[i-a[j]]);
          }
     }
     cout<<dp[h];
}







 
 

















Measured memory_bytes: 384
#include<stdio.h>

int main (void){
    char str[21] = "";
    int i = 0;

    scanf("%s",str);

    while(1){

        if(str[i] == NULL)
            break;
            i++;
    }

    while(1){

        i--;
        printf("%c",str[i]);
        if(i == 0){
            printf("\n");
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 524
import sys
input = sys.stdin.readline

class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]


n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
xy2 = [[x[0],x[1],i] for (i,x) in enumerate(xy)]
xy2.sort()
u = Unionfind(n)

l = []
for x,y,ind in xy2:
    M = y
    le = ind
    while l and xy[l[-1]][1] < y:
        v = l.pop()
        if M > xy[v][1]:
            M = xy[v][1]
            le = v
        u.union(ind,v)
    l.append(le)
for i in range(n):
    print(u.size(i))



Measured memory_bytes: 74272
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 1000*1000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x;
    cin>>x;
    int n; cin>>n;
   if(n == 0){
       cout << x;
   }
   else{
       set<int> s;
       for(int i =0;i<n;++i){
           int val; cin>>val;
           s.insert(val);
       }
       int ans = -1,mn = 10000;
       for(int i = 0;i<=200;++i){
           if(!s.count(i)){
               if(ans == -1){
                   ans = i;
                   mn = abs(i - x);
               }
               else {
                   if(mn > abs(i-x)){
                       mn = abs(i-x);
                       ans = i;
                   }
                   else if(mn == abs(i-x)){
                       ans = min(ans,i);
                   }
               }
           }
       }
       cout << ans ;
   }
  
   
    return 0;
}
    

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
#define pi (acos(-1))
///#define for(i,a,b) for(i=(a);i<(b);++i)
///freopen("input.txt","r",stdin);
///   freopen("output.txt","w",stdout);
int n,m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<"\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
	public class QuestionA
	{
		public static void Main(string[] args)
		{
			// 整数配列の入力
			var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			var X = inputLongArray[0];
			var Y = inputLongArray[1];

			long next = X;
			long count = 0;
			while(next <= Y) {
				++count;
				next *= 2;
			}

			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 27904
/*
T(i, j) s[:i) t[:j) 的最长公共子序列长度
T(0, 0) = 0
T(i, j) = max{T(i-1, j), T(i, j-1), T(i-1, j-1) + s[i-1] == t[j-1] ? 1 : 0}
pre(i, j) 记录状态
*/

package main

import "fmt"

type Node struct {
  i, j int
}

const N = 3005
var T [N][N]int
var pre [N][N]Node

func umax(current *int, val int, pre_i, pre_j int, i, j int) {
  if val > *current {
    *current = val
    pre[i][j] = Node{pre_i, pre_j}
  }
}

func printResult(i, j int, s string) {
  result := make([]byte, 0)
  for !(i == 0 && j == 0) {
    pre_i, pre_j := pre[i][j].i, pre[i][j].j
    if T[i][j] == T[pre_i][pre_j] + 1 {
      result = append(result, s[i-1])
    }
    i, j = pre_i, pre_j
  }
  n := len(result)
  for i := n-1; i >= 0; i-- {
    fmt.Printf("%c", result[i])
  }
  fmt.Println()
}

func main() {
  var s, t string
  fmt.Scanf("%s", &s)
  fmt.Scanf("%s", &t)
  n, m := len(s), len(t)
  for i := 1; i <= n; i++ {
    for j := 1; j <= m; j++ {
      T[i][j] = -1
      v := &T[i][j]
      umax(v, T[i-1][j], i-1, j, i, j)
      umax(v, T[i][j-1], i, j-1, i, j)
      delta := 0
      if s[i-1] == t[j-1] {
        delta = 1
      }
      umax(v, T[i-1][j-1] + delta, i-1, j-1, i, j)
    }
  }
  
  printResult(n, m, s)
}

Measured memory_bytes: 213224
inp = int(input())
if inp>=400 and inp<=599:
  ans = 8
elif inp>=600 and inp<=799:
  ans = 7
elif inp>=800 and inp<=999:
  ans = 6
elif inp>=1000 and inp<=1199:
  ans = 5
elif inp>=1200 and inp<=1399:
  ans = 4
elif inp>=1400 and inp<=1599:
  ans = 3
elif inp>=1600 and inp<=1799:
  ans = 2
elif inp>=1800 and inp<=1999:
  ans = 1
print(ans)

Measured memory_bytes: 9064
#include<iostream>
#include<cstdio>
#include<map>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
const int maxn = 2e5+7;
int main()
{
    string s;
    string d = "dream",e = "erase";
    cin >> s;
    int i=0,j;
    bool p = true;
    while( i < s.length())
    {
        if(i+6<=s.length()&&s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r')
        {
            i+=6;
            //cout << "1" <<endl;
        }
        else if(i+5<=s.length()&&s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e')
        {
            i+=5;
           // cout << "2" <<endl;
        }
        else if(i+7<=s.length()&&s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'&&s[i+6]=='r'&&s[i+7]!='a')
        {
            i+=7;
           // cout << "3" <<endl;
        }
        else if(i+5<=s.length()&&s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m')
        {
            i+=5;
           // cout << "4" <<endl;
        }
        else
        {
           // cout << "5" <<endl;
            p = false;
            break;
        }
    }
    if(p)cout << "YES" <<endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class B0or1Swap
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var pList = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList();

            int wrongCount = 0;
            for (int i = 0; i < n; i++)
            {
                if (pList[i] != i + 1)
                {
                    wrongCount++;
                }

                if (2 < wrongCount)
                {
                    break;
                }
            }

            Console.WriteLine(2 < wrongCount ? "NO" : "YES");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11220
import java.io.PrintWriter
import kotlin.math.abs

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (a, v) = readLongList()
    val (b, w) = readLongList()
    val t = readLong()

    if (w >= v) {
        println("NO")
    } else {
        val d = abs(a - b)
        if (d <= t * (v - w)) {
            println("YES")
        } else {
            println("NO")
        }
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36360
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b = list(map(int, input().split()))
# s = input()

N = int(input())
i = 1
ans = N 
while i * i <= N:
    if N % i == 0:
        ans = min(ans, (i-1) + ((N//i)-1))
    i += 1

print(ans)


Measured memory_bytes: 40684
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s; cin >> s;
	int dot = s.find('.'), op = s.find('(');
	
	int it = (op == s.npos ? s.size() : op) - dot - 1;
	string t = s;
	if(op != s.npos) t = t.substr(0, op);
	t.erase(t.begin() + dot);
	
	ll n = atoll(t.c_str()), m = 1;
	rep(i, it) m *= 10;
	
	//dbg(n, m);
	
	if(op != s.npos){
		ll p = atoll(s.substr(op + 1, s.size() - op - 2).c_str());
		ll q = atoll(string(s.size() - op - 2, '9').c_str());
		rep(i, it) q *= 10;
		//dbg(p, q);
		
		ll y = q * m, x = p * m + n * q;
		n = x; m = y;
	}
	ll g = __gcd(n, m); n /= g; m /= g;
	cout << n << "/" << m << endl;
	return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<(n); i++)
#define int long long
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
vector<int>uni(100010,-1);
int root(int a){
    if(uni[a]<0)return a;
    return uni[a]=root(uni[a]);
}
bool Connect(int a,int b){
    a=root(a);b=root(b);
    if(a==b)return false;
    if(uni[a]<uni[b])swap(a,b);
    uni[a]+=uni[b];
    uni[b]=a;
    return true;
}

signed main(void){
    int n,m;cin>>n>>m;
    vector<int>L[m];
    int k,l;
    rep(i,n){
        cin>>k;
        rep(j,k){
            cin>>l;l--;
            L[l].push_back(i);
        }
    }
    rep(i,m){
        rep(j,L[i].size()){
            if(j==L[i].size()-1)break;
            Connect(L[i][j],L[i][j+1]);
        }
    }
    rep(i,n){
        if(uni[i]<0){
            if(uni[i]!=-n){cout<<"NO"<<endl;break;}
            else {cout<<"YES"<<endl;break;}
        }
    }
}



Measured memory_bytes: 5504
S = input()
N = len(S)

ans1 = 0
ans2 = 0
for i in range(N):
    if i % 2 == 0:
        if S[i] == "0":
            ans1 += 1
        else:
            ans2 += 1
    else:
        if S[i] == "1":
            ans1 += 1
        else:
            ans2 += 1

print(min(ans1, ans2))

Measured memory_bytes: 3188
M, D = map(int, input().split())
ans = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        d1 = d % 10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int h,w,k;
string s[10],s1[10];
int n;
bool check(int y){


    for(int i=0;i<h;i++) s1[i]=s[i];
    int cnt=0;
    for(int i=0;i<h;i++){
        if((1<<i)&y){
            for(int k=0;k<(int)s1[i].length();k++){
                cnt+=(s1[i][k]=='#');
                s1[i][k]='.';
            }
        }
    }

    for(int j=0,i=h;i<n;i++,j++){
        if((1<<i)&y){
            for(int k=0;k<h;k++){
                cnt+=(s1[k][j]=='#');
                s1[k][j]='.';
            }
        }
    }
    return (cnt==k);
}

int main()
{
    cin>>h>>w>>k;
    for(int i=0;i<h;i++) cin>>s[i];
    int c=0;
    for(int i=0;i<h;i++){
        for(auto x:s[i]){
            c+=(x=='#');
        }
    }
    k=c-k;
    n=h+w;
    int cnt=0;
    for(int i=0;i<=(1<<n)-1;i++){
        if(check(i)) cnt++;
       // cout<<cnt<<' '<<i<<endl;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[2004],ans;
inline int abs(int x) {
	return x>0?x:-x;
}
int main() {
	scanf("%d",&n);
	int m=n;
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<m-1;++i) {
		for (int j=i+2;j<=m;++j) {
			int x=a[i],y=a[j];
			int pos=i+1;
			while (a[pos]+x<=y) ++pos;
			ans+=j-pos;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint n; cin >> n;
  int k = __lg(n + 1);
  n -= (1LL << k) - 1;
  V<> res;
  for (int i = 0; i < k; i++) {
    if (n & 1) res.push_back(2 * i);
    n >>= 1;
  }
  for (int i = k; i; i--) res.push_back(2 * i - 1);
  for (int i = 99; i >= 0; i--) res.push_back(i);
  int m = res.size();
  cout << m << '\n';
  for (int i = 0; i < m; i++) cout << res[i] + 1 << (i != m - 1 ? ' ' : '\n');
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(void){
    int M[N][N];
    int n, u, k, v;
    scanf("%d", &n);

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

    for(int i=0; i<n; i++){
        scanf("%d %d", &u, &k);
        u--;
        for(int j=0; j<k; j++){
            scanf("%d", &v);
            v--;
            M[u][v]=1;
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j){
                printf(" ");
            }
            printf("%d", M[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2140
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N + 1];
		int[] B = new int[N];

		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}

		long result = 0;

		for (int i = N - 1; i >= 0; i--) {
			if (A[i + 1] >= B[i]) {
				result += B[i];
				A[i + 1] -= B[i];
				B[i] = 0;
			} else {
				result += A[i + 1];
				B[i] -= A[i + 1];
				A[i + 1] = 0;
				if (A[i] >= B[i]) {
					result += B[i];
					A[i] -= B[i];
					B[i] = 0;
				} else {
					result += A[i];
					B[i] -= A[i];
					A[i] = 0;
				}
			}
		}

		// for (int i = N; i > 0; i--) {
		// if (A[i] >= B[i - 1]) {
		// result += B[i - 1];
		// A[i] -= B[i - 1];
		// B[i - 1] = 0;
		// } else {
		// result += A[i];
		// A[i] = 0;
		// B[i - 1] -= A[i];
		// if (A[i - 1] >= B[i - 1]) {
		// result += B[i - 1];
		// A[i - 1] -= B[i - 1];
		// B[i - 1] = 0;
		// } else {
		// result += A[i - 1];
		// A[i - 1] = 0;
		// B[i - 1] -= A[i - 1];
		// }
		// }
		// }

		System.out.println(result);
	}

}

Measured memory_bytes: 65116
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int ans = 0;
    int n, k;
    cin >> n >> k;
    while (n) {
        ans++;
        n /= k;
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, ans=0;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        while(a%2==0){
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

const int N = 2e5 + 5;

template <typename T>
void vmax(T& a, T b) {
	(a < b) && (a = b, 0);
}

int n;
char s[N];
int f[N][2];

int main() {
	scanf("%s", s + 1);
	f[0][0] = 0, f[0][1] = -1e9;
	n = strlen(s + 1);
	for (int i = 1; i <= n; i++) {
		f[i][0] = f[i][1] = -1e9;
		vmax(f[i][0], f[i - 1][1] + 1);
		if (s[i] != s[i - 1])
			vmax(f[i][0], f[i - 1][0] + 1);
		if (i > 1) {
			vmax(f[i][1], f[i - 2][0] + 1);
			if (i > 3 && (s[i] != s[i - 2] || s[i - 1] != s[i - 3])) {
				vmax(f[i][1], f[i - 2][1] + 1);
			}
		}
	}
	printf("%d\n", max(f[n][0], f[n][1]));
	return 0;
}


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

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

  vector<int> divs = {1};

  for(int i = 2; i <= min(A, B); i++){
    if(A % i != 0 || B % i != 0){
      continue;
    }
    divs.push_back(i);
  }
  cout << divs[divs.size() - K] << endl;

  return 0;
}

Measured memory_bytes: 256
import itertools
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
import bisect
import sys
sys.setrecursionlimit(10**9)

def main():
    X, Y = map(int,input().split())
    p = 10**9+7

    i = (2*X-Y)/3
    j = (2*Y-X)/3

    if i < 0 or j < 0 or not(i.is_integer() and j.is_integer()):
        print(0)
        exit()

    i = int(i)
    j = int(j)

    def comb(n, r, mod):
        r = min(r, n-r)
        res = 1
        for i in range(r):
            res = res * (n - i) * pow(i+1, mod-2, mod) % mod
        return res

    print(comb(i+j,i,p))


if __name__ == "__main__":
  main()

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int a, b;
    cin >> a >> b;

    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int n;
    vector<int> a;
    vector<int> b;
    vector<int> c;

    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        b.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long count = 0;
    for (int i = 0; i < n; i++) {
        int a_num = distance(a.begin(), lower_bound(a.begin(), a.end(), b[i]));
        int c_num = distance(upper_bound(c.begin(), c.end(), b[i]), c.end());
        count += (long)a_num * (long)c_num;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 1784
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <vector>

#define MAX_N (100000L)
#define NUM_MOD (1000000007L)

using namespace std;

long dps[MAX_N][2];

void init(long N) {
  for (long i = 0; i < N; i++) {
    dps[i][0] = -1;
    dps[i][1] = -1;
  }
}

long calc_num_ways(long i, long b, const vector<vector<long>> &adj_lists) {
  if (adj_lists[i].size() == 0) {
    if (b) {
      return 1;
    } else {
      return 2;
    }
  }
  if (dps[i][b] < 0) {
    long dp0 = 1, dp1 = 1;
    for (long j : adj_lists[i]) {
      dp0 = (dp0 * calc_num_ways(j, 0, adj_lists)) % NUM_MOD;
      dp1 = (dp1 * calc_num_ways(j, 0, adj_lists)) % NUM_MOD;
    }
    dps[i][0] = dp0;
    dps[i][1] = dp1;
    dp0 = 1;
    for (long j : adj_lists[i]) {
      dp0 = (dp0 * calc_num_ways(j, 1, adj_lists)) % NUM_MOD;
    }
    dps[i][0] = (dp0 + dps[i][0]) % NUM_MOD;
  }
  return dps[i][b];
}

int main() {
  // read inputs
  long N, xs[MAX_N], ys[MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N - 1; i++) {
    scanf("%ld %ld", &xs[i], &ys[i]);
    xs[i]--;  // NOTE : modified input
    ys[i]--;  // NOTE : modified input
  }

  // create graph
  vector<vector<long>> adj_list0s(N, vector<long>());
  for (int i = 0; i < N - 1; i++) {
    const int x = xs[i], y = ys[i];
    adj_list0s[x].push_back(y);
    adj_list0s[y].push_back(x);
  }

  // create tree with root
  queue<long> que;
  vector<long> us(N, 0);
  vector<vector<long>> adj_lists(N, vector<long>());
  us[0] = 1;
  que.push(0);
  while (!que.empty()) {
    const long i = que.front();
    que.pop();
    for (long j : adj_list0s[i]) {
      if (!us[j]) {
        us[j] = 1;
        adj_lists[i].push_back(j);
        que.push(j);
      }
    }
  }

  // solve dp
  init(N);
//   for (long i = 0; i < N; i++) {
//     printf("i = %ld, dps[i][0] = %ld, dps[i][1] = %ld\n", i,
//            calc_num_ways(i, 0, adj_lists), calc_num_ways(i, 1, adj_lists));
//   }
  printf("%ld\n", calc_num_ways(0, 0, adj_lists));
}

Measured memory_bytes: 23424
#include<bits/stdc++.h>
#define N 100005
#define LL long long
#define INF (1LL<<60)
using namespace std;
vector<int> G[N];
vector<int> E[N];
int n,rt,sz[N];
LL d[N],ans,now=INF;
void dfs(int t,int fa)
{
	int i; sz[t]=1;
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa)
			dfs(G[t][i],t),sz[t]+=sz[G[t][i]];
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa&&sz[G[t][i]]>n/2) break;
	if(i>=G[t].size()&&n-sz[t]<=n/2) rt=t;
}
void DFS(int t,int fa)
{
	int i; sz[t]=1;
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa)
			d[G[t][i]]=d[t]+E[t][i],DFS(G[t][i],t),sz[t]+=sz[G[t][i]];
}
int main()
{
	int i,x,y,z;
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		scanf("%d %d %d",&x,&y,&z);
		G[x].push_back(y),G[y].push_back(x);
		E[x].push_back(z),E[y].push_back(z);
	  }
	dfs(1,0);
	DFS(rt,0);
	for(i=1;i<=n;i++) ans+=2*d[i];
	for(i=0;i<G[rt].size();i++)
		if(sz[G[rt][i]]==n/2&&n%2==0){ now=d[G[rt][i]]; break;}
		else now=min(now,d[G[rt][i]]);
	ans-=now;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 19072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = a + b + c;
    if (ans >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
square = [list(input()) for i in range(h)]
def bfs(si, sj):
    que = deque()
    que.append((si, sj))
    d = [[float('inf')] * w for i in range(h)]
    d[si][sj] = 0
    move = [(-1, 0), (0, 1), (1, 0), (0, -1)]
    while que:
        i, j = que.popleft()
        for mi, mj in move:
            ni, nj = i + mi, j + mj
            if 0 <= ni < h and 0 <= nj < w and square[ni][nj] != '#' and d[ni][nj] == float('inf'):
                que.append((ni, nj))
                d[ni][nj] = d[i][j] + 1
    return d[i][j]

max_num = 0
for i in range(h):
    for j in range(w):
        if square[i][j] == '.':
            max_ij = bfs(i, j)
            max_num = max(max_num, max_ij)
print(max_num)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> acc(n + 1, vector<int>(20));
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for(int j = 0; j < 20; j++) {
      acc[i + 1][j] = acc[i][j] + (a & 1);
      a >>= 1;
    }
  }
  int e = 1;
  ll o = 0;
  for(int b = 0; b < n; b++) {
    int d[20], m;
    for(; e < n + 1; e++) {
      m = 0;
      for(int i = 0; i < 20; i++) {
        d[i] = acc[e][i] - acc[b][i];
        m = max(m, d[i]);
      }
      if(m > 1) break;
    }
    o += e - b - 1;
  }
  cout << o << '\n';
}

Measured memory_bytes: 23680
#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(a) (a).begin(),(a).end()
#define SORT(V) sort((V).begin(),(V).end())

#define ll long long

int main(){
  ll N; ll K;
  cin>>N>>K;
  vector<ll> person(N,0);
  for(ll i=0; i<K; i++) {
    ll d;
    cin>>d;
    for(ll j=0; j<d;j++) {
      ll a;
      cin>>a;
      person[a-1]++;
    }
  }
  ll result = 0;
  for (int b = 0; b < person.size(); b++){
    if(person[b] == 0) {
      result++;
    }
  }
  cout << result<<endl;
  return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

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



int main(){
	
	vector<int> a;
	rep(i,5){
		int b;
		cin>>b;
		a.push_back(b);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	rep(i,5){
		if(i!=0)printf(" ");
		printf("%d",a[i]);
	}puts("");
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
bool check(long n) 
{ 
    // Corner cases 
    if (n <= 0)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (long i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
long get_factors(long a,long b)
{
    long n = __gcd(a, b); 
  
    // Count divisors of n. 
    long result = 0; 
    for (long i=1; i<=sqrt(n); i++) 
    { 
        // if 'i' is factor of n 
        if (n%i==0) 
        { 
            // check if divisors are equal 
            if (n/i == i&&check(i)) 
                result += 1; 
            else {
                if(check(i))
                    result += 1; 
                if(check(n/i))
                    result+=1;
            }
            
        } 
    } 
    return result; 
}
int main()
{
    long a,b;
    cin>>a>>b;
    long count;
    count=get_factors(min(a,b),max(a,b));
    cout<<count<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>

using namespace std;

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int ans = 0;
  X -= Z;
  while (X >= Z + Y) {
    X -= Z + Y;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin>>s;
    int ans=0;
    int ret=0;
    int n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')ret++;
        else {
            ans=max(ret,ans);
            ret=0;
        }
    }

    ans=max(ans,ret);
 
    cout<<ans<<endl;
}

Measured memory_bytes: 256
D = 1_000_000_000
H, W, N = gets.split.map(&:to_i)

h = Hash.new(0)
N.times do
  a, b = gets.split.map(&:to_i)
  ((a - 1)..(a + 1)).each do |i|
    ((b - 1)..(b + 1)).each do |j|
      h[D * i + j] += 1 
    end
  end
end

c = Array.new(10, 0)
h.each do |k, v|
  i = k / D 
  j = k % D
  next if i <= 1 || i >= H || j <= 1 || j >= W 
  c[v] += 1 
end

c[0] = (H - 2) * (W - 2) - c.inject(:+)
puts c

Measured memory_bytes: 60028
K = int(input())
A = [int(_) for _ in input().split()]
l = r = 2
for a in A[::-1]:
    l = a * ((l - 1) // a) + a
    r = a * (r // a + 1) - 1
for x in [l, r]:
    for a in A:
        x = a * (x // a)
    if x != 2:
        print(-1)
        exit()
print(l, r)


Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		boolean[] submitted=new boolean[31];
		for(int i=0; i<28; i++) {
			submitted[sc.nextInt()]=true;
		}
		for(int i=1; i<=30; i++) {
			if(!submitted[i]) {
				pl(i);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


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

int main(void)
{
	int x, y;
	
	while (1){
		cin >> x >> y;
		
		if (x == 0 && y == 0){
			break;
		}
		if (x > y){
			cout << y << " " << x;
		}
		else {
			cout << x << " " << y;
		}
		cout << endl;
	}
	return (0);
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;

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

            string ans = "";

            if ((a * b) % 2 == 0){
                ans = "Even";
            }else{
                ans = "Odd";
            }
            Console.WriteLine(ans);
    //        Console.ReadLine();

        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main()
{

	int n;
	int a, b, c, d;
	int v[4][3][10] = { 0 };
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> d;
		v[a - 1][b - 1][c - 1] += d;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << v[i][j][k];
			}
			cout << endl;
		}
		if (i != 3) cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,t,cub,rec,per;
   while(scanf("%d%d",&n,&t)!=EOF)
   {
     if(n==t)
     {
         cout<<"a == b"<<endl;
     }
     else if(n>t)
     {
         cout<<"a > b"<<endl;
     }
     else if(n<t)
     {
         cout<<"a < b"<<endl;
     }
   }
}




Measured memory_bytes: 3148
//Author- VMAX


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */      
       int main()
       
       {
           
           
           fast
           
           
           string a,b;
           cin>>a>>b;
           
           ll i,c=0;
           
           f(i,a.size())
           {
               if(a[i]!=b[i])
               {
                   c++;
               }
           }
           
           
           o(c)
           
           
           
           
           
           
           
           
           
       
 
          re
}

Measured memory_bytes: 3776
import numpy as np
import copy

N = int(input())  
a = np.array(input().split(), dtype=np.int32)
M = np.arange(N) + 1
    
for i in np.arange(N // 2)[::-1]:
    A = a[i::i+1]
    if np.sum(A) % 2  == 0:
        a[i] = 0
    else:
        a[i] = 1
        
ans = np.where(a == 1)[0] + 1

print(np.size(ans))

if np.size(ans) > 0:
    print(*ans.astype(np.int32))

Measured memory_bytes: 22768