akhauriyash/Code-Regression huggingface dataset:
n=int(input())
h=map(int,input().split())
h=list(h)
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(n-2):
  dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])

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

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
	int x, y;
	cin >> x >> y;
	int ans = 2000000000;

	if(x <= y) ans = min(ans, y - x);

	if(x <= -y) ans = min(ans, -y - x + 1);

	if(-x <= y) ans = min(ans, y + x + 1);

	if(-x <= -y) ans = min(ans, -y + x + 2);
	cout<< ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e2+7;

int n,ar[maxn];
bool vis[maxn];
int ans[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",ar+i);
    memset(vis,0,sizeof(vis));
    for(int i=n;i>=1;i--){
        int mx=0;
        for(int j=1;j<=i;j++){
            if(ar[j]==j)mx=max(mx,j);
        }
        if(mx==0){
            printf("-1\n");
            return 0;
        }
        for(int j=mx;j<i;j++)ar[j]=ar[j+1];
        ans[i]=mx;
    }
    for(int i=1;i<=n;i++){
        printf("%d\n",ans[i]);
    }
    

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















int main(){
    ll n;
    string s;
    cin >> n >> s;
    ll mn = 0, cnt = 0;
    REP(i, n){
        if(s[i] == '(') cnt++;
        else{
            cnt--;
            mn = min(mn, cnt);
        }
    }
    REP(i, -mn){
        s = '(' + s;
    }
    cnt = 0;
    REP(i, s.size()){
        if(s[i] == '(') cnt++;
        else cnt--;
    }
    REP(i, cnt){
        s += ')';
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int l, r, d;
	cin >> l >> r >> d;

	int cnt = 0;
	for (int i = l; i <= r; ++i) if (i % d == 0) ++cnt;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <string.h>

int main (void) {
    char deck[201];
    char sub_deck[201];
    int m, h;

    for (;;) {
        scanf ("%s", deck);
        if (strcmp (deck, "-")==0) break;
        scanf ("%d", &m);
        for (int i=0; i<m; i++) {
            scanf ("%d", &h);
            strcpy (sub_deck, deck+h);
            strncat (sub_deck, deck, h);
            strcpy (deck, sub_deck);
        }
        printf ("%s\n", deck);
    }
    
    return 0;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
vector<ll> enum_div(ll n){//nの約数を列挙
    vector<ll> res;
    for (ll i = 1LL; i*i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            ll j = n / i;
            if (j != i) res.push_back(j);
        }
    }
    sort(res.begin(), res.end());
    return res;
}
int main() {
  int n,m; cin >> n >> m;
  
  vector<ll> v = enum_div(m);
  
  ll ans = 0;
  for(auto v1:v){
    if((ll)v1*n <= m) chmax(ans,v1);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    float x[4], y[4];
    float slope1, slope2;
    int n;
    int i;

    scanf("%d", &n);
    while (n-- > 0){
        for (i = 0; i < 4; i++){
            scanf("%f %f", &x[i], &y[i]);
        }
        slope1 = (y[1] - y[0]) / (x[1] - x[0]);
        slope2 = (y[3] - y[2]) / (x[3] - x[2]);
        if (slope1 == slope2){
            printf("YES\n");
        }
        else {
            printf("NO\n");
        }
    }

    return (0);
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n;
    int ans = 0;
    string s;

    cin >> n >> s;
    

    for (int i = 0; i < 1000; i++) {
        string key = to_string(i);
        while (key.size() != 3) {
            key = '0' + key;
        }
        int sub = 0;
        bool flg = false;
        for (int j = 0; j < 3; j++) {
            bool flg2 = false;
            for (int k = sub; k < n; k++) {
                if (key[j] == s[k]) {
                    sub = k+1;
                    flg2 = true;
                    break;
                }
            }
            if (flg2) {
                flg = true;
            }
            else {
                flg = false;
                break;
            }
        }
        if (flg) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn solve(n: i128, a: i128, b: i128, c: i128, d: i128, mem: &mut HashMap<i128, i128>) -> i128 {
    if mem.contains_key(&n) {
        return mem[&n];
    }

    let mut res = n * d;
    res = min(
        res,
        solve((n + 4) / 5, a, b, c, d, mem) + c + (5 - (n % 5)) * d,
    );
    res = min(
        res,
        solve((n + 2) / 3, a, b, c, d, mem) + b + (3 - (n % 3)) * d,
    );
    res = min(
        res,
        solve((n + 1) / 2, a, b, c, d, mem) + a + (2 - (n % 2)) * d,
    );
    if n >= 5 {
        res = min(res, solve(n / 5, a, b, c, d, mem) + c + (n % 5) * d);
    }
    if n >= 3 {
        res = min(res, solve(n / 3, a, b, c, d, mem) + b + (n % 3) * d);
    }
    if n >= 2 {
        res = min(res, solve(n / 2, a, b, c, d, mem) + a + (n % 2) * d);
    }
    mem.insert(n, res);
    mem[&n]
}

fn main() {
    let t = read::<i128>();
    for _ in 0..t {
        let v = read_vec::<i128>();
        let (n, a, b, c, d) = (v[0], v[1], v[2], v[3], v[4]);
        let mut mem = HashMap::new();
        mem.insert(0, 0);
        mem.insert(1, d);
        let ans = solve(n, a, b, c, d, &mut mem);
        println!("{}", ans);
    }
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 3084
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
ans = 10 ** 9
for i in range(n-k+1):
    if h[i+k-1] - h[i] < ans:
        ans = h[i+k-1] - h[i]
print(ans)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[]{ -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[]{ 0, 1, 1, 1, 0, -1, -1, -1 };
void run() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}

int main() {
	run();
	int n, m, k;
	cin >> n >> m >> k;
	vector<vector<char>> v(n, vector<char>(m));
	vector<vector<int>> out(n, vector<int>(m));
	vector<bool> vis(n);
	for (int i = 0; i < n; i++) for (int j = 0; j < m; j++)
		cin >> v[i][j];
	int cnt = 0;
	for (int i = 0; i < n; i++)for (int j = 0; j < m; j++)
		if (v[i][j] == '#') {
			cnt++;
			vis[i] = 1;
			for (int k = j; k >= 0 && out[i][k] == 0; k--)
				out[i][k] = cnt;
			for (int k = j + 1; k < m && out[i][k] == 0 && v[i][k] != '#'; k++)
				out[i][k] = cnt;
		}
	for (int i = 0; i < n; i++) {
		if (vis[i]) {
			for (int j = i + 1; j < n && !vis[j]; j++)
				out[j] = out[i];
			for (int j = i - 1; j >= 0 && !vis[j]; j--)
				out[j] = out[i];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			cout << out[i][j] << ' ';
		cout << endl;
	}
}

Measured memory_bytes: 1280
N = input();
A = map(int,raw_input().split(" "))
for i in range(1,len(A)):
	key = A[i]
	j = i - 1;
	for k in range(0,len(A)):
		if A[N-1] == A[k]:
			print A[k]
		else:
			print A[k],
	while j >=0 and A[j] > key:
		A[j+1] = A[j]
		j -= 1
	A[j+1] = key
for j in range(0,len(A)):
		if A[N-1] == A[j] :
			print A[j]
		else:
			print A[j],

Measured memory_bytes: 4236
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
#define inf 1e9
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que; get min
const double eps = 1.0e-10;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
//const int maxn = 3e5 + 10;
const int  maxn = 100005;
const int turn[4][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}};
const int turn2[8][2] = {{1, 0}, { -1, 0}, {0, 1}, {0, -1}, {1, -1}, { -1, -1}, {1, 1}, { -1, 1}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int ans[105][105];
int a, b;
int main()
{
        //freopen("sample.txt", "w", stdout);
        cin >> a  >> b;
        for (int i = 0; i < 50; i++)
        {
                for (int j = 0; j < 100; j++)
                {
                        ans[i][j] = 1;
                        ans[i + 50][j] = 0;
                }
        }
        a--, b--;
        for (int i = 0; i < 50 && a; i += 2)
        {
                int cur = i % 2;
                for (int j = cur; j < 100 && a; j += 2)
                {
                        ans[i][j] = 0;
                        a--;
                }
        }
        for (int i = 51; i < 100 && b; i += 2)
        {
                int cur = i % 2;
                for (int j = cur; j < 100 && b; j += 2)
                {
                        ans[i][j] = 1;
                        b--;
                }
        }
        cout << "100 100" << endl;
        for (int i = 0; i < 100; i++)
        {
                for (int j = 0; j < 100; j++)
                {
                        if (ans[i][j])
                        {
                                cout << "#";
                        }
                        else
                        {
                                cout << ".";
                        }
                }
                cout << endl;
        }
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

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

    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3632
import Data.Char
import Control.Monad

import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

main :: IO ()
main = do
  n <- readLn :: IO Int
  a <- map read . words <$> getLine :: IO [Int]

  v <- VM.replicate 100001 0 :: IO (VM.IOVector Int)

  forM_ a $ \x -> do
    VM.modify v (+1) x
  
  q <- readLn :: IO Int

  let
    f 0 ans = return ()
    f k ans = do
      [b, c] <- map read . words <$> getLine :: IO [Int]

      x <- VM.read v b
      VM.write v b 0
      VM.modify v (+x) c
    
      let ans' = ans + x * (c - b)

      print ans'
      f (k-1) ans'
      
  f q (sum a)


Measured memory_bytes: 34472
a,b,c = gets.split(" ").map{|x|x.to_i}
count = 0
yakusu = Array.new()
n = 0
for i in 1..c do
	if c % i == 0
		yakusu[n] = i
		n += 1
	end
end
for i in a..b do
	yakusu.size.times do |j|
		count += 1 if yakusu[j] == i
	end
end
puts count

Measured memory_bytes: 8688
#include<cstdio>
typedef unsigned long long ul;
using namespace std;
ul power(ul n,ul m){
  
  if(m == 0) return 1;
  ul res = 1;
  res = power(n,m/2);
  if(m%2 == 0) return res = res*res%1000000007;
  return res = (((res*res)%1000000007)*n)%1000000007;
}
int main(){
  
  int n,m;
  scanf("%d %d",&n,&m);
  printf("%llu\n",power(n,m));

  return (0);
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int a[105], n;
int main() {
    cin >> n;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) ok = false;
        }
    }
    if (ok)
        cout << "APPROVED\n";
    else
        cout << "DENIED\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;


int main(){
    string s;
    cin >> s;
    int start = -1;
    int end = 0;

    for(size_t i = 0; i < s.size(); i++)
    {
        if(s[i]=='A' && start == -1){
            start = i;
            continue;
        }
        else if(s[i]=='Z'){
            end = i;
        }
    }
    cout << end+1-start << endl;
    return 0;
}

Measured memory_bytes: 640
import numpy as np
n,m=list(map(int,input().split()))
h=list(map(int,input().split()))

flag=np.zeros(n)+1

for i in range(m):
  a,b=list(map(int,input().split()))
  if h[a-1]>h[b-1]:
    flag[b-1] = 0
  elif h[a-1]==h[b-1]:
    flag[b-1] = 0
    flag[a-1] = 0
  else:
    flag[a-1] = 0
    
ans=np.sum(flag)
print(int(ans))

Measured memory_bytes: 38656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n,v,p;
  ll m;
  cin>>n>>m>>v>>p;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  int b=0;
  int c=n-p;
  while(c>b){
    int d=(b+c)/2;
    int e=upper_bound(a,a+n,a[d]+m)-a;
    if(n-e>=p){
      b=d+1;
    }
    else{
      ll cur=0;
      rep(i,0,n-p+1){
        cur+=min(a[d]+m-a[i],m);
      }
      if(cur-m<m*(v-p)){
        b=d+1;
      }
      else{
        c=d;
      }
    }
  }
  cout<<n-b<<endl;
}

Measured memory_bytes: 1024
import fractions
import sys
#import numpy as np

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    N = int(input())
    for i in range(N):
        if i == 0:
            tmp = int(input())
        else:
            a = int(input())
            b = lcm_base(a, tmp)
            tmp = b
    if N == 1:
        print(tmp)
    else:
        print(b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5088
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
using P = pair<ll,ll>;
const ll INF = 999999999999;


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

  vector<vector<vector<bool>>> dp(30009,vector<vector<bool>>(4,vector<bool>(1009)));
  dp.at(0).at(0).at(0) = true;
  for(ll i=0;i<n;++i){
    for(ll j=0;j<=3;++j){
      for(ll k=0;k<1000;++k){
        if( !dp.at(i).at(j).at(k) ) continue;
        dp.at(i+1).at(j).at(k) = true;
        if( j <= 2 ){
          dp.at(i+1).at(j+1).at(k*10+( s.at(i)-'0' )) = true;
        }
      }
    }
  }
  ll cnt = 0;
  for(ll i=0;i<1000;++i){
    if( dp.at(n).at(3).at(i) ) ++cnt;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 25964
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
typedef complex<int> P;
typedef pair<int,int> pii;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
template <class F, class T> void convert(const F &f, T &t){	stringstream ss; ss << f; ss >> t;}


bool solve(){
	int gx, gy;
	cin>> gx>> gy;
	int n;
	cin>> n;
	vector<pii> s(n), t(n);
	for(int i=0;i<n;i++){
		int a, b, c, d;
		cin>> a>> b>> c>> d;
		if(a > c || b > d){
			swap(a,c);
			swap(b,d);
		}
		s[i].first = a;
		s[i].second = b;
		t[i].first = c;
		t[i].second = d;
	}
	
	vector<vector<ll> > a(gy+2, vector<ll>(gx+2));
	a[0][0] = 1;
	for(int i=0;i<=gy;i++){
		for(int j=0;j<=gx;j++){
			bool x = true, y = true;
			for(int k=0;k<n;k++){
				if(s[k].first == j && s[k].second == i && t[k].first == j+1) x = false;
				if(s[k].first == j && s[k].second == i && t[k].second == i+1) y = false;
			}
			if(x) a[i][j+1] += a[i][j];
			if(y) a[i+1][j] += a[i][j];
		}
	}
//	for(int i=0;i<=gy;i++){ for(int j=0;j<=gx;j++) cout<< " "<< a[i][j]; cout<< endl; }
	
	if(a[gy][gx] == 0) cout<< "Miserable Hokusai!" << endl;
	else cout<< a[gy][gx]<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed); cout.precision(10);
	
	int n;
	cin>> n;
	for(int i=0;i<n;i++) solve();
	return 0;
}

 

Measured memory_bytes: 1220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		String s = fs.next();
		int[] valArr = new int[s.length()+1];
		
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == '<') {
				valArr[i+1] = valArr[i] + 1;
			}
		}
		
		for(int i = s.length()-1; i >= 0 ; i--) {
			
			if(s.charAt(i) == '>') {
				valArr[i] = Math.max(valArr[i], valArr[i+1] + 1);
			}
		}
		
//		int minVal = s.length()+1;
//		for(int i = 0; i < s.length()+1; i++) {
//			minVal = Math.min(minVal, valArr[i]);
//		}
//		
//		int diff = 0;
//		if(minVal < 0) {
//			diff = (-1)*minVal;
//		}
		
		long ans = 0;
		for(int i = 0; i < s.length()+1; i++) {
			ans += (valArr[i]);
		}
//		System.out.println(Arrays.toString(valArr));
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

int main(){

int a, b;
  cin >> a >> b;
  
  if((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
  else cout << (a + b) / 2 + 1 << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)




int main(){

ll A,B,C;
cin>>A>>B>>C;


if(A==B&&A!=C){
    cout<<"Yes"<<endl;
    return 0;
}

if(A==C&&A!=B){
    cout<<"Yes"<<endl;
       return 0;
}

if(C==B&&A!=C){
    cout<<"Yes"<<endl;
       return 0;
}

cout<<"No"<<endl;
       return 0;




}


Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
    n  <- read <$> getLine :: IO Int
    ns <- map (\l -> (head l, length l)) . group . sort . map read . words <$> getLine :: IO [(Int, Int)]
    let can = if odd n then f True ns             && all (even . fst) ns 
                       else ns == [(i, 2)|i <- take (length ns) [1,3..]]
    print $ if not can then 0
                       else if even n then 2 |^ div n 2
                                      else 2 |^ div (n-1) 2

f _ [] = True
f nonAlready ((n, l):ns) = 
    if l == 2 then f nonAlready ns 
              else nonAlready && l == 1 && n == 0 && f False ns

fact :: Int -> Int
fact 0 = 1
fact n = n |* fact (n|-1)

modN :: Int
modN = 10^9+7
 
(|+) :: Int -> Int -> Int
(|+) n m = (`mod` modN) $ n + m 

(|-) :: Int -> Int -> Int
(|-) n m = (`mod` modN) $ n - m 

(|*) :: Int -> Int -> Int
(|*) n m = (`mod` modN) $ (n `mod` modN) * (m `mod` modN) 

(|^) :: Int -> Int -> Int
(|^) x n
  | n == 0    = 1
  | even n    = mod (x*x) modN |^ div n 2
  | otherwise = (`mod` modN) $ (x |^ (n - 1)) * x

(|/) :: Int -> Int -> Int
(|/) n m = n |* (m |^ (modN - 2))


Measured memory_bytes: 30844
N,M,k = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C=[0]
D=[0]
A.each{|a|C<<C[-1]+a}
B.each{|b|D<<D[-1]+b}
ans=0
j=M
C.each_with_index do |c,i|
    break if c>k
    while D[j]> k-c
        j-=1
    end
    ans=[ans,i+j].max
end
puts ans

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m; assert(b>=0); for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// n*m<=500よりmin(n,m)<=22
// n<=22なら全列挙、m<=22ならbitDP

int n, m, s[500][500];
string S[500];

int enu() {
	int res = 0;
	rep(b,1<<n) {
		int t[500] = {};
		rep(i,n) if (b>>i&1) rep(j,m) t[j] ^= s[i][j];
		if (accumulate(t,t+m,0)==0) chmax(res, __builtin_popcount(b));
	}
	return res;
}

int bit() {
	// dp[i][j]: i番目のレシピまでで材料の偶奇の列がjとなるような選び方の中でレシピを最も多く使うもののレシピの個数
	int dp[2][1<<m];
	memset(dp,-1,sizeof(dp));
	dp[0][0] = 0;
	rep(I,n) {
		int i = I&1, ii = 1-i, k = 0;
		rep(j,m) if (s[I][j]==1) k |= 1<<j;
		rep(j,1<<m) if (dp[i][j]!=-1) chmax(dp[ii][j], dp[i][j]), chmax(dp[ii][j^k], dp[i][j]+1);
	}
	return dp[n&1][0];
}

signed main() {
	while (1) {
		cin >> n >> m;
		if (n==0) break;
		rep(i,n) {
			cin >> S[i];
			rep(j,m) s[i][j] = (S[i][j]=='1');
		}
		cout << (n<=m ? enu() : bit()) << ln;
	}
}


Measured memory_bytes: 20608
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
 
n = ni()
INF = 1000000000+7

power = 1
for i in range(1,n+1):
  power *= i
  power = power % INF
  
print(power)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stderr, stdin, stdout, BufRead, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::{i64, u64, usize};
#[allow(unused_macros)]
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;($($r :tt ) *) =>{let mut s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;}
#[allow(unused_macros)]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .expect ("Parse error" ) } ;}
#[allow(unused_macros)]
macro_rules !dbg {($($a :expr ) ,*) =>{writeln !(&mut stderr () ,concat !($(stringify !($a ) ," = {:?}, " ) ,*) ,$($a ) ,*) .unwrap () ;} }
#[allow(non_snake_case)]
#[allow(dead_code)]
fn main() {
    input! {
        n: usize,
        p: [u64; n],
    }
    let mut min_pi = vec![0; n];
    min_pi[0] = p[0];
    for i in 1..n {
        min_pi[i] = min(p[i], min_pi[i - 1]);
    }
    let mut ans: u64 = 0;
    for i in 0..n {
        if p[i] <= min_pi[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}

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

class Program
{
	static void Main()
	{
		var s = Console.ReadLine().ToArray();
		var d = Console.ReadLine().ToArray();
		Array.Sort(s);
		Array.Sort(d, (d1, d2) => d1 < d2 ? 1 : -1);
		var min = Math.Min(s.Length, d.Length);

		var isWrite = false;
		if (s.Take(min).SequenceEqual(d.Take(min)) && s.Length < d.Length) {
			isWrite = true;
		} else {
			for (var i = 0; i < min; ++i) {
				if (s[i] < d[i]) {
					isWrite = true;
					break;
				}
			}
		}

		Console.WriteLine(isWrite ? "Yes" : "No");

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 13280
#include"bits/stdc++.h"
using namespace std;
const int N=2e5+4;
int q[N];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		q[x]=i;
	}

	int k=1;
	int cur=1;
	for(int i=2;i<=n;i++)
	{
		if(q[i]>q[i-1])cur++;
		else cur=1;
		k=max(k,cur);
	}
	cout<<n-k;

}


Measured memory_bytes: 4392
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
 
 
int main() {
    cout << fixed;
    cout << setprecision(10);
    
    auto func = [](ll i) {return (i+1)/2.0;};
 
 
    ll N, K;
    cin >> N >> K;
    vector<double> p(N);
    for (ll i=0; i<N; ++i) {
        double pi;
        cin >> pi;
        p[i] = func(pi);
    }
 
    double sum = accumulate(p.begin(), p.begin()+K, 0.0);
    double max_sum = sum;
 
 
    for (int i=0; i+K<=N; ++i) {
        sum = sum + p[i+K] - p[i];        
        if (max_sum < sum) max_sum = sum;
 
    }
    cout << max_sum << endl;
 
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int dp[101][76];

int main() {
	int n;
	cin >> n;
	int p[11];
	int ma = -1;
	int num = -1;
	rep(i, n) {
		cin >> p[i];
		if (ma < p[i]) {
			ma = p[i];
			num = i;
		}
	}
	int sum = 0;
	rep(i, n) {
		if (i == num) {
			sum += p[i] / 2;
		}
		else {
			sum += p[i];
		}
	}
	cout << sum << en;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#define ll long long
using namespace std;
int main()
{
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	while (n)
	{
		n /= k;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x = 1, y = 1, tmp;
	while (x != 0, y != 0){
		scanf("%d", &x);
		scanf("%d", &y);
		if (x > y){
			tmp = x;
			x = y;
			y = tmp;
			
		}
		if (x != 0, y != 0){
			printf("%d %d\n", x, y);
		}

	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
 
const int N=1e5+10;
vector <int> E[N];//建立N个vector,第i个vector存储与i节点相临接的结点。
int color[N],cnt[3];
 
int main(){
    //下边这句话的作用是加快c++读写速度。
	ios_base::sync_with_stdio(false);
	queue <int> que;
	int n,x,y;
	cin>>n;
	//读入数据
	for(int i=1;i<n;i++){
		cin>>x>>y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	color[1]=1;
	color[n]=2;
	que.push(1);
	que.push(n);//fennec先操作，所以先把染色为黑色的点放入队列中。
	//依次对队列中的结点根据相i邻的结点染色。
	while(!que.empty()){
		int tmp=que.front();
		que.pop();
		cnt[color[tmp]]++;
		for(int i=0;i<E[tmp].size();i++){
			int v=E[tmp][i];
			if(color[v]) continue;
			color[v]=color[tmp];
			que.push(v);
		}
	}
	//比较黑点多还是白点多，做出判断。
	if(cnt[2]>=cnt[1]) cout<<"Snuke"<<endl;
	else cout<<"Fennec"<<endl;
	return 0;
}
	

Measured memory_bytes: 6272
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
struct node *right;
struct node *left;
struct node *parent;
int key;
};

typedef struct node * Node;


Node root;


Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<(u->key)){
      u=u->left;
    }else{
      u=u->right;
    }
  }
  return u;
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  z->parent=y;

  if(y==NULL){
    root=z;
  }else if(z->key < y->key){
    y->left=z;
  }else{
    y->right=z;
  }

}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
}
  void preorder(Node u){
      printf(" ");
      printf("%d",u->key);
      if(u->left!=NIL){ 
	preorder(u->left);
      }
      if(u->right!=NIL){
	preorder(u->right);
      }
  }


  int main(){
    int n=0, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
      scanf("%s", &com[0]);
      x=0;
     if ( com[0] == 'f' ){
	scanf("%d", &x);
	Node t = treeSearch(root, x);
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      } else if ( com[0] == 'i' ){
	scanf("%d", &x);
	insert(x);
      } else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
      } 
        
      
    }

    return 0;
  }

Measured memory_bytes: 19360
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N, N_pl, sum;
  cin >> N;
  N_pl = N;
  sum = 0;

  while ( N_pl >= 1)
  {
    sum = sum + N_pl % 10;
    
    N_pl /= 10;
  }


  if (N % sum == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N;
    while (cin >> N) {
        map<int,int> seq;
        FOR(i,0,N) {
            int x; cin >> x;
            seq[x]++;
        }
        int ans = 1;
        FOR_ALL(i,seq) {
            const int k = i->first;
            const int v = i->second;
            const int dx[] = {-1,0,1};
            FOR(d,0,3) {
                int res = v;
                const int X = k+dx[d];
                if (X == 2)
                    int blah = 100;
                auto j = i; 
                if (j != seq.begin()) {
                    --j;
                    const int xx = X - (j->first);
                    if (xx <= 1)
                        res += j->second;
                    ++j;
                }
                ++j;
                if (j != seq.end()) {
                    const int xx = (j->first) - X;
                    if (xx <= 1)
                        res += j->second;
                }
                ans = max(ans,res);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

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

    sort(A, A + N);

    if (A[0] == 0) {
        cout << 0 << endl;
        return 0;
    }

    long long maxNum = 1000000000000000000;
    for (int i = 0; i < N; i++) {
        maxNum /= A[i];
        if (maxNum == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    long long ans = 1;
    for (int i = 0; i < N; i++) {
        ans *= A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4388
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var w = int.Parse(spl[0]);
        var h = int.Parse(spl[1]);
        var n = int.Parse(spl[2]);

        var x0 = 0;
        var y0 = 0;

        for(int i=0; i<n; i++) {
            spl = input.ReadLine().Split(' ');
            var x = int.Parse(spl[0]);
            var y = int.Parse(spl[1]);
            var a = int.Parse(spl[2]);

            if(a==1) x0 = Math.Max(x0, x);
            if(a==2) w = Math.Min(w, x);
            if(a==3) y0 = Math.Max(y0, y);
            if(a==4) h = Math.Min(h, y);
        }

        if(x0 > w) return 0;
        if(y0 > h) return 0;

        return (w-x0) * (h-y0);
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;



int main(int argc, char *argv[]) {

	int N,X,T; cin >> N >> X >> T;

	int ans = 0;
	while(N > 0) {
		ans += T;
		N -= X;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	ll a, b;
	cin >> a >> b;
	
	int ans = 0;
	ll g = __gcd(a, b), c = g;
	
	for(ll i = 2; i * 1ll * i <= g; i++) {
		int ok = 0;
		while(c % i == 0) {
			ok = 1;
			c /= i;
		}
		
		ans += ok;
	}
	
	if(c != 1) ans++;
	
	cout << ans + 1 << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){

    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if (a <= b){
 
        if (b <= c){

            printf("%d %d %d\n",a,b,c);
        
        } else if (a <= c){

            printf("%d %d %d\n",a,c,b);

        } else if (c <= a){

            printf("%d %d %d\n",c,a,b);

        }

    }else if (b <= a){

        if (a <= c){

            printf("%d %d %d\n",b,a,c);

        }else if (c <= b){

            printf("%d %d %d\n",c,b,a);

        }else if(c <= a){

            printf("%d %d %d\n",b,c,a);

        }

}

return 0;
    
}


Measured memory_bytes: 1932
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    //hashmapで同じ数字は数える。配列ではstack over flowする。　配列はスタックに確保されるので，大きな配列には向いていない。
    //参考；https://atcoder.jp/contests/abc159/submissions/11144830
    let n: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut count_map = HashMap::new();

    //各数字の出現数をカウント
    for i in a.iter() {
        let count = count_map.entry(i).or_insert(0);
        *count += 1;
    }

    let mut all: usize = 0;
    for (k, v) in count_map.iter() {
        all += (*v * *v - *v) / 2;
    }

    for i in a.iter() {
        let count = count_map[i];
        let index = count - 1;
        let add = (index * index - index) / 2;
        let sub = (count * count - count) / 2;
        println!("{}", all + add - sub);
    }
}


Measured memory_bytes: 17176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;

		int a,b,c=0;

		try {
			str=bfr.readLine();

			if(str.equals("")) {
				System.exit(0);
			}

			else {
				stk=new StringTokenizer(str," ");
				a=Integer.parseInt(stk.nextToken());
				b=Integer.parseInt(stk.nextToken());
				c=Integer.parseInt(stk.nextToken());

				str=bfr.readLine();

				if(str.equals("")) {
					System.exit(0);
				}

				int kaisu=Integer.parseInt(str);


				int max_coffee=Math.max(a, Math.max(b,c));
				if(a==max_coffee) {
					for(int i=0; i<kaisu; i++) {
						a*=2;
					}
				}

				else if(b==max_coffee) {
					for(int i=0; i<kaisu; i++) {
					b*=2;
					}
				}

				else if(c==max_coffee) {
					for(int i=0; i<kaisu; i++) {
						c*=2;
					}
				}
				System.out.println(a+b+c);
			}
		}catch(IOException e) {
			System.exit(0);
		}

		catch(NumberFormatException ee) {
			System.exit(0);
		}

		catch(NullPointerException eee) {
			System.exit(0);
		}
	}
}

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

using namespace std;

int main()
{
    int n,c=0;
    cin>>n;
    for(int i=1; i<=n; i++){
        int x;
        cin>>x;
        if(x!=i)
            c++;
    }
    if(c<=2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2017/01/15 20:02:20 UTC+8
File Name     :ion.cpp
*************************************** */

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

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

const LL mod=1e9+7;

int sum[1010];

int main()
{
    int n;
    cin>>n;
    for (int j=2;j<=n;++j)
    {
        int tis=j;
        int sq=sqrt(tis);
        for (int k=2;k<=sq;++k)
        {
            while (tis%k==0)
            {
                tis/=k;
                ++sum[k];
            }
        }
        ++sum[tis];
    }
    LL ans=1;
    for (int j=2;j<=1000;++j)
    {
        ans=ans*(sum[j]+1)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
vector<vector<int>> graph;
int memo[210];
ll dp[210][210];
bool bipar(int now,int c){
    if(memo[now]==0)memo[now]=c;
    else{
        if(memo[now]!=c)return false;
        else return true;
    }
    for(int i=0;i<graph[now].size();i++){
        if(!bipar(graph[now][i],-c))return false;
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
   int n;cin>>n;
   graph.resize(n);
   for(int i=0;i<n;i++)for(int j=0;j<n;j++)dp[i][j]=inf;
   for(int i=0;i<n;i++){
       string s;cin>>s;
       for(int j=0;j<n;j++){
      if(s[j]=='1'){
          dp[i][j]=1;
          graph[i].push_back(j);
      }
     }
   }
 if(!bipar(0,1)){
     cout<<-1<<endl;
     return 0;
 }
 int V=n;
        for(int k=0;k<V;k++)
                for(int i=0;i<V;i++)
                   for(int j=0;j<V;j++)
                      dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
ll ans=0;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        if(i==j)continue;
            chmax(ans,dp[i][j]);
    }
}
cout<<ans+1<<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll ans;

int main(void) {
    ll n;
    cin >> n;
    for(ll i=1; i<=n; i++) {
        if (i%3!=0 && i%5!=0) ans += i;
    }
    

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;
 
int main(void){
	
	char s[4];
	
	cin>>s;
	
	int S[4];
	
	for(int i=0;i<4;i++)
		S[i]=(int)(s[i]-48);
	
	if((S[0]*10+S[1]>=13 && (S[2]*10+S[3]<=12 && S[2]*10+S[3]>=1)) || (S[0]*10+S[1]==0 && (S[2]*10+S[3]<=12 && S[2]*10+S[3]>=1)))
		cout<<"YYMM";
	else if(((S[0]*10+S[1]<=12 && S[0]*10+S[1]>=1) && S[2]*10+S[3]>=13) ||((S[0]*10+S[1]<=12 && S[0]*10+S[1]>=1) && S[2]*10+S[3]==0))
		cout<<"MMYY";
	else if((S[0]*10+S[1]<=12 && S[0]*10+S[1]>=1) && (S[2]*10+S[3]<=12 && S[2]*10+S[3]>=1))
		cout<<"AMBIGUOUS";
	else
		cout<<"NA";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n){
    cin>>v[i];
    v[i]%=2;
  }
  for(int i=0;i<n-1;i++){
    v[i+1]+=v[i];
  }
  if(v[n-1]%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 1024