akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
vector<int> fact(ll L){
  vector<int> res;
  for(int i = 2; i <= 1000000; i++){
    if(L % i == 0){
      int cnt = 0;
      while(L % i == 0){
        L /= i;
        cnt++;
      }
      res.push_back(cnt);
    }
    if(L == 1) break;
  }
  if(L != 1) res.push_back(1);
  return res;
}

int main(){
  ll L;
  while(cin >> L && L){
    if(L == 1){
      cout << 1 << endl;
      continue;
    }
    vector<int> v = fact(L);
    int dp[2] = {};
    dp[1] = v[0];
    for(int i = 1; i < v.size(); i++){
      dp[(i + 1) & 1] = dp[i & 1] * 2 * v[i] + v[i] + dp[i & 1];
    }
    cout << dp[v.size() & 1] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#[allow(unused_imports)]
use {
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::ops::*,
};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        ab: [(Usize1, Usize1); h]
    }

    let mut s = BTreeSet::<(usize, usize)>::new();
    let mut v = BTreeSet::<(usize, usize)>::new();
    for i in 0..w {
        s.insert((i, i));
        v.insert((0, i));
    }

    for (i, &(a, b)) in ab.iter().enumerate() {
        let update = s
            .range((a, 0)..(b, w))
            .map(|&(i, j)| (i, j))
            .collect::<Vec<(usize, usize)>>();
        if !update.is_empty() {
            let mut x = 0;
            for (end, start) in update {
                s.remove(&(end, start));
                v.remove(&(end - start, start));
                x = max(x, start);
            }
            if b + 1 != w {
                s.insert((b + 1, x));
                v.insert((b + 1 - x, x));
            }
        }
        if v.is_empty() {
            println!("{}", -1);
        } else {
            println!("{}", 1 + i + v.iter().next().unwrap().0);
        }
    }
}


Measured memory_bytes: 22172
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);}
  vector<int> e(N);//iからの最大移動回数
  for(int j=N-2;j>=0;j--){
    if(d.at(j)>=d.at(j+1)){e.at(j)=e.at(j+1)+1;}}
  sort(e.begin(),e.end());
  cout<<e.at(N-1)<<endl;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d %d", $n, $x);
$a = explode(' ', trim(fgets(STDIN)));

$c = 0;
for ($i = 0; $i < $n - 1; $i++) {
	$s = $a[$i] + $a[$i+1];
	if ($s <= $x) continue;
	$c += $d = $s - $x;
	if ($a[$i+1] >= $d) {
		$a[$i+1] -= $d;
	} else {
		$a[$i+1] = 0;
		$a[$i] -= $d - $a[$i+1];
	}
}
echo $c;

Measured memory_bytes: 22080
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int n, x, t, s;
    cin >> n >> x >> t;
    s = n / x;
    if(n%x!=0) s++;
    cout << t*s << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}
	if(n < k || n%k != 0){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
	return 0;
}


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

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

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

    if(k <= a) cout << a-k << " " << b << endl;
    if(a<k && k <=a+b) cout << 0 << " " << a+b-k << endl;
    if(a+b < k) cout << 0 << " " << 0 << endl;

    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int w,h,c[50][50];

void dfs(int y,int x) {
  c[y][x]=0;
  for(int dy=-1; dy<=1; dy++) {
    for(int dx=-1; dx<=1; dx++) {
      int nx=x+dx,ny=y+dy;
      if(nx>=0&&nx<w&&ny>=0&&ny<h&&c[ny][nx]==1) {
        dfs(ny,nx);
      }
    }
  }
}
int main() {
  while(cin >> w >> h) {
    if(w==0&&h==0) {
      return 0;
    }
    else {
      int ans=0;
      for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
          cin >> c[i][j];
        }
      }
      for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
          if(c[i][j]==1) {
            dfs(i,j);
            ans++;
          }
        }
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 3272
#include <cstdio>
#include <vector>

int main() {
  using namespace std;

  long long n, k;
  scanf("%lld%lld", &n, &k);
  vector<int> a(n + 1);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

  vector<int> ord(n + 1, -1);
  vector<int> pf;
  int x = 1;
  while (ord[x] == -1) {
    ord[x] = pf.size();
    pf.push_back(x);
    x = a[x];
  }

  int p = pf.size() - ord[x];

  if (k < pf.size())
    printf("%d\n", pf[k]);
  else {
    k -= pf.size();
    k %= p;
    for (int i = 0; i < k; ++i) x = a[x];
    printf("%d\n", x);
  }
}

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

