akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
  int n,dpt=100000;
  cin >> n;
  for(int i=0;i<n;i++){
    dpt /= 20;
    dpt *= 21;
    if(dpt - (dpt/1000)*1000 > 0)dpt = (dpt/1000+1)*1000;
     else dpt = (dpt/1000)*1000;
  }
  cout << dpt << endl;
  
  return 0;
}

Measured memory_bytes: 0
#![allow(unused)]

use std::cmp::{min, max};
use std::io::Write;

macro_rules! dbg {
    ($($a:expr),*) => {
        writeln!(
            std::io::stderr(),
            concat!($(stringify!($a), " = {:?}, "),*),
            $($a),*);
    }
}

//
// Based on EbTech's Scanner https://stackoverflow.com/q/56449027
//
struct Scanner<'a, R: std::io::BufRead> {
    reader: R,
    buf: String,
    iter: std::str::SplitWhitespace<'a>,
}

impl<'a, R: std::io::BufRead> Scanner<'a, R> {
    fn new(reader: R) -> Scanner<'a, R> {
        Scanner { reader: reader, buf: String::new(), iter: "".split_whitespace() }
    }

    fn get_str(&mut self) -> &str {
        if let Some(t) = self.iter.next() {
            return t;
        }
        self.buf.clear();
        self.reader.read_line(&mut self.buf).expect("I/O error");
        self.iter = unsafe { std::mem::transmute(self.buf.split_whitespace()) };
        self.get_str()
    }

    fn get<T: std::str::FromStr>(&mut self) -> T {
        self.get_str().parse().ok().expect("Parse error")
    }
}

fn main() {
    let stdin = std::io::stdin();
    solve(Scanner::new(stdin.lock()));
}

fn solve<R: std::io::BufRead>(mut sc: Scanner<R>) {
    let n: usize = sc.get();
    let k: usize = sc.get();
    let xs: Vec<usize> = (0..n).map(|_| sc.get()).collect();

    // dp[i] = 石が i 個のとき勝つのがその時点の先手なら true，後手なら false
    let mut dp = vec![false; k + 1];
    for i in 1..(k + 1) {
        dp[i] = xs.iter().filter(|&&x| x <= i).any(|&x| !dp[i - x]);
    }

    println!("{}", if dp[k] { "First" } else { "Second" });
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull k, x;
  cin >> k >> x;

  const long start = (long)((long)x - (long)k) + 1;
  const long end = (long)((long)x + (long)k) - 1;
  for (long i=start; i <= (long)end; i++) {
    cout << i << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

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

	ll H,W;
	cin >> H >> W;
	string S[H];
	FOR(i,0,H){
		cin >> S[i];
	}
	ll ans = 0;

	ll yoko[H][W]={};
	ll tate[H][W]={};

	FOR(i,0,H){
		FOR(j,0,W){
			if(j==0){
				if(S[i][j]=='.')yoko[i][j]=1;
			}else{
				if(S[i][j]=='.')yoko[i][j]=1+yoko[i][j-1];
			}
		}
		FORR(j,0,W-1){
			if(yoko[i][j]){
				yoko[i][j] = max(yoko[i][j],yoko[i][j+1]);
			}
		}
	}


	FOR(j,0,W){
		FOR(i,0,H){
			if(i==0){
				if(S[i][j]=='.')tate[i][j]=1;
			}else{
				if(S[i][j]=='.')tate[i][j]=1+tate[i-1][j];
			}
		}
		FORR(i,0,H-1){
			if(tate[i][j]){
				tate[i][j] = max(tate[i][j],tate[i+1][j]);
			}
		}
	}

	FOR(i,0,H){
		FOR(j,0,W){
			ans = max(ans,yoko[i][j]+tate[i][j]-(S[i][j]=='.'));
		}
	}


	cout << ans << endl;
}


Measured memory_bytes: 67072
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;

 int main() {
        ff;
       int n;
       cin>>n;
       int a[n],b[1000005],cnt[1000005],c[1000005]={0};
       for(int i=0;i<n;i++){
           cin>>a[i];
           cnt[a[i]]++;
           b[a[i]]=1;
       }
       for(int i=0;i<1000005;i++){
           if(b[i]==1){
           for(int j=i+i;j<=1000005;j+=i){
               c[j]++;
           }
           }
       }
      ll ans=0;
      for(int i=0;i<n;i++){
          if(cnt[a[i]]==1 && c[a[i]]==0)ans++;
      }
		cout<<ans<<endl;
    return 0;
}

            
		
        
           
  

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

int n;
vector<int> v, ans;

int main()
{
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}

	int k, mode = 0;

	k = n;

	for (int i = 0; i < n; ++i) {
		cout << v[k-1];
		
		if (i == n - 1) {
			cout << endl;
			break;
		}
		else cout << " ";

		if (mode == 0 && k > 2) k -= 2;
		else if (mode == 0 && k == 2) {
			k = 1;
			mode = 1;
		}
		else if (mode == 0 && k == 1) {
			k = 2;
			mode = 1;
		}
		else {
			k += 2;
		}
	}

    return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[100010][3],dp[100010][3];
signed main(){
    cin>>n;
    rep(i,n){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j!=k)chmax(dp[i+1][k],dp[i][j]+a[i][k]);
            }
        }
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
    return 0;
}

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    int a[N]; for(int i=0;i<N;i++) cin >> a[i];
    bool flag=false;
    for(int i=0;i<N;i++){
        if(a[i]%2==1){
            flag=true;
            break;
        }
    }
    if(flag) cout << "first" << endl;
    else cout << "second" << endl;
}


