akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        xy: [(f64, f64); n],
    }
    const W: i32 = 1000000;
    let pi = (-1.0f64).acos();
    let delta = 2.0 * pi / (W as f64);
    let mut ma = 0.0;
    for rot in 0..W {
        let theta = rot as f64 * delta;
        let c = theta.cos();
        let s = theta.sin();
        let mut x = 0.0;
        let mut y = 0.0;
        for i in 0..n {
            let (a, b) = xy[i];
            if c * a + s * b > 0.0 {
                x += c * a + s * b;
                y += -s * a + c * b;
            }
        }
        let d = (x * x + y * y).sqrt();
        if ma < d {
            ma = d;
        }
    }
    puts!("{}\n", ma);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8700
#include<iostream>
#include<string>

using namespace std;
int main(){
    int h,w,ans=-1;
    cin>>h>>w;
    if(h%3==0 || w%3==0)ans=0;
    else if(h%2==0 && h==w)ans=h/2;
    else if(h%2==1 && h==w)ans=h-1;
    if(ans==-1){
        if(h>w)swap(h,w);
        if(h%2==0){
            if(w%2==1 && w<h/2)ans=w;
            else ans=h/2;
        }else{
            if(w%2==0 && w/2<h)ans=w/2;
            else ans=h;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int n,k;
    ll ans;

    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    sort(h.begin(), h.end(), greater<int>());
    ans = 0;
    for (int i = k;i < n;++i) {
        ans += h[i];
    }
    //結果
    std::cout << ans << endl;
}



Measured memory_bytes: 4040
N=int(input())
A=list(map(int,input().split()))

A2=[0]+A+[0]

D=0

for i in range(1,N+2):
    D+=abs(A2[i]-A2[i-1])

for i in range(1,N+1):
    if (A2[i]-A2[i-1])*(A2[i]-A2[i+1])<0:
        print(D)
    else:
        print(D-abs(A2[i]-A2[i-1])-abs(A2[i]-A2[i+1])+abs(A2[i+1]-A2[i-1]))

Measured memory_bytes: 14048
if isfile("in.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
macro p(z);:((x->parse(Int,x)).(split($z)));end
function pul(l,x)
  for i=x; l[x]+=1; end
end
function main()
  n,m=@p(readline())
  l=fill(0,m)
  for i=1:n
    for j=@p(readline())[2:end]; pul(l,j); end
  end
  print(count(x->x==n,l))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


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


const int MOD=1e9+7;

ll cal(ll a,ll n){
  ll tmp=a;
  tmp=tmp%MOD;
  for(ll i=0;i<n-1;++i){
    tmp=tmp*a;
    tmp=tmp%MOD;
  }
  return tmp;
}

int main(){
  int n;
  cin >> n;
  ll ans=cal(10,n)-cal(9,n)-cal(9,n)+cal(8,n);
  ans%=MOD;
  if(ans<0) ans+=MOD;

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
  int n;
  float const PI = 3.141592653589793238462643383; 
  while(cin >> n )
  {
    float res = 2 * PI * n;
    cout << setprecision(17) << res << endl;
  }
}

Measured memory_bytes: 3256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};

intl pow(intl a,intl n){
  intl ans=1;
  Rep(i,n) ans *=a;
  return ans;
}

int main(){
  intl A;
  cin >>A;
  int ure500 = (A/500) *1000;
  int ure5 = ((A%500)/5) *5;
  cout << ure500+ure5;
}
  

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		Result [] resultArray = new Result[24];
		for(int i = 0; i < 24; i++) {
			int n = sc.nextInt();
			String str = sc.next(); 
			resultArray[i] = new Result(n, str);
		}
		Arrays.sort(resultArray, 0, 8);
		Arrays.sort(resultArray, 8, 16);
		Arrays.sort(resultArray, 16, 24);
		for(int i = 0; i < 3; i++) {
			System.out.println(resultArray[i * 8].num + " " + resultArray[i * 8].time);
			System.out.println(resultArray[i * 8 + 1].num + " " + resultArray[i * 8 + 1].time);
			resultArray[i * 8].time = "aaaa";
			resultArray[i * 8 + 1].time = "aaaa";
		}
		Arrays.sort(resultArray);
		System.out.println(resultArray[0].num + " " + resultArray[0].time);
		System.out.println(resultArray[1].num + " " + resultArray[1].time);
	}
	
}
class Result implements Comparable<Result> {
	int num;
	String time;
	Result(int num, String time) {
		this.num = num;
		this.time = time;
	}
	@Override
	public int compareTo(Result r) {
		return time.compareTo(r.time);
	}
}	