using namespace std;

const int e = 2e5 + 69;

int main()
{
    ll n;
    cin >> n;
    string s;
    while(n > 0){
        int t = (n%26 + 'a' - 1);
        if(t < 97) t += 26, n-=26;
        s += char(t);
        //cout << char(t) <<"\n";
        n /= 26;
    }
    reverse(s.begin(), s.end());
    bool chk = true;
    for(int i=0; i<s.size(); i++){
        if(s[i] < 'a' || s[i] > 'z'){
            chk = false;
        }
    }
    cout << s;
}


Measured memory_bytes: 3628
N,C,K=map(int,input().split())
P=[]
for i in range(N):
    p=int(input())
    P.append(p)
    
P.sort()

ANS=1
B=1
T=P[0]
for j in range(1,N):
    if K<(P[j]-T):
        ANS+=1
        B=1
        T=P[j]
    elif B<C:
        B+=1
    elif B>=C:
        ANS+=1
        B=1
        T=P[j]

print(ANS)

Measured memory_bytes: 50904
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    vector <int> d(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> d[i];
        sum += d[i];
    }sum -= d[0];
    int ans = 0;
    for(int i=0;i<n-1;i++){
        ans += d[i]*sum;
        sum -= d[i+1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
// Your code here!
for($i=0;$i<5;$i++){
$array[$i] = trim(fgets(STDIN));
}

$k = trim(fgets(STDIN));

$cnt = 0;

for($i=0;$i<5;$i++){
    for($j=$i+1;$j<5;$j++){
        $sub = $array[$j]-$array[$i];
        if($sub > $k){
            $cnt = 1;
        }
    }
}

if($cnt == 1){
    echo ":(";
}
else{
    echo "Yay!";
}

?>

Measured memory_bytes: 4604
#include<iostream>

using namespace std;

int main() {
	long int a, b, n;
	long int ans;
	int c, d, e;
	cin >> a >> b >> n;
	if (b > n) {
		d = a * n / b;
		e = n / b;
		c = d - a * e;
		ans = c;
	}else{
		d = a * (b-1) / b;
		e = (b-1) / b;
		c = d - a * e;
		ans = c;
	}

	cout << ans << endl;
	return 0;
}

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

int main() {
	int A, B, C;

	cin >> A >> B >> C;

	if (A * C <= B) {
		cout << C << endl;
	}
	else {
		cout << B / A << endl;
	}


		 
}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  
  int dx = tx - sx, dy = ty - sy;
  for (int i = 0; i < dy; i++) {
    cout << "U";
  }
  for (int i = 0; i < dx; i++) {
    cout << "R";
  }
  
  for (int i = 0; i < dy; i++) {
    cout << "D";
  }
  for (int i = 0; i < dx+1; i++) {
    cout << "L";
  }
  
  
  for (int i = 0; i < dy + 1; i++) {
    cout << "U";
  }
  
  for (int i = 0; i < dx + 1; i++) {
    cout << "R";
  }
  cout << "DR"; 
  for (int i = 0; i < dy + 1; i++) {
    cout << "D";
  }
  
  for (int i = 0; i < dx + 1; i++) {
    cout << "L";
  }
  cout << "U" << endl;
  
}


Measured memory_bytes: 3624
N, C, K = map(int,input().split())
T = [int(input()) for i in range(N)]
# print(T)
T.sort()
# print(T)
time = T[0]
people = 0
bus = 1
for i in T:
    people += 1 #乗客を乗せようとする
    if i - time > K or people > C: #乗せられないとき
        bus += 1 
        time = i
        people = 1 #次のバスに客iを乗せる
print(bus)

Measured memory_bytes: 7384
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int MAX = 100000;
static const int NIL = -1;
using namespace std;

ll calC(ll a, ll b){

    if(a == 1) return 0;
    ll ans = 1;
    ll tmpB = b;
    ll tmpA = a;
    for(int i = 1; i <= b; i ++){
        ans *= tmpA;
        tmpA --;
    }
    for(int i = 1; i <= b; i ++){
        ans /= tmpB;
        tmpB --;
    }

    return ans;
}
int main() {
    int n; cin >> n;
    ll ans = 0;
    vector<ll> m(5);
    string s;
    rep(i,n) {
        cin >> s;
        if (s[0] == 'M') m[0]++;
        if (s[0] == 'A') m[1]++;
        if (s[0] == 'R') m[2]++;
        if (s[0] == 'C') m[3]++;
        if (s[0] == 'H') m[4]++;
    }

    ans += m[0]*m[1]*m[2];
    ans += m[0]*m[1]*m[3];
    ans += m[0]*m[1]*m[4];
    ans += m[0]*m[2]*m[3];
    ans += m[0]*m[2]*m[4];
    ans += m[0]*m[3]*m[4];
    ans += m[1]*m[2]*m[3];
    ans += m[1]*m[2]*m[4];
    ans += m[1]*m[3]*m[4];
    ans += m[2]*m[3]*m[4];

    cout << ans;

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < (ll)(r); i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = 1000000007;

int main() {
    int T; cin >> T;
    queue<ll> ans;
    while(T--) {
        int N; cin >> N;
        vector<P> lKD, rKD;
        ll mx = 0;  
        int K,L,R;
        rep(i,N) {
            cin >> K >> L >> R;

            //Lの方が高いラクダとRの方が高いラクダに分ける
            if(L-R >= 0) lKD.emplace_back(P(K, L-R));
            else rKD.emplace_back(P(N-K, R-L));
            mx += max(L,R);
        }
        //K（左端，右端からK番目以内に置きたい），LとRの差（希望通りでないときの減少量の小さい順）でソート
        sort(lKD.begin(), lKD.end());
        sort(rKD.begin(), rKD.end());

        //すでに並んでいるラクダの集合(LとRの差の小さい順)
        priority_queue<int, vector<int>, greater<int>> llaw;
        priority_queue<int, vector<int>, greater<int>> rlaw;
        int lidx = 0, ridx = 0;
        //左に並べたいラクダを順に並べていく
        rep(j,lKD.size()) {
            while(lidx < (int)lKD.size() && j+1 == lKD[lidx].first) {
                llaw.push(lKD[lidx].second);
                lidx++;
            }
            //並んでいるラクダの内，LとRの差が小さいラクダを追い出す
            while((int)llaw.size() > j+1) {
                mx -= llaw.top();
                llaw.pop();
            }
        }
        //右に並べたいラクダを順に並べていく
        //N=Kのとき，右には並べられないことに注意
        rep(j,rKD.size()+1) {
            while(ridx < (int)rKD.size() && j == rKD[ridx].first) {
                rlaw.push(rKD[ridx].second);
                ridx++;
            }
            while((int)rlaw.size() > j) {
                mx -= rlaw.top();
                rlaw.pop();
            }
        }
        ans.push(mx);
    }

    while(!ans.empty()) {
        cout << ans.front() << "\n";
        ans.pop();
    }
    return 0;
}


Measured memory_bytes: 5640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, K, A[101], dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    rep(k, 0, K + 1) {
        int lose = 0, cnt = 0;
        rep(i, 0, N) if (0 <= k - A[i]) {
            cnt++;
            if(!dp[k - A[i]]) lose++;
        }
        if (cnt == 0) dp[k] = 0;
        else if (0 < lose) dp[k] = 1;
        else dp[k] = 0;
    }

    if (dp[K]) printf("First\n");
    else printf("Second\n");
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7;

lint score[500][500], N;
bool isexist[500][500];
lint arr[250000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N * N) {
		cin >> arr[i]; arr[i]--;
	}
	REP(i, N) {
		REP(j, N) {
			score[i][j] = min(min(i, N - i - 1), min(j, N - j - 1));
			isexist[i][j] = true;
		}
	}
	lint cnt = 0;
	lint dx[4] = { 0, -1, 0, 1 }, dy[4] = { 1, 0, -1, 0 };
	REP(i, N * N) {
		lint row = arr[i] / N, col = arr[i] % N;
		cnt += score[row][col];
		queue<plint> que;
		que.push(plint(row, col));
		isexist[row][col] = false;
		while (!que.empty()) {
			plint curr = que.front(); que.pop();
			lint y = curr.first, x = curr.second;
			REP(i, 4) {
				lint nextx = x + dx[i], nexty = y + dy[i];
				if (0 <= nexty && nexty < N && 0 <= nextx && nextx < N && 
					((isexist[y][x] && score[nexty][nextx] > score[y][x] + 1) || (!isexist[y][x] && score[nexty][nextx] > score[y][x]))) {
					if (!isexist[y][x]) score[nexty][nextx] = score[y][x];
					else score[nexty][nextx] = score[y][x] + 1;
					que.push(plint(nexty, nextx));
				}
			}
		}
	}
	cout << cnt;
}


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

int findSumOfDigits(int n){
	int sum = 0;
	while(n > 0){
		sum += n%10;
		n /= 10;
	}
	return sum;
}
int main(){
	int n;
	cin >> n;
	int minimum = 1e6;
	for(int i = 1; i<n; i++){
		int sum = findSumOfDigits(i) + findSumOfDigits(n-i);
		minimum = min(sum,minimum);
	}
cout << minimum << endl;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int a,b,memo[4],one,two;

main() {
    rep(i,3) {
        cin >> a >> b;
        memo[a-1]++;
        memo[b-1]++;
    }
    rep(i,4) {
        if (memo[i] == 1) one++;
        else if (memo[i] == 2) two++;
    }
    if (one == 2 && two == 2) ct("YES")
    else ct("NO")
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N, M;
	cin >> N >> M;
	vector<int>L(M), R(M);
	rep(i, M)cin >> L[i] >> R[i];
	int left = L[0];
	int right = R[0];
	rep(i, M - 1)
	{
		left = max(L[i + 1], left);
		right = min(R[i + 1], right);
	}
	cout << max(right - left + 1, 0);
}

Measured memory_bytes: 1024
#include <stdio.h>
int Q[1010],head,tail,n,t[101][101],d[101],k[100];
void enqueue(int x){
  Q[tail++]=x;
}
int dequeue(){
  return Q[head++];
}
void bfs(int s){
  int u,v,w;
  for(v=0;v<=n;v++) d[v]=10000;
  d[s]=0;
  enqueue(s);
  while(head!=tail){
    u=dequeue();
    for(v=0;v<=n;v++){
	if(t[u][v]==1&&d[v]==10000){
	  d[v]=d[u]+1;
	  enqueue(v);
      }
    }
  }
}

main(){
  int p,i,j,s,dd,TTL,r[101],m,tt[101][101];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&r[i],&k[i]);
    for(j=0;j<k[i];j++){
      tt[r[i]][j]=10000;
      scanf("%d",&tt[r[i]][j]);
    }
  }
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
      t[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<k[i];j++){
      for(m=0;m<=n;m++){
	if(tt[r[i]][j]==m) t[r[i]][m]=1;
      }
    }
  }


  scanf("%d",&p);
  for(i=0;i<p;i++){
    scanf("%d%d%d",&s,&dd,&TTL);
    head=0;
    tail=0;
    bfs(s);

    if(d[dd]<TTL) printf("%d\n",d[dd]+1);
    else printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>b[i];

  vector<Int> r(n+1);
  for(Int i=0;i<n;i++) r[a[i]]=i;

  set<Int> s;
  for(Int i=0;i<n;i++) s.emplace(b[i]);
  if((Int)s.size()==n){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  Int p=1;
  while(s.count(p)) p++;

  cout<<"No"<<endl;
  
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i==r[p]) cout<<1;
    else cout<<i+1;
  }
  cout<<endl;
  
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    if(i==r[p]) cout<<2;
    else cout<<i+1;
  }
  cout<<endl;
  
  return 0;
}