Measured memory_bytes: 640
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
String line =sc.nextLine();
String[]a=line.split(" ",0);
int []n=new int[2];
for(int i=0;i<2;i++){
n[i]=Integer.parseInt(a[i]);
}
if(n[1]<9&&n[0]<9){
System.out.println("Yay!");
}
else System.out.println(":(");
}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S;

  long long K;

  std::cin >> S >> K;

  int C = 0;

  char second = -1;

  for (const auto& c : S)
    if (c == '1') {
      C ++;
    }
    else {
      second = c;
      
      break;
    }

  std::cout << (K <= C ? '1' : second) << std::endl;

  return 0;
}


Measured memory_bytes: 256
s = input()
head = int(s[0]+s[1])
tail = int(s[2]+s[3])
#print(head,tail)
if 1<=head<=12:
    if 1<=tail<=12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<=tail<=12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
  public static void main(String[] args) throws Exception{
    int x,y,tmp;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    while (true){
      String[] line = br.readLine().split(" ");
      x = Integer.parseInt(line[0]);
      y = Integer.parseInt(line[1]);
      if(x==0 && x==y){
        break;
      }else if(x>y){
        tmp = x;
        x = y;
        y = tmp;
      }
      System.out.println(x+" "+y);
    }
  }
}

Measured memory_bytes: 26712
import fractions
a,b,c,d = map(int, input().split())
gcd = fractions.gcd(c,d)
lcm = c * d // gcd
num = [c,d,lcm]
l = b - a + 1
temp = []

for i in range(3):
  count = 0
  if l - num[i] >= 0:
    count += l // num[i]
    if l % num[i] != 0:
      if b % num[i] < (b - (l % num[i]) + 1) % num[i]:
        count += 1
  else:
    if b % num[i] < l:
        count += 1
  temp.append(count)

ans = l - (temp[0] + temp[1] - temp[2])
print(ans)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    vector<string> x(a);
    vector<bool>  l(a, false), r(a, false);

    for (int i = 0; i < a; i++) cin >> x[i];
    for (int i = 0; i < a; i++) {
        for (int k = 0; k < b; k++) {
            if (x[i][k] == '#') {
                l[i] = true, r[k] = true;
            }
        }
    }

    for (int i = 0; i < a; i++) {
        if (l[i]) {
            for (int k = 0; k < b; k++){
                if (r[k]) {
                    cout << x[i][k];
                }
            }
            cout << endl;
        }
    }

}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
h = Hash.new(0)
a.sort!.reverse!

def f(x)
  res = 1
  while x>0
    x /= 2
    res *= 2
  end
  res