Measured memory_bytes: 26172
#include <iostream>
#include<stdio.h>
#define MAX_N 100005
using namespace std;
typedef long long ll;
typedef pair<int ,bool> p;
p fa[MAX_N];
int main(){
    int n,q;
    fa[1].first = 1;
    fa[1].second = true;
    while(~scanf("%d%d",&n,&q)&&n>0){
        ll ans = 0;
        for(int i = 2;i <= n;i++){
            scanf("%d",&fa[i].first);
            fa[i].second = false;
        }
        getchar();
        for(int i = 0;i<q;i++){
            char ch;int a;
            scanf("%c%d",&ch,&a);
            getchar();
            if(ch =='Q'){
                while(fa[a].second==false){
                    a = fa[a].first;
                }
                ans += a;
            }
            else{
                fa[a].second = true;
            }

        }
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 3892
s=input()
n=len(s)
a=0
t=1
d=[1]+[0]*2018
 
for i in range(n):
    a+=int(s[n-1-i])*t
    a%=2019
    t*=10
    t%=2019
    
    d[a]+=1

ans=0
for i in d:
    ans+=i*(i-1)//2
 
print(ans)

Measured memory_bytes: 9260
using System;

class main{
	static void Main(){
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Trim().Split(' ');
		int D = int.Parse(str[0]);
		int X = int.Parse(str[1]);
		int ans = X;
		for(int i = 0; i < N; i++){
			int A = int.Parse(Console.ReadLine());
			ans += (D - 1) / A + 1;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
/// {{{ Author: Wang, Yen-Jen
// include
#include <bits/stdc++.h>

// using
using namespace std;

// types
typedef long long ll;
typedef pair<int,int> pii;

// macro
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin() , (x).end()
#define REP(i , n) for(int i = 0; i < int(n); i++)
#define REP1(i , a , b) for(int i = a; i <= int(b); i++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define LC o<<1 , l , m
#define RC o<<1|1 , m + 1 , r
#define MS(x , v) memset(x , (v) , sizeof(x))

// input
inline bool SR(int &x) {
  return scanf("%d",&x) == 1;
}

inline bool SR(ll &x) {
  return scanf("%lld",&x) == 1;
}

inline bool SR(double &x) {
  return scanf("%lf",&x) == 1;
}

inline bool SR(char *s) {
  return scanf("%s",s) == 1;
}

inline bool RI() {
  return true;
}

template<typename I , typename... T> inline bool RI(I &x , T&... tail) {
  return SR(x) && RI(tail...);
}

// output
inline void SP(const int x) {
  printf("%d",x);
}

inline void SP(const ll x) {
  printf("%lld",x);
}

inline void SP(const double x) {
  printf("%.16lf",x);
}

inline void SP(const char *s) {
  printf("%s",s);
}

inline void PL() {
  puts("");
}

template<typename I , typename... T> inline void PL(const I x , const T... tail) {
  SP(x);
  if(sizeof...(tail)) putchar(' ');
  PL(tail...);
}

// debug
#define WangYenJen

#ifdef WangYenJen
template<typename I> void _DOING(const char *s , I&& x) {
  cerr << s << " = " << x << endl;
}

template<typename I , typename... T> void _DOING(const char *s , I&& x , T&&... tail) {
  int c = 0;
  while(*s != ',' || c != 0) {
    if(*s == '(' || *s == '[' || *s == '{') c++;
    if(*s == ')' || *s == ']' || *s == '}') c--;
    cerr << *s++;
  }
  cerr << " = " << x << " , ";
  _DOING(s + 1 , tail...);
}

#define DEBUG(...) \
do {\
  fprintf(stderr , "%s: Line %d - ",__PRETTY_FUNCTION__,__LINE__);\
  _DOING(#__VA_ARGS__ , __VA_ARGS__);\
} while(0);

#else
#define DEBUG(...)

#endif

// constant number
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3fll;

// random function
inline int RAND() {
  static int x = 880301;
  return (x = x * 0xdefaced + 1) % 0x7fffffff;
}
/// }}}

const int MAX_N = 100000 + 7;

int A[MAX_N];

int main() {
  int N;
  RI(N);
  REP1(i, 1, N) RI(A[i]);
  sort(A + 1, A + N + 1, greater<int>());
  int p = 0;
  while (p + 1 < N && p + 1 < A[p + 2]) p++;
  int sg1 = (A[p + 1] - p) & 1, sg2 = 1;
  for (int i = p + 2; i <= N && A[i] > p; i++) sg2 ^= 1;
  int sg = sg1 & sg2;
  PL(sg ? "Second" : "First");
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    vector<string> f(h); for(auto& e : f) cin >> e;

    vi xs, ys;
    rep(y, h){
        bool ok = false;
        rep(x, w){
            ok |= (f[y][x] == '#');
        }
        if(ok) ys.emplace_back(y);
    }
    rep(x, w){
        bool ok = false;
        rep(y, h){
            ok |= (f[y][x] == '#');
        }
        if(ok) xs.emplace_back(x);
    }

    for(auto y : ys){
        for(auto x : xs){
            cout << f[y][x];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[][] numArray = new int[10][10];
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                numArray[i][j] = 0;
            }
        }
        for(int i=1;i<=N;i++){
            int topNum = Integer.parseInt(String.valueOf(i).substring(0,1));
            int bottomNum = i % 10;
            numArray[topNum][bottomNum]++;
        }
        int res = 0;
        for(int i=1;i<=N;i++){
            int topNum = Integer.parseInt(String.valueOf(i).substring(0,1));
            int bottomNum = i % 10;
            res += numArray[bottomNum][topNum];
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 40424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";

vector<vector<pair<ll, ll>>> v(100001);
vector<pair<ll, string>> v2;

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

    int n, m;
    cin >> n >> m;

    vector<ll> pi(m);
    vector<ll> yi(m);
    REP(i, m) {
        cin >> pi[i] >> yi[i];
        v[pi[i]].push_back(make_pair(yi[i], i));
    }

    REP(i, 100001) {
        if (v[i].empty()) { continue; }

        sort(ALL(v[i]));

        int id = 1;
        for (auto& j : v[i]) {
            stringstream ss;
            ss << setw(6) << setfill('0') << i;
            ss << setw(6) << setfill('0') << id;
            auto p = make_pair(j.second, ss.str());
            v2.push_back(p);
            id++;
        }
    }

    sort(ALL(v2));

    for (auto& p : v2) {
        cout << p.second << LF;
    }

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	int x, y, a;
	int x1=0, x2=w, y1=0, y2=h;
	rep(i, n) {
		cin >> x >> y >> a;
		if (a == 1) {
			x1 = max(x1, x);
		}
		else if (a == 2) {
			x2 = min(x2, x);
		}
		else if (a == 3) {
			y1 = max(y1, y);
		}
		else {
			y2 = min(y2, y);
		}
	}
	if (x1 >= x2 || y1 >= y2)cout << 0 << endl;
	else cout << (x2 - x1) * (y2 - y1) << endl;

	return 0;
}



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

int main(){
    int n;
    cin >> n;
    int a;
    int count[200010];
    for(int i=1; i<=n; i++){
        count[i] = 0;
    }
    for(int i=0; i<n-1; i++){
        cin >> a;
        count[a]++;
    }
    for(int i=1; i<=n; i++){
        cout << count[i] << endl;
    }
    return 0;
}

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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

inline char up(char c){return c-'a'+'A';}
int main(){
    string a,b,c;
    cin>>a>>b>>c;
    cout<<up(a[0])<<up(b[0])<<up(c[0])<<endl;
    return 0;
}

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

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

  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int p;
    cin >> p;
    cnt += p != i + 1;
  }
  string ans = (cnt <= 2) ? "YES" : "NO";
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  for(;;){
    int siaisu;
    int j;
    int A={0};
    int B={0};
    scanf("%d",&siaisu);
	if(siaisu==0)
	  break;
  
    for(j=0;j<siaisu;j++){
      int Acard;
	  int Bcard;
      scanf("%d %d",&Acard,&Bcard);
	  if(Acard>Bcard)
	    A+=Acard+Bcard;
      else if(Acard<Bcard)
	    B+=Acard+Bcard;
	  else{
	    A+=Acard;
	    B+=Bcard;
	  }
    }
  
    printf("%d %d\n",A,B);
	  
  }
	  
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 2 * 1e5 + 50, mxn = 1e6 + 10;
bool isprime(int n)
{
	if(n==0 or n==1)return false;
	for(int i=2;i*i<=n;i++){
		if(n%i==0){
			return false;break;
		}
	}
	return true;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int n;
    cin>>n;
    for(int i=n;i<=sz;i++){
    	if(isprime(i)){
    		cout<<i<<"\n";
    		return 0;
    	}
    }
	
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b;
  string s;
  cin >> a >> b >> s;
  s[b-1]=s[b-1]-'A'+'a';
  cout << s;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    char S[60][60];
    for(int i=0;i<60;i++){
        for(int k=0;k<60;k++){
            S[i][k]='0';
        }
    }
    for(int i=1;i<=H;i++){
        for(int k=1;k<=W;k++){
            cin>>S[i][k];
        }
    }
    for(int i=1;i<=H;i++){
        for(int k=1;k<=W;k++){
          int sum=0;
          if(S[i][k]=='.'){
                for(int h=i-1;h<=i+1;h++){
                    for(int g=k-1;g<=k+1;g++){
                        if(S[h][g]=='#'){
                            sum++;
                        }
                    }
                }
                S[i][k]=sum+'0';
            }
        }
    }
    for(int i=1;i<=H;i++){
        for(int k=1;k<=W;k++){
            cout<<S[i][k];
           }
        cout<<endl;
     }
    return 0;
}


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

#include<iostream>
#include<iomanip>
#include<math.h>
#include<string.h>


using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define INF 1000000007
#define ull unsigned long long
#define PI 3.141592653589793238
#define pb push_back
#define max3(x, y, z) Max(x, Max(y, z))
#define min3(x, y, z) Min(x, Min(y, z))
#define mp make_pair
#define pre(a,b) cout << fixed << setprecision(a) << b  //a for precision b for answer
#define MAX 1e18
#define all(x) (x).begin(), (x).end()
#define lb lower_bound //lower_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘x’.
#define ub upper_bound //upper_bound(first_iterator, last_iterator, x) – returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘x’.
#define maxe *max_element
#define mine *min_element
#define acc(x) accumulate(x.begin(), x.end(), 0)
#define dst distance
#define sz(x) (int)x.size()

template <typename T>
inline T const& Max (T const& a, T const& b)
{ 
	return a < b ? b:a; 
}

template <typename T>
inline T const& Min (T const& a, T const& b) { 
   return a < b ? a:b; 
}

ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
}

ll SieveOfEratosthenes(int n) 
{  
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    {  
        if (prime[p] == true) 
        {   
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    /*for (int p=2; p<=n; p++) 
       if (prime[p]) 
          cout << p << " "; */
    return prime[n + 1];
}

int main()
{
	IOS;
	int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    int dp[n];
    dp[0] = 0;
    int m = INF;
    for (int i = 1; i < n; i++)
    {
        m = INF;
        for (int j = 1; j <= min(i, k); j++)
        {
            m = min(m, dp[i - j] + abs(h[i] - h[i - j]));
        }
        dp[i] = m;
    }
    cout << dp[n - 1] << '\n';
	return 0;
}

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

int main() {
  string s; cin>>s;
  vector<int> v;
  string t="";
  rep(i,s.size()){
    if(s[i]!='x'){
      v.push_back(i);
      t+=s[i];
    }
  }
  string tr;
  tr= t;
  reverse(tr.begin(), tr.end());
  if(t.size()==0 ){cout<<0<<endl;}
  else if( tr!= t){cout<<-1<<endl;}
  else{
    vector<int> vec(t.size()+1);
    rep(i,t.size()+1){
      if(i==0){vec[i]=v[0];}
      else if(i==t.size() ){vec[i]=s.size()-v[i-1]-1;}
      else{vec[i]=v[i]-v[i-1]-1;}
    }
    int ans=0;
    rep(i,t.size()+1){
      ans+=abs(vec[i]-vec[vec.size()-i-1] );
    }
   // if(vec.size() %2==1){
    //  ans-= vec[vec.size()/2];
    //}
    ans/=2;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 4524
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = scan.nextInt();
        a[1] = scan.nextInt();
        a[2] = scan.nextInt();
        Arrays.sort(a);
        System.out.println(a[0] * a[1] / 2);
    }
}

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

int main() {
	int n=1, a, b;

	std::cin >> a >> b;

	for (int i = 2; i < 1000; i++) {
		if (abs(n - a) == abs(n+i - b)) {
			std::cout << abs(n - a) << std::endl;
			exit(0);
		}

		n = n+i;
	}

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,d,e,g,i,j,k,f,t,x,y,p,q;
long long A,B,C,X,Y,Z;
long long MIN ,ans,mid,MAX,num;
long long a[200050],b[200050],s[20000];
char str[200050];


int main()
{
    double l,v;
    cin >> l;
    v=l/3.0;
    v=v*v*v;
    printf("%f",v);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for (int i = 1; i*i <= m; i++) {
		if (!(m%i)) {
			if (i*n <= m) {
				ans = max(ans, i);
			}
			if ((m / i)*n <= m) {
				ans = max(ans, m / i);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

c = [list(map(int, input().split())) for _ in range(3)]

for a1 in range(min(c[0] + [100]) + 1):
    for a2 in range(min(c[1] + [100]) + 1):
        for a3 in range(min(c[2] + [100]) + 1):
            x1 = [c[0][0] - a1, c[0][1] - a1, c[0][2] - a1]
            x2 = [c[1][0] - a2, c[1][1] - a2, c[1][2] - a2]
            x3 = [c[2][0] - a3, c[2][1] - a3, c[2][2] - a3]
            if x1 == x2 == x3:
                print("Yes")
                sys.exit()
print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  cin>>s>>t;
  bool f=false;
  for(int i=0;i<t.size()+1;i++){
    if(s==t) f=true;
    u=s.substr(s.size()-1,1)+s.substr(0,s.size()-1);
    s=u;
  }
  if(f)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;

int divnum(int n,int m) {
	int res=0;
	while (n > 0) {
		n /= m;
		res++;
	}
	return res - 1;
}


int main() {
	cin >> N;
	vector<int>coin(N + 1, 0);
	for (int i = 1; i <= N; i++) {
		int tmp = 1;
		coin[i] = coin[i - 1] + 1;
		for (int j = 1; j <= divnum(i,6); j++) {
			coin[i] =min(coin[i], coin[i - 6 * tmp]+1);
			tmp *= 6;
		}
		tmp = 1;
		for (int j = 1; j <= divnum(i, 9); j++) {
			coin[i] = min(coin[i], coin[i - 9 * tmp]+1);
			tmp *= 9;
		}
	}
	cout << coin[N] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  string s;
  cin >> s;
  s += "zzzz";
  if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I') cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = 0;
        int y = 0;
        while (true) {
            x = Integer.parseInt(sc.next());
            y = Integer.parseInt(sc.next());
            if (x == 0 && y == 0)
                break;
            else if (x > y)
                System.out.println(y + " " + x); 
            else
                System.out.println(x + " " + y);
        }
    }
}


Measured memory_bytes: 36384
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
	
ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}
int main()
{
	int a, b;
	cin >> a >> b;
	if( a%b==0){
		cout<<-1<<endl;
	}else{
		bool ans=true;
		int i=1;
		while(ans){
			ll tmp=a*i;
			if(tmp%a==0&&tmp%b!=0){
				ans=false;
				cout<<tmp<<endl;
			}
			i++;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define mai3(a,b,c) mai(a,mai(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define el cout<<endl;
#define deci(n) int n; cin>>n;
#define decs(n) string n; cin>>n;
//SUNEET KUMAR -->  ਸੁਨੀਤ 
int power(int a,int n)//binary expo
{
    int r;
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
        r=power(a,n/2);
    if(n%2==0)
        return ((r)%mod)*((r)%mod)%mod;
    else
        return ((((r)%mod)*((r)%mod))%mod*((a)%mod))%mod;
}
int mai(int a,int b)
{
    if(a>b)
    return a;
    else 
    {
        return b;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans;
}

int modinverse(int a)
{
    return power(a,mod-2);
}
signed main()
{
      int a,b;
      cin>>a>>b;
      int temp=min(a,b);
      int temp2=max(a,b);
      a=temp;
      b=temp2;
      if(a==1&&b==2)
      {
          cout<<3;
      }
      if(a==1&&b==3)
      {
          cout<<2;
      }
      if(a==2&&b==3)
      {
          cout<<1;
      }

}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""077-a"""

import sys
import pprint
import re

import itertools
pp = pprint.PrettyPrinter(indent=2)

def main():
    """Main function."""
    c1 = input()
    c2 = input()

    if c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3700
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readContents 2 >>= main'
    where
        main' [[n, m], xs] = print . solve n m $ sort xs

solve :: Int -> Int -> [Int] -> Int
solve n m xs
    | n >= m = 0
    | otherwise = last xs - head xs + 1 - n - r
    where
        r = sum $ take (n - 1) ds 
        ds = sortBy (flip compare) $ diffs xs
        diffs (x : y : zs) = (y - x - 1) : diffs (y : zs)
        diffs _ = []

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 16764
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] N = new int[n];
        for(int i=0;i<n;++i){N[i]=sc.nextInt();}

        Map<Integer,Integer> map1 = new HashMap<>();
        Map<Integer,Integer> map2 = new HashMap<>();
        for(int i=0;i<n;i=i+2){
            map1.put(N[i],map1.getOrDefault(N[i],0)+1);
        }
        for(int i=1;i<n;i=i+2){
            map2.put(N[i],map2.getOrDefault(N[i],0)+1);
        }
        //for(int a:map1.keySet()) System.out.println(a + "   "+map1.get(a));
        //for(int a:map2.keySet()) System.out.println(a + "   "+map2.get(a));
        //.
        int max1 = 0;
        int maxidx1 = 0;
        for(int a:map1.keySet()) if (map1.get(a)>max1) {max1=map1.get(a);maxidx1=a;}
        //.
        int max2 = 0;
        int maxidx2 = 0;
        for(int a:map2.keySet()) if (map2.get(a)>max2) {max2=map2.get(a);maxidx2=a;}

        if (maxidx1!=maxidx2) {System.out.println(n-max1-max2);return;}

        int secmax1 = 0;
        int secmaxidx1 = 0;
        for(int a:map1.keySet()) {if (a==maxidx1) continue; if (map1.get(a)>secmax1) {secmax1=map1.get(a);secmaxidx1=a;}}

        int secmax2 = 0;
        int secmaxidx2 = 0;
        for(int a:map2.keySet()) {if (a==maxidx2) continue; if (map2.get(a)>secmax2) {secmax2=map2.get(a);secmaxidx2=a;}}
        System.out.println(Math.min(n-max1-secmax2,n-max2-secmax1));
    }
}


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

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int as, ae, bs, be;
    cin >> as >> ae >> bs >> be;

    int s, e;
    s = max(as, bs);
    e = min(ae, be);

    int ans = e - s;

    cout << max(ans, 0) << endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=300001 ;
int main()
{
   fast ;
   ll k ;
   cin>>k ;
   ll ans=0 ;
   for(ll a=1;a<=k;a++)
   {
       for(ll b=1;b<=k;b++)
       {
           for(ll c=1;c<=k;c++)
           {
               ans+=__gcd(a,__gcd(b,c)) ;
           }
       }
   }
   cout<<ans ;

}



Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;
ll L[100005];

int main()
{
	int l=1;
	scanf("%d",&n);

	ll a;
	L[0]=-1;
	for(int i=0;i<n;i++){
		scanf("%lld",&a);
		*lower_bound(L+1,L+l,a) = a;
		if(a>L[l-1])l++;
	}
	printf("%d\n",l-1);
	return 0;
}



Measured memory_bytes: 3540
a,b,c = map(int, input().split())
if a <= b <= c:
 print(a, b, c)
elif a <= c < b:
 print(a, c, b)
elif b < a <= c:
 print(b, a, c)
elif b < c < a:
 print(b, c, a)
elif c < a <= b:
 print(c, a, b)
else:
 print(c, b, a)


Measured memory_bytes: 5596
while line = gets.chomp do
  if ( line == "-1 -1 -1" ) then
    exit
  end
  m, f, r = line.split(" ").map(&:to_i)
  mf = m + f
  if (m == -1 || f == -1 || mf < 30) then
    printf "F\n";
  elsif mf < 50 && r < 50 then
    printf "D\n";
  elsif mf < 65 then
    printf "C\n";
  elsif mf < 80 then
    printf "B\n";
  else
    printf "A\n";
  end
end

Measured memory_bytes: 8684
sx,sy,tx,ty=gets.split.map(&:to_i)
dx,dy=tx-sx,ty-sy
puts ?U*dy+?R*dx+?D*dy+?L*(dx+1)+?U*(dy+1)+?R*(dx+1)+?D+?R+?D*(dy+1)+?L*(dx+1)+?U

Measured memory_bytes: 1916
/**
  *  Author: dhruv_gheewala
  *  Problem: D - Not Divisible
  *  Date:   14.08.2020
  *  Time:   11:31:04
**/

#if __has_include("debug.h")
    #include "debug.h"
#else
    #include<bits/stdc++.h>
    using namespace std;
    
    #define fundri 108
    #define debug(...) 1729
#endif

#define int int64_t
typedef pair<int, int> pii;
typedef vector<int> vi;

const bool testcases = false;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(), s.end()

// if vector isn't soted then it will remove consecutive same elements
#define make_unique(vec) vec.erase(unique(all(vec)), vec.end())
#define test int TC = 1;if(testcases)cin >> TC;for(int tc = 1 ; tc <= TC ; tc++)solve(), fundri
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})
// clears stdin
#define flush(ch) cin.ignore(std::numeric_limits<std::streamsize>::max(), ch) // default, EOF

int seed; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

inline bool in_range(int a, int l, int r) {return (a >= l && a <= r);}
template<typename H, typename ...T>void inp(H &head) {cin >> head;}
template<typename H, typename ...T>void inp(H &head, T &...tail) {cin >> head;inp(tail...);}
template<typename T>bool isPrime(T n) {for(T i = 2; i * i <= n; i++)if(n % i == 0)return false; return n >= 2;}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(T &x : a)in >> x; return in;}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.ff >> a.ss; return in;}

void solve();
void fast_io();

int32_t main(int32_t argc, char **argv)
{
    fast_io();
    test;
    return 0;
}

const int mxn = 1e6 + 5;
vi freq(mxn, 0);
void solve()
{
    int n;
    cin >> n;
    vi a(n);
    cin >> a;

    for(int i = 0 ; i < n ; i++)
        freq[a[i]]++;

    set<int> s;
    for(int i = 0 ; i < n ; i++)
        s.insert(a[i]);

    int ans = 0;
    while(!s.empty()) {
        int fir = *s.begin();
        s.erase(s.begin());
        ans += (freq[fir] == 1);

        for(int i = fir ; i < mxn ; i += fir) {
            if(s.count(i))
                s.erase(i);
        }
    }

    cout << ans << endl;
}

void fast_io()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

Measured memory_bytes: 21880
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;

using mp = pair<LL, LL>; // my pair

int main() {
  LL n, m;
  cin >> n >> m;
  
  vector<mp> numbers;
  for (int i = 0; i < n; ++i) {
    LL a;
    cin >> a;
    numbers.push_back(make_pair((LL)1, a));
  }
  for (int i = 0; i < m; ++i) {
    LL b, c;
    cin >> b >> c;
    numbers.push_back(make_pair(b, c));
  }

//  cout << "DEBUG\n";
//  for (const auto& e: numbers) {
//    cout << e.first << " " << e.second << endl;
//  }

  auto comp = [](mp &lhs, mp &rhs) {
    return lhs.second > rhs.second;
  };
  sort(numbers.begin(), numbers.end(), comp); // kojun sort

//  cout << "DEBUG\n";
//  for (const auto& e: numbers) {
//    cout << e.first << " " << e.second << endl;
//  }

  LL rest = n;
  LL sum = (LL)0;
  for (const auto& e: numbers) {
    if (rest <= e.first) {
      sum += rest * e.second;
      break;
    } else {
      sum += e.first * e.second;
      rest -= e.first;
    }
    //cout << "check: " << sum << endl;
  }
  cout << sum << endl;
}



Measured memory_bytes: 6384
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll X,Y;
int main() {
	cin>>X>>Y;

	ll total=0;
	while(X<=Y){
		X*=2;
		total++;
	}

	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np 
import math

x_list = np.array([])
y_list = np.array([])

n = int(input())

for i in range(n):
    x,y = map(int, input().split())
    x_list = np.append(x_list, x)
    y_list = np.append(y_list, y)

X = x_list[:, None] - x_list[None, :]
Y = y_list[:, None] - y_list[None, :]

print(np.sqrt(X ** 2 + Y ** 2).sum() / n)

Measured memory_bytes: 12600
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=2512;

int n,cnt;
char a[112],b[112],c[112];

int main()
{
    scanf("%d",&n);
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    for(int i=0;i<n;++i){
        if(a[i]==b[i] && a[i]==c[i]){

        }
        else if(a[i]==b[i] || b[i]==c[i] || a[i]==c[i]){
            ++cnt;
        }
        else{
            cnt+=2;
        }
    }
    printf("%d",cnt);
    return 0;
}


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

int main(){
  vector<int> input(2);
  for(int i=0;i<2;i++){
    cin >> input[i];
  }
  
 if((input[0]%500) <= input[1]){
   printf("Yes\n");
 }else{
   printf("No\n");
 }
}

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

int main() {
	int n,i,j,sum=0,size,fill=0,used[10005]={0},a[10005],b[10005],c[10005],d[10005],r[10005];
	vector<int> s[10005];
	cin >> n;
	size=n;
	for(i=1;i<n;i++){
		cin >> a[i] >> b[i];
		s[a[i]].push_back(b[i]);
		s[b[i]].push_back(a[i]);
	}
	for(i=1;i<=n;i++) r[i]=s[i].size();
	for(i=0;i<n;i++) {
		cin >> c[i];
		sum+=c[i];
	}
	sort(c,c+n);
	cout << sum-c[n-1] << endl;
	while(1){
		if(size==1){
			for(i=1;i<=n;i++){
				if(used[i]==0){
					d[i]=c[n-1];
					break;
				}
			}
			break;
		}
		for(i=1;i<=n;i++){
			if(r[i]==1){
				used[i]=1;
				size=size-1;
				r[i]=1000000;
				for(j=0;j<s[i].size();j++){
					if(used[s[i][j]]==0){
						r[s[i][j]]=r[s[i][j]]-1;
						break;
					}
				}
				d[i]=c[fill];
				fill++;
			}
		}
	}
	cout << d[1];
	for(i=2;i<=n;i++) cout << " " << d[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for (int i = 1; i * i <= m; ++i) {
		if (m % i == 0) {
			if (i <= m / n) maxs(ans, i);
			if (m / i <= m / n) maxs(ans, m / i);
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define endl <<endl
constexpr auto INF = 100000000000000;

int main()
{
	int a, b, c, d;
	in a >> b >> c >> d;
	if (a != c)
		out 1 endl;
	else
		out 0 endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();

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


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

class Program
{
    

    static void Main(string[] args)
    {
        //黒白黒白・・・
        //白黒白黒・・・
        //上記どちらか


        var tiles = Console.ReadLine();

        var sirokuro = new string((makeChars('0', tiles.Length).ToArray()));
        var kurosiro = new string((makeChars('1', tiles.Length).ToArray()));


        var dif1 = tiles.Zip(sirokuro, (c1, c2) => new { c1, c2 }).Count(x => x.c1 != x.c2);
        var dif2 = tiles.Zip(kurosiro, (c1, c2) => new { c1, c2 }).Count(x => x.c1 != x.c2);

        Console.WriteLine(Math.Min(dif1, dif2));
    }


    static IEnumerable<char> makeChars(char startChar, int count)
    {
        var ch = startChar;        

        for(int i = 0; i < count; i++)
        {
            yield return ch;

            if (ch == '0') ch = '1';
            else if (ch == '1') ch = '0';
        }
    }
    
}


Measured memory_bytes: 17376
function Main(input){
    input = input.split("\n");
    var N = [];
    var arr = input[1].split(" ").map(Number);
    for(var i=0;i<arr.length;i++){
        N.push([arr[i],i+1]);
    }
    N = N.sort(function(a,b){return a[0]-b[0]});
    var ans = "";
    for(i=0;i<N.length;i++){
        ans+=N[i][1]
        ans+=" ";
    }
   // console.log(N)
    console.log(ans.trim());
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 53612