Measured memory_bytes: 9952
#include<iostream>

using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];
    
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    
    while (1) {
        minv = INFTY;
        int u = -1;
        
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        
        if (u == -1) {
            break;
        }
        
        color[u] = BLACK;
        
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}

int main() {
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }
    
    int k, c, u, v;
    
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}



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

int main() {
	string S, ABC = "ABC";
	static long long DP[100010][4] = {};
	cin >> S;
	DP[S.size()][3] = 1;
	DP[S.size()][2] = 0;
	DP[S.size()][1] = 0;
	DP[S.size()][0] = 0;
	for (int i = S.size() - 1; i >= 0; i--) {
		for (int j = 0; j < 4; j++) {
			if (j == 3) {
				if (S[i] == '?') DP[i][3] = DP[i + 1][3] * 3;
				else DP[i][3] = DP[i + 1][3];
			}
			else {
				int m1, m2;
				if (S[i] == '?') m1 = 3;
				else m1 = 1;
				if (S[i] == ABC[j] || S[i] == '?') m2 = 1;
				else m2 = 0;
				DP[i][j] = DP[i + 1][j] * m1 + DP[i + 1][j + 1] * m2;
			}
			DP[i][j] = DP[i][j] % 1000000007;
		}
	}
	cout << DP[0][0];
}

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

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