end

ans = 0
a.each{|t|
  r = f(t)
  if h[t]>0
    h[t]-=1
    ans+=1
  else
    h[r-t]+=1
  end
}

p ans


Measured memory_bytes: 28900
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val a, b, c = sc.nextInt()

  println(solve(a, b, c))

  def solve(a : Int, b: Int, c: Int): String = {

    for (i <- 1 to 100) {
      if ((a * i) % b == c) {
        return "YES"
      }
    }
    "NO"
  }
}


Measured memory_bytes: 25524
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Applicative


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

main = putStrLn . f =<< replicateM 5 readInt
  where f [w,h,x,y,r] = if and [r <= x, x + r <= w, r <= y, y + r <= h] then "Yes" else "No"


Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main(void){
	char str[1000];
	
	while(scanf("%s", str) != EOF ){
		int size = strlen(str);
		int a[4] = {0};
		char s[4] = {'K','U','P','C'};
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < size; j++){
				if(str[j] == s[i]){
					a[i]++;
				}
			}
		}
		
		printf("%d\n",min(min(a[0],a[1]),min(a[2],a[3]) ));
	}
	
	return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;
    while(x!=0 || y!=0) {
        if (x<y) {
            cout << x << " "<< y <<endl;
        } else {
            cout << y << " "<< x <<endl;
        }
    cin >> x >> y;
    }
    return 0;
}



Measured memory_bytes: 3004
package main

import (
    "fmt"
    "math"
)

func main() {
    var e int
    for {
        fmt.Scan(&e)
        if e == 0 { break }

        var ans float64 = float64(e)
        for z := 0; z <= 101; z++ {
            for y := 0; y <= 1001; y++ {
                x := e - y*y - z*z*z
                if (0 <= x && x <= 100000) {
                  ans = math.Min(ans, float64(x+y+z));
                }
            }
        }
        fmt.Println(ans)
    }
}



Measured memory_bytes: 1356
n, m = map(int, input().split())

h = tuple(map(int, input().split()))

not_good = set()
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    if h[a] > h[b]:
        not_good.add(b)
    elif h[b] > h[a]:
        not_good.add(a)
    else:
        not_good.add(a)
        not_good.add(b)

print(n - len(not_good))


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t;