Measured memory_bytes: 256
def add(i, x):
    i += n-1
    sg[i] += x
    while i>0:
        i = (i-1)//2
        sg[i] += x


def getSum(a, b):
    return _getSum(a, b+1, 0, 0, n)


def _getSum(a, b, k, l, r):
    if b <= l or r <= a:
        return 0

    if a <= l and r <= b:
        return sg[k]

    ll = _getSum(a, b, k*2+1, l, (r+l)/2)
    rr = _getSum(a, b, k*2+2, (r+l)/2, r)
    return ll+rr


(_n, q) = map(int, input().split())
n=1
while n <= _n:
    n*=2

sg = [0] * (2*n-1)

for i in range(q):
    (c, x, y) = map(int, input().split())
    if c:
        print(getSum(x, y))
    else:
        add(x, y)

Measured memory_bytes: 12628
#include <stdio.h>

int main()
{
    int x,y;
    for(int i=1;i++;){
        scanf("%d%d",&x,&y);
        if(x==0 && y==0)
            break;
        else if(x>=y)
            printf("%d %d\n",y,x);
        else
            printf("%d %d\n",x,y);
    }
        
    
    return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "{";
    for (int i = 0; i < v.size(); ++i) {
        if(i) os << ",";
        os << v[i];
    }
    return os << "}";
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto &&i : a) scanf("%d", &i);
    for (auto &&i : b) scanf("%d", &i);
    set<int> used;
    for (int i = 1; i <= 50; ++i) {
        used.insert(i);
    }
    {
        auto dp = make_v(51, 51, 0);
        for (int i = 0; i <= 50; ++i) {
            dp[i][i] = 1;
            for (auto &&j : used) {
                dp[i][i%j] = 1;
            }
        }
        for (int z = 0; z <= 50; ++z) {
            for (int x = 0; x <= 50; ++x) {
                for (int y = 0; y <= 50; ++y) {
                    if(dp[x][z] && dp[z][y]) dp[x][y] = 1;
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            if(!dp[a[i]][b[i]]){
                puts("-1");
                return 0;
            }
        }
    }
    for (int k = 50; k >= 1; --k) {
        auto dp = make_v(51, 51, 0);
        used.erase(k);
        for (int i = 0; i <= 50; ++i) {
            dp[i][i] = 1;
            for (auto &&j : used) {
                dp[i][i%j] = 1;
            }
        }
        for (int z = 0; z <= 50; ++z) {
            for (int x = 0; x <= 50; ++x) {
                for (int y = 0; y <= 50; ++y) {
                    if(dp[x][z] && dp[z][y]) dp[x][y] = 1;
                }
            }
        }
        for (int i = 0; i < n; ++i) {
            if(!dp[a[i]][b[i]]){
                used.insert(k);
            }
        }
    }
    ll ans = 0;
    for (auto &&i : used) {
        ans += (1LL << i);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]

flag = False
ans = 0

while flag == False :
	for i in range(len(A)):
		if A[i] % 2 == 0 :
			A[i] = A[i] // 2
		else :
			flag = True
			break
	if flag == False :
		ans += 1

print(ans)


Measured memory_bytes: 2940
N = int(input())

candidates = [True]*(2*(10**5)+1)
candidates[0] = candidates[1] = False

for i in range(2, N):
    for j in range(i, 2*(10**5)+1, i):
        candidates[j] = False

for n, n_is_prime in enumerate(candidates):
    if n_is_prime:
        print(n)
        break

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

using namespace std;

int main(void) {
  int N, cnt, i;
  string S;
  // get input -----------------------------
  cin >> N >> S;
  // count "ABC" ---------------------------
  cnt = 0;
  for(i = 0; i < N; i++) {
    if(S[i] == 'A' && (i + 2) < N) {
      if(S[i + 1] == 'B' && S[i + 2] == 'C') {
        cnt++;
        i += 2;
      }
    }
  }
  // disp answer --------------------------
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#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 n,k,v[60],t[60],s[60],c=0,ans=0;
  cin >> n >> k;
  rep(i,n)cin >> v[i];
  rep(i,min(k+1,n+1)){
    rep(j,i+1){
      rep(l,j)t[l]=v[l];
      rep(l,j){
        s[l]=t[l];
        c+=t[l];
      }
      sort(s,s+j);
      rep(l,min(k-j,j)){
        if(s[l]<0)c-=s[l];
      }
      
      ans=max(ans,c);
      c=0;
      rep(l,j){
        t[j-1-l]=v[n-1-l];
        rep(p,j){
        s[p]=t[p];
        c+=s[p];
        }
        sort(s,s+j);
        rep(p,min(k-j,j)){
        if(s[p]<0)c-=s[p];
        }
        ans=max(ans,c);
        c=0;
      }
      rep(l,j)t[l]=0;
    }
  }
  printf("%lld",ans);
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        Stack<Integer> train = new Stack<>();
        while (sc.hasNext()) {
            int num = Integer.parseInt(sc.next());

            if (num == 0) {
                System.out.println(train.pop());
            } else {
                train.push(num);
            }
        }
    }
}

Measured memory_bytes: 26088
#include<iostream>
using namespace std;
int main()
{
    long long int N,i,j=0;
    cin>>N;
    for(i=1;i<=N;i++)
    {
        if(i%3==0 || i%5==0)
        {
            j=j;
        }
        else
        {
            j=j+i;
        }
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	int n;
	string s;
	cin>>n>>s;
	for(auto ch : s)
		cout<<(char)((ch-'A'+n)%26+'A');
	return 0;
}


Measured memory_bytes: 3664
n, m = map(int, input().split())
a = [[0] * m for i in range(n)]
b = [0] * m

for i in range(n):
    list = input().split()
    for j in range(m):
        a[i][j] = int(list[j])
for j in range(m):
    b[j] = int(input())

for i in range(n):
    cij = 0
    for j in range(m):
        cij += a[i][j] * b[j]
    print(cij)




Measured memory_bytes: 6012
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int N;
	int a;
	vector<int> v;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> a;
		v.push_back(a);
	}

	sort(v.begin(), v.end());

	int ans = v.at(N - 1) - v.at(0);

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pii;
#define mk make_pair
const int N=205;
int n,a[N],b[N],nxt[N];
stack<pii> stk;
vector<int> v;
int vis[N],tot=0,pos[N],tmppos[N];
pii t[N];
int lcm=0,rest=0;

int gcd(int x,int y)
{
    if(!y) return x;
    return gcd(y,x%y);
}

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

void dfs(int u)
{
    vis[u]=1;
    stk.push(mk(u,pos[u]));
    if(!vis[nxt[u]]) dfs(nxt[u]);
}

void init()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]),pos[a[i]]=i;
    for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
    for(int i=1;i<=n;i++) nxt[a[i]]=b[a[i]];
}

void change()
{
    for(int i=1;i<=tot;i++) t[i].first=nxt[t[i].first];
}

int judge()
{
    for(int i=1;i<=tot;i++) tmppos[i]=t[i].second;
    int bl=1;
    for(int j=1;j<=tot;j++) if(t[j].first!=tmppos[j]) bl=0;
    if(bl) return 0;
    for(int i=1;i<tot;i++)
    {
        change();
        bl=1;
        for(int j=1;j<=tot;j++) if(t[j].first!=tmppos[j]) bl=0;
        if(bl) return i;
    }
    return -1;
}

void update(int &lcm,int &rest,int step,int sz)
{
    if(lcm==0)
    {
        lcm=sz; rest=step;
        return;
    }
    int delta=_abs(rest-step);
    int g=gcd(sz,lcm);
    if(delta%g!=0)
    {
        puts("-1");
        exit(0);
    }
    if(delta==0)
    {
        lcm=lcm*sz/g;
        return;
    }
    int now=rest; 
    if(now%sz==step) return;
    for(int ttt=1;ttt<=sz;ttt++)
    {
        now+=lcm;
        if(now%sz==step) 
        {
            break;
        }
    }
    //cout<<"now="<<now<<endl;
    lcm=lcm*sz/g; rest=now;
}

void solve()
{
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]) 
        {
            tot=0;
            while(!stk.empty()) stk.pop();
            dfs(i);
            while(!stk.empty()) t[++tot]=stk.top(),stk.pop(); 
            //for(int i=1;i<=tot;i++) cout<<t[i].first<<" "<<t[i].second<<endl;
            int step=judge();
            if(tot==1)
            if(step==-1)
            {
                puts("-1");
                exit(0);
            }
            update(lcm,rest,step,tot); //cout<<"OK"<<step<<" "<<tot<<endl;
        }
    }
}