int main() {
	cin >> s;
	
	t = s;
	int p = 0;
	inc(i, s.size()) {
		if(s[i] != 'B') { t[p++] = s[i]; }
		else if(p > 0) { p--; }
	}
	
	cout << t.substr(0, p) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, k, a[200005];
ll lt=-1e18, rt=1e18, md, ans, cnt;

ll neg(ll p) {
	ll l=p, r=n, m, x;
	while(l+1!=r) {
		m = l + r >> 1;
		if(a[p] * a[m] <= md) r = m;
		else l = m;
	}
	return n - r;
}

ll pos(ll p) {
	ll l=p, r=n, m, x;
	while(l+1!=r) {
		m = l + r >> 1;
		if(a[p] * a[m] <= md) l = m;
		else r = m;
	}
	return l - p;
}

int main() {
	ll i;
	cin >> n >> k;
	for(i=0; i<n; i++) scanf("%lld", &a[i]);
	sort(a, a+n);
	while(lt <= rt) {
		md = lt + rt >> 1;
		cnt = 0;
		for(i=0; i<n; i++) {
			if(a[i] < 0) {
				cnt += neg(i);
			} else {
				cnt += pos(i);
			}
		}
		if(cnt < k) lt = md + 1;
		else rt = md -1, ans = md;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main ()
{
    int N,A,B;
    scanf ("%d %d %d",&N,&A,&B);
    if (N>=1&&N<=20&&A>=1&&A<=50&&B>=1&&B<=50)
    {
        if ((N*A)<B)
        {
            printf ("%d\n",N*A);
        }
        if ((N*A)>B)
        {
            printf ("%d\n",B);
        }
        if ((N*A)==B)
        {
            printf ("%d\n",B);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<math.h>
#include<algorithm>

using namespace std;


int main(){
    int len_array;
    scanf("%d",&len_array);
    vector<int> int_array(len_array);
    for(int i = 0; i < len_array;i++){
        int_array[i] = i+1;
    }
    do{
        for(int i = 0;i < len_array;i++){
            if(i != len_array-1) printf("%d ",int_array[i]);
            else printf("%d\n",int_array[i]);
        }
    }while(next_permutation(int_array.begin(),int_array.end()));
    
    return 0;
}


Measured memory_bytes: 2696
/*氏名：保坂優介, 学籍番号：200441141
  概要：*/

#include<stdio.h>

int main(void)
{
    int i, j, H, W;     //変数の宣言

    scanf("%d %d", &H, &W);     //入力

    while (H != 0 && W != 0)        //0 0が入力されるまで繰り返す
    {
        for (j = 0; j < W; j++)     //W回繰り返す
        {
            printf("#");        //表示
        }

        printf("\n");       //改行
        
        for (i = 0; i < H-2; i++)     //H回繰り返す
        {
            printf("#");

            for (j = 0; j < W-2; j++)     //W回繰り返す
            {
                printf(".");        //表示
            }

            printf("#\n");       //表示
        }

        for (j = 0; j < W; j++)     //W回繰り返す
        {
            printf("#");        //表示
        }

        printf("\n\n");       //改行

        scanf("%d %d", &H, &W);//入力
    }

    return 0;
}


Measured memory_bytes: 2096
// C - GCD on Blackboard

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int A[100000];
int m_gcd[100000];
int m_gcd_l[100000];
int m_gcd_r[100000];

ll get_gcd(ll x, ll y) {
	if (y > 0) return get_gcd(y, x % y);
	else return x;
}

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

	for (int i=0; i<N; i++) {
		cin >> A[i];
	}

	int gcd;

	gcd = A[0];
	for (int i=1; i<N; i++) {
		m_gcd_l[i] = gcd;
		gcd = get_gcd(gcd, A[i]);
	}

	gcd = A[N-1];
	for (int i=N-2; i>=0; i--) {
		m_gcd_r[i] = gcd;
		gcd = get_gcd(gcd, A[i]);
	}

	for (int i=1; i<= N-2; i++) {
		m_gcd[i] = get_gcd(m_gcd_l[i], m_gcd_r[i]);
	}
	m_gcd[0] = m_gcd_r[0];
	m_gcd[N-1] = m_gcd_l[N-1];

	int ans = 0;

	for (int i=0; i<N; i++) {
		ans = max(ans, m_gcd[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5204
from queue import Queue
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    G[A].append(B)
    G[B].append(A)
que = Queue()
que.put(0)
visit = [0] * N
ans = [0] * N
while not que.empty():
    v = que.get()
    for next_v in G[v]:
        if visit[next_v] == 1:
            continue
        ans[next_v] = v
        visit[next_v] = 1
        que.put(next_v)
print("Yes")
for i in list(map(lambda x: x+1, ans[1:])):
    print(i)

Measured memory_bytes: 39112
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, C, K;
  cin >> N >> C >> K;
  vector<ll> t(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }
  sort(t.begin(), t.end());
  ll ans = 1;
  ll end = t[0] + K;
  ll cnt = 1;
  for (int i = 1; i < N; i++) {
    if (t[i] <= end && cnt < C) {
      cnt++;
      continue;
    }
    ans++;
    cnt = 1;
    end = t[i] + K;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3972
def main():
    n, m = map(int, input().split())
    query = [[int(x) for x in input().split()] for _ in range(m)]
    break_bridges = [-1]
    query.sort(key=lambda x: x[1])
    for begin, end in query:
        if not (begin <= break_bridges[-1] < end):
            break_bridges.append(end - 1)
    print(len(break_bridges) - 1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 22820
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<assert.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e6+10, M = 1e6+10;

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

Measured memory_bytes: 3636
#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)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(s.size()>=4 && s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I'){
		cout<<"Yes"<<'\n';
	}
	else{
		cout<<"No"<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 200000+10;
int a[MAXN],n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]-=i;
	};
	sort(a+1,a+n+1);
	int l=1,r=n;
	long long ans=0;
	while(l<r)
	{
		ans+=a[r]-a[l];
		++l;--r;
	};

	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

vector <ll> vec[100005];
ll flg[100005];
void solve(ll id)
{
    flg[id] = 1;
    for(ll v:vec[id])
    {
        if(flg[v]==-1)
           solve(v);
    }
}

int main()
{	
    std::ios_base::sync_with_stdio(0);
	  cin.tie(0);
	  cout.tie(0);

    ll n,m;
    cin>>n>>m;

    for(ll i=0;i<m;i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }

    ll ans = 0;
    memset(flg,-1,sizeof(flg));
    for(ll i=0;i<n;i++)
    {
        if(flg[i+1]==-1)
        {
            solve(i+1);
            ans++;
        }
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 9856
#include<iostream>
using namespace std;
int main()
{
    string str;
    cin >> str;

    bool c = false;
    string result = "No";
    for (int i = 0; i < (int)str.size(); i++) {
        if (str[i] == 'C') {
            c = true;
        } else if (str[i] == 'F' && c) {
            result = "Yes";
            break;
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 384
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

int h[maxn], dp[maxn];

int N, K;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//
	cin >> N >> K;
	for (int i = 0; i < N; i++)
		cin >> h[i];
	//
	for (int i = 1; i < N; i++) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		for (int t = 1; t <= K && i - t >= 0; t++)
			dp[i] = min(dp[i], dp[i - t] + abs(h[i] - h[i - t]));
	}
	//
	cout << dp[N - 1] << "\n";
}



Measured memory_bytes: 1024
H, W, A, B = map(int, input().split())

MOD = 10 ** 9 + 7


def pow_mod(x, p):
    res = 1
    while p:
        if p % 2:
            res = res * x % MOD
        x = x * x % MOD
        p //= 2
    return res


F = [1]
invF = []


def comb_mod(n, r):
    return F[n] * invF[r] * invF[n - r] % MOD


for i in range(1, H + W - 1):
    F.append(F[-1] * i % MOD)

invF.append(pow_mod(F[-1], (MOD - 2)))
for f in range(len(F) - 1):
    invF.append(invF[-1] * (len(F) - len(invF)) % MOD)
invF = invF[::-1]

res = 0
for i in range(B + 1, W + 1):
    p = H - A - 1
    q = i - 1

    res = (
                  res
                  + comb_mod(H - A - 1 + i - 1, H - A - 1)
                  * comb_mod(A - 1 + W - i, W - i)
          ) % MOD

print(res)


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

using namespace std;

#define int long long
typedef long double ld;
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vi>
#define viii vector<vii>
#define vpii vector<pii>
#define vb vector<bool>
#define vbb vector<vb>
#define vs vector<string>
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define in(a, x) for (int i = x; i < (a).size(); ++i) cin >> (a)[i]
#define out(a) for (auto qwe : a) cout << qwe << " "

const int INF = 1e9;
const int INF64 = 1e18;
const int MOD = 1e9 + 7;
const int MOD9 = 1e9 + 9;
const int MOD3 = 998244353;
const int P = 37;

const int mxn = 200000;

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

    int n;
    cin >> n;

    vii mask(n + 1, vi(0));

    for (int j = 0; j < (1 << n); ++j) {
        int c = 0;
        for (int i = 0; i < n; ++i) {
            if ((1 << i) & j) ++c;
        }
        mask[c].pb(j);
    }

    vii a(n + 1, vi(n + 1, 1));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> a[i][j];
        }
    }

    vii dp(n + 1, vi((1 << n), 0));
    dp[0][0] = 1;

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < mask[k].size(); ++i) {
            int x = mask[k][i];

            for (int j = 0; j < n; ++j) {
                if (!((1 << j) & x) && a[k + 1][j + 1]) {
                    dp[k + 1][((1 << j) | x)] += dp[k][x];
                    dp[k + 1][((1 << j) | x)] %= MOD;
                }
            }
        }
    }

    cout << dp[n][(1 << n) - 1];
}


Measured memory_bytes: 400416
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl


/*--------------------template--------------------*/

int main()
{
	cin >> n;
	vi v(n), a(n);
	REP(i, n) cin >> v[i];
	REP(i, n)
	{
		if (v[i] == i + 1) {
			a[i] = 1;
		} else {
			a[i] = 0;
		}
	}

	if (a[0] == 1) {
		swap(v[0], v[1]);
		a[0] = 0;
		if (v[1] == 2) {
			a[1] = 1;
		} else {
			a[1] = 0;
		}
		cnt++;
	}
	REP(i, n - 1)
	{
		if (a[i] == 1) {
			a[i] = 0;
			if (a[i + 1] == 1) {
				swap(v[i], v[i + 1]);
				a[i] = a[i + 1] = 0;
			} else if (v[i + 1] > i) {
				swap(v[i], v[i + 1]);
				if (v[i + 1] == i + 2) {
					a[i + 1] = 1;
				} else {
					a[i + 1] = 0;
				}
			} else {
				swap(v[i], v[i - 1]);
				if (v[i - 1] == i) {
					a[i - 1] = 1;
				} else {
					a[i - 1] = 0;
				}
			}
			cnt++;
		}
	}

	if (a[n - 1] == 1) {
		swap(v[n - 1], v[n - 2]);
		a[n - 1] = 0;
		if (v[n - 1] == n) {
			a[n - 2] = 1;
		} else {
			a[n - 2] = 0;
		}
		cnt++;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel B(N-1); rep(i,N-1) cin >> B[i];
    ll ans = B[0] + B[N-2];
    rep(i,N-2) ans += min(B[i],B[i+1]);
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main() {
    int n,m;
    map<string, int> mp;
    cin >> n;
    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    for (int i=0; i<m; i++) {
        string s;
        cin >> s;
        mp[s]--;
    }

    int ans = 0;
    for (auto p : mp) ans = max(ans, p.second);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll k, s, a, e;
  a = 0;
  in2(k, s);
  rep(i, k + 1){
    rep(j, k + 1){
      e = s - i - j;
      if(e < k + 1 && 0 <= e)
        a++;
    }
  }
  out(a);
  memi;
}

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

int main(){
    string s;cin>>s;
    ll mod1=1e+9 +7;
    int mod=13;
    int length = s.length();
    ll d[length+1][13];
    for(int i=0;i<13;i++){
        for(int j=0;j<=length;j++) d[j][i]=0;
    }
    int beki=1;
    //for(int i=0;i<10;i++) d[length][i]=1;
    d[length][0]=1;

    for(int i=length;i>0;--i){
        char a = s.at(i-1);
        if(a=='?'){
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++){
                    d[i-1][(beki*k+j)%mod]+=d[i][j];
                    d[i-1][(beki*k+j)%mod]%=mod1;
                }                
            }
        }
        else{
            int c =s[i-1]-'0';
            for(int j=0;j<13;j++){

                d[i-1][(beki*c+j)%mod]+=d[i][j];
                d[i-1][(beki*c+j)%mod]%=mod1;

            }
        }


        beki = beki*10%mod;

    }
    cout << d[0][5]<<endl;
}

Measured memory_bytes: 13920
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    string s;
    cin>>s;
    for(int i=0;i<(int)s.size()-1;i++){
        if(s[i]=='A' && s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int width = scan.nextInt();
		int height = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		
		if(x - r >= 0 && y - r >= 0 && x + r <= width && y + r <= height)
		{
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17316
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static IEnumerable<int[]> ReadData()
        {
            string line;
            while((line = Console.ReadLine()) != "0,0")
            {
                yield return line.Split(',').Select(int.Parse).ToArray();
            }
        }

        static void Main(string[] args)
        {
            var ranks = ReadData()
                .GroupBy(x => x[1], x => x[0])
                .OrderByDescending(x => x.Key)
                .SelectMany((x, rank) => x.Select(x2 => new {x = x2, rank = rank + 1}))
                .ToDictionary(x => x.x, x => x.rank);

            string line;
            while ((line = Console.ReadLine()) != null)
            {
                Console.WriteLine(ranks[int.Parse(line)]);
            }
        }
    }
}

Measured memory_bytes: 6804
#include<bits/stdc++.h>
using namespace std;
int n,a[1010][1010];
vector<int> v[1010];
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		int x=i;
		while (x!=0){
			v[i].push_back(x%2);
			x/=2;
		}
		while (v[i].size()<60) v[i].push_back(0);
		reverse(v[i].begin(),v[i].end());
	}
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++)
			for (int k=0;k<v[i].size();k++)
				if (v[i][k]!=v[j][k]) a[i][j]=a[j][i]=60-k;
	for (int i=1;i<=n;i++,cout<<endl)
		for (int j=i+1;j<=n;j++)
			cout<<a[i][j]<<' ';
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int L,R,d,c=0,x;
    cin>>L>>R>>d;
    for(int i=1; ;++i)
    {
        x=d*i;
        if(x>=L&&x<=R)
            ++c;
        if(x>R)
            break;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3632
count = int(input())

sonomama = []
city = {}
for i in range(count):
    score = input().split()
    sonomama.append(' '.join(score))
    if score[0] not in city:
        city[score[0]] = []
    city[score[0]].append(score[1])

city = sorted(city.items())

for item in city:
    holder = sorted(map(int, item[1]), reverse=True)
    for i in range(len(item[1])):
        print(sonomama.index(item[0]+' '+str(holder[i]))+1)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int tenpower[10];

int calc(int n, int c, int t, int lz) {
	int i[3] = {};
	if (c == 0) {
		while (t > 0) {
			if (t % 10 == 3) i[0] = 1;
			if (t % 10 == 5) i[1] = 1;
			if (t % 10 == 7) i[2] = 1;
			t /= 10;
		}
		if (i[0] + i[1] + i[2] == 3) {
			return 1;
		}
		return 0;
        }
	int r = 0;
	if (lz) r = calc(n, c - 1, t, 1);
	if (n >= t + 3 * tenpower[c - 1]) {
		r += calc(n, c - 1, t + 3 * tenpower[c - 1], 0);
	}
	if (n >= t + 5 * tenpower[c - 1]) {
		r += calc(n, c - 1, t + 5 * tenpower[c - 1], 0);
	}
	if (n >= t + 7 * tenpower[c - 1]) {
		r += calc(n, c - 1, t + 7 * tenpower[c - 1], 0);
	}
	return r;
}

int main(int argc, char *argv[]) {
	int n;
	scanf("%d", &n);
	int r, c;
	for (r = n, c = 0; r > 0; c++) r /= 10;
	tenpower[0] = 1;
	for (r = 1; r < 10; r++) tenpower[r] = 10 * tenpower[r - 1];
	printf("%d\n", calc(n, c, 0, 1));
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, C: int):
    return min(B // A, C)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    result = solve(A, B, C)
    print(result)

if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    REP(i, n){
        int tmp;
        cin >> tmp;
        mp[tmp]++; 
    }

    int ev = 0;
    for(auto x : mp){
        if(x.second % 2);
        else ev++;
    }

    if(ev % 2)  cout << mp.size() - 1 << endl;
    else cout << mp.size() << endl;

    return 0;
}

Measured memory_bytes: 4992
/*  CREATED BY
    STREAM_CIPHER
    07-sep-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;//5*64M bit ->5*8M byte ->40MB size for long long int (64 bit)
int vis[mx];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    #endif
        int n;
        cin>>n;
        vector<int>a(n);
        for(auto &i:a)
        	cin>>i,vis[i]++;
        int ans=0;
        for(int i=0;i<n;i++)
        {
        	vis[a[i]]--;
        	bool fnd=false;
        	for(int j=1;j<=sqrt(a[i]);j++)
        	{
        		if(a[i]%j==0)
        		{
        			// debug1(j);
        			if(vis[j]!=0)
        			{
        				fnd=true;
        				break;
        			}
        			if(a[i]/j!=j)
        			{
        				if(vis[a[i]/j]!=0)
        				{
        					fnd=true;
        					break;
        				}
        			}
        		}
        	}
        	if(!fnd)
        		ans++;
        	vis[a[i]]++;
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 12640
#include<iostream>
#include <cstdio>
#include<ios>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N, A[200002];
    int num_sup[200002] = {0};
    cin >> N;
    for (int i = 2; i <= N; i++){
        cin >> A[i];
        num_sup[A[i]]++;
    }
    for(int i = 1; i <= N; i++) {
        cout << num_sup[i] << "\n";
        // printf("%d\n",num_sup[i]);
    }
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define IN freopen("input.txt", "r", stdin);
#define OUT freopen("output.txt", "w", stdout);
#define ll long long

int main()
{
    FAST;
    // IN;
    // OUT;
    int n;
    cin>>n;
    int AC=0,WA=0,TLE=0,RE=0;
    string str;
    while(n--)
    {
        cin>>str;
        if(str.compare("AC")==0)
            AC++;
        else if (str.compare("WA")==0)      
            WA++;
        else if(str.compare("TLE")==0)
            TLE++;
        else
            RE++;
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
}

Measured memory_bytes: 3656
import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

myCeiling :: Int -> Int -> Int
myCeiling x y = ceiling ((fromIntegral x) / (fromIntegral y))

main = do
  [a, b, c, d] <- map toInt . words <$> getLine
  putStrLn $ if myCeiling a d >= myCeiling c b then "Yes" else "No"


Measured memory_bytes: 3892
#include<stdio.h>

int main(){
  int n,m,a,b,i,j,k,flag=0;
  long c,g[1001][1001][2]={};
  scanf("%d %d",&n,&m);
  for(i=1;i<=n;i++)
    g[i][i][1]=1;
  for(i=0;i<m;i++){
    scanf("%d %d %ld",&a,&b,&c);
    g[a][b][0]=c;
    g[a][b][1]=1;
  }
  for(k=1;k<=n;k++)
    for(i=1;i<=n;i++)
      for(j=1;j<=n;j++)
        if(g[i][k][1]&&g[k][j][1]&&(g[i][j][0]<g[i][k][0]+g[k][j][0]||g[i][j][1]==0)){
          g[i][j][1]=1;
          g[i][j][0]=g[i][k][0]+g[k][j][0];
        }
  for(i=1;i<=n;i++)
    if(g[i][i][0]>0&&g[i][n][1]==1)
      flag=1;
  /*for(i=1;i<=n;i++){
    for(j=1;j<=n;j++)
      printf("%ld ",g[i][j][0]);
    printf("\n");
  }*/
  if(flag)
    printf("inf\n");
  else
    printf("%ld\n",g[1][n][0]);
}

Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

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

	ll a, b;
	cin >> a >> b;

	ll check = max(a,b);
	if(check > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;


	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int rcount = 0;
  int bcount = 0;
  int i;
  for(i = 0; i < n; i++)
  {
    if(s.at(i) == 'R')
    {
      rcount++;
    }
    if(s.at(i) == 'B')
    {
      bcount++;
    }
  }
  if(rcount > bcount)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

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

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N=0; cin >> N;

    cout << N*N*N << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i,h) cin >> grid[i];
  Graph d(h, V(w,-1));
  ll sy = 0, sx = 0, gy = h-1, gx = w-1;
  d[sy][sx] = 0;
  queue<P> q;
  vector dy = {0,1,0,-1};
  vector dx = {1,0,-1,0};

  q.push(make_pair(sy,sx));
  while(!q.empty()) {
    ll y = q.front().first, x = q.front().second;
    if (d[gy][gx] != -1) break;
    rep(i,4) {
      ll ny = y + dy[i], nx = x + dx[i];
      if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue;
      if (grid[ny][nx] == '.' && d[ny][nx] == -1) {
        d[ny][nx] = d[y][x]+1;
        q.push(make_pair(ny,nx));
      }
    }
    q.pop();
  }
  
  ll cnt = 0;
  rep(i,h) rep(j,w) {
    if (grid[i][j] == '.') ++cnt;
  }

  if (d[gy][gx] == -1) cout << -1 << '\n';
  else cout << cnt - d[gy][gx] - 1 << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3656