signed main()
{
    init();
    solve();
    printf("%lld\n",rest);
    return 0;
}//


Measured memory_bytes: 3220
import java.math.BigInteger;
import java.util.Scanner;
import java.lang.String;



public class Main {

    public static void main(String[] args) {

        Scanner cin = new Scanner(System.in);
        int n;
        n = cin.nextInt();


       String ss = cin.next();

       char[] aa = new char[n];
       aa = ss.toCharArray();
        int cnt=0;


        for (int i = 0; i <aa.length-2 ; i++) {

            //System.out.println("ok");
            if(aa[i]=='A' && aa[i+1]=='B' && aa[i+2]=='C')
                cnt++;

        }
        System.out.println(cnt+"");

    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
//for (int i = 0; i < N; i++){}

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

    float x[N];
    string u[N];

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

    float sums = 0;
    for (int i = 0; i <N; i++){
        if(u[i] == "JPY"){
            sums += x[i];
        }else{
            sums += 380000*x[i];
        }
    }
    cout << sums << endl;
}

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

int main(){
  int n,ans=1e9,mi,ma;
  cin>>n;
  vector<int> a(n,0);
  REP(i,n){
    cin>>a.at(i);
    if(i){
      mi=min(mi,a.at(i));
      ma=max(ma,a.at(i));
    }else mi=ma=a.at(i);
  }
 
  for(int i=mi; i<=ma; i++){
    int tmp=0;
    REP(j,n) tmp+=pow(i-a.at(j),2);
    ans=min(ans,tmp);
  }
  
  cout<<ans<<endl;
}

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

int F[45];

int fib(int x)
{
	if (F[x]) return F[x];
	if (x <= 1) return F[x] = 1;
	return F[x] = fib(x - 1) + fib(x - 2);
}

int main()
{
	int x;
	scanf("%d", &x);

	printf("%d\n", fib(x));

	return 0;
}

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

int main() 
{
int n,x,y,max,min,sum;
cin>>n>>x>>y;
if(x<y)
{
	max=y;
	min=x;
}
else
{
	max=x;
	min=y;
}
if(x+y-n>0)
sum=x+y-n;
else
sum=0;
cout<<min<<" "<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
using namespace std; 
int main()
{
	vector<char> a(4);
	for (int i = 0; i < 4; i++)
	{
		cin >> a.at(i);
	}
	int p=0, q=0 ,r=0, s=0;
	for (int i = 0; i < 4; i++)
	{
		if (a[i]=='1')
		{
			p++;
		}
		if (a[i]=='9')
		{
			q++;
		}
		if (a[i]=='7')
		{
			r++;
		}
		if (a[i]=='4')
		{
			s++;
		}
	}
	if (p==1&&q==1&&r==1&&s==1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class ForwardIterator, class T>
  void iota (ForwardIterator first, ForwardIterator last, T val)
{
  while (first!=last) {
    *first = val;
    ++first;
    ++val;
  }
}
int g[11][11];
int main()
{
    int n,m,x,y,res=0;
    cin>>n>>m;
    vector<int> p(n);
    iota(p.begin(),p.end(),0);
    
    for(int i=0;i<m;i++){
        cin>>x>>y;
        g[x-1][y-1] = g[y-1][x-1] = 1;
    }
    do{
        bool flag = true;
        if(p[0])break;//視点が1の時はbreak
        for(int i=1;i<n;i++){
            if(!g[p[i-1]][p[i]])flag=false;//つながってない
        }
        if(flag)res++;
    }while(next_permutation(p.begin(),p.end()));
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> L >> R;
	R = min(R, L + 5000);
	K = MOD;
	for (long long int i = L; i <= R; i++) {
		for (int j = i+1; j <= R; j++) {
			K = min(K, (i*j) % 2019);
		}
	}
	cout << K << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) throws IOException {
		MScanner sc = new MScanner(System.in);
		//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		int a=sc.nextInt();int b=sc.nextInt();int t=sc.nextInt();
		
		pw.println((t/a)*b);
		
		pw.close();
		pw.flush();
 
	}

    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 21460
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();

        System.out.println(a.multiply(b).setScale(0, RoundingMode.DOWN));

        sc.close();
    }
}

Measured memory_bytes: 37408
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef vector<int> vi;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    vector<int> K;
    vector<vi> A;
    rep(i, N) {
        int j;
        scanf("%d", &j);
        K.pb(j);
        vector<int> Atemp;

        rep1(j, K[i]) {
            int l;
            scanf("%d", &l);
            Atemp.pb(l);
        }
        A.pb(Atemp);
    }
    /* ====================================== */
    int check[33];
    rep(i, 33) { check[i] = 0; }
    rep(i, N) {
        rep(j, K[i]) {
            check[A[i][j]]++;
        }
    }
    int ans = 0;
    rep(i, 33) {
        if (check[i] == N) {
            ans++;
        }
    }

    cout << ans;
    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll a[200010];
ll sum,t;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	t=a[0];
	for (int i=1;i<n;i++)
	{
		sum+=max(0ll,t-a[i]);
		a[i]=max(t,a[i]);
		t=max(t,a[i]);
	}
	cout <<sum;
	return 0;
}

Measured memory_bytes: 5144
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

int main(){
	
	int n;
	cin >> n;
	
	map<string, int> m;
	map<string, int>::iterator ite;
	
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		if(str[0] == 'i'){
			cin >> str;
			m[str] = 1;
		}else{
			cin >> str;
			if(m.find(str) != m.end()){
				cout << "yes" << endl;
			}else{
				cout << "no" << endl;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 36484
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<58;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int x,a,b;

int main(){
	cin>>x>>a>>b;
	int A=abs(x-a),B=abs(x-b);
	if(A<B) cout<<'A'<<endl;
	else cout<<'B'<<endl;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

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

        int min = Integer.MAX_VALUE;
        for(int i = -100; i <= 100; i++){
            int tmp = 0;
            for(int j = 0; j < N; j++){
                tmp += (a[j] - i) * (a[j] - i);
            }
            min = Math.min(min, tmp);
        }

        out.println(min);
    }
}

Measured memory_bytes: 23764
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)

// thanks! http://kujira16.hateblo.jp/entry/2017/04/09/223843

type Io struct {
    reader    *bufio.Reader
    writer    *bufio.Writer
    tokens    []string
    nextToken int
}

func NewIo() *Io {
    return &Io{
        reader: bufio.NewReader(os.Stdin),
        writer: bufio.NewWriter(os.Stdout),
    }
}

func (io *Io) Flush() {
    err := io.writer.Flush()
    if err != nil {
        panic(err)
    }
}

func (io *Io) NextLine() string {
    var buffer []byte
    for {
        line, isPrefix, err := io.reader.ReadLine()
        if err != nil {
            panic(err)
        }
        buffer = append(buffer, line...)
        if !isPrefix {
            break
        }
    }
    return string(buffer)
}

func (io *Io) Next() string {
    for io.nextToken >= len(io.tokens) {
        line := io.NextLine()
        io.tokens = strings.Fields(line)
        io.nextToken = 0
    }
    r := io.tokens[io.nextToken]
    io.nextToken++
    return r
}

func (io *Io) NextInt() int {
    i, err := strconv.Atoi(io.Next())
    if err != nil {
        panic(err)
    }
    return i
}

func (io *Io) NextFloat() float64 {
    i, err := strconv.ParseFloat(io.Next(), 64)
    if err != nil {
        panic(err)
    }
    return i
}

func (io *Io) PrintLn(a ...interface{}) {
    fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
    fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
    b := []interface{}{}
    for _, x := range a {
        b = append(b, x)
    }
    io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
    b := []interface{}{}
    for _, x := range a {
        b = append(b, x)
    }
    io.PrintLn(b...)
}

func Log(name string, value interface{}) {
    fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
    if a < b {
        return a
    }
    return b
}

func intMax(a, b int) int {
    if a > b {
        return a
    }
    return b
}
func main() {
    io := NewIo()
    defer io.Flush()

    O := io.Next()
    E := io.Next()
    for i := range E {
       io.Printf("%s%s", string(O[i]), string(E[i]));
    }
    if len(O) != len(E) {
        io.Printf("%s", string(O[len(O) - 1]));
    }
    io.Printf("\n");
}


Measured memory_bytes: 640