akhauriyash/Code-Regression huggingface dataset:
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='?')
        s[i]='D';
    }
    cout<<s;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int S = sc.nextInt();
		int A[] = new int[N];
		for(int i = 0 ; i < A.length ; ++i){
			A[i] = sc.nextInt();			
		}
		long MOD = 998244353;
		long result = 0;
		long memo[] = new long[S + 1];
		memo[0] = 1;
		long r2 = 0;
		for(int R = 0 ; R < N ; ++R){
			int a = A[R];
			long next[] = new long[S + 1];
			for(int i = 0 ; i <= S ; ++i){
				if(i == a){
					next[i] = memo[i] + (R + 1);
				}else if(i > a){
					next[i] = memo[i - a] + memo[i];
				}else{
					next[i] = memo[i];					
				}
			}
			for(int i = 0 ; i <= S ; ++i){
				next[i] = next[i] % MOD;
			}
			memo = next;
			r2 = (r2 + memo[S]) % MOD;
		}
		System.out.println(r2);
	}
}


Measured memory_bytes: 45928
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;

int fa[N], size[N], ans[N];

int Find(int x) {
	return x == fa[x] ? x : fa[x] = Find(fa[x]);
}

void Union(int x, int y) {
	int fa_x = Find(x);
	int fa_y = Find(y);
	if (fa_x != fa_y) {
		fa[fa_y] = fa_x;
		size[fa_x] += size[fa_y];
	}
}

void Init() {
	iota(fa, fa + N, 0);
	fill(size, size + N, 1);
}

int main() { 
	Init();
	int n, m, k; cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		Union(x, y);
		++ans[x], ++ans[y];
	}
	for (int i = 0; i < k; i++) {
		int x, y; cin >> x >> y;
		if (Find(x) == Find(y))
			++ans[x], ++ans[y];
	}
	for (int i = 1; i <= n; i++)
		cout << size[Find(i)] - ans[i] - 1 << ' ';
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[11],s1[11]={'\0'};
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
        if(s[i]=='B')
            s1[strlen(s1)-1]='\0';
        else
            s1[strlen(s1)]=s[i];
    }
    printf("%s\n",s1);
}


Measured memory_bytes: 128
//
// Created by aqib on 4/1/20.
//

#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"

using namespace std;

int main() {
    fastIO;
    int N, M;
    cin >> N >> M;
    long waCnt[100001] = {0};
    bool ac[100001];
    memset(ac, false, sizeof(ac));
    long long WAs = 0, ACs = 0;
    for (int i = 0; i < M; i++) {
        int serial;
        string res;
        cin >> serial;
        cin >> res;
        if (res == "AC" && !ac[serial]) {
            ac[serial] = true;
            ACs++;
            WAs += waCnt[serial];
        } else if (res == "WA" && !ac[serial]) {
            waCnt[serial]++;
        }
    }
    cout << ACs << " " << WAs << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=3000;
int n;
double p[MAX_N]; 
double dp[MAX_N][MAX_N];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(j>=1)dp[i][j]+=dp[i-1][j-1]*p[i];
			dp[i][j]+=dp[i-1][j]*(1-p[i]);
		}
	}
	double ans=0;
	for(int i=0;i<=n;i++)
	{
		if(i>n-i)ans+=dp[n][i]; 
	}
	printf("%.10lf",ans);
	return 0;
}


Measured memory_bytes: 70528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.regex.Pattern;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int[] line = Pattern.compile(" ").splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();
        int n = line[0];
        int k = line[1];

        if (k == 1) {
            stdout.println(0);
            return ;
        }

        int min = 1;
        int max = n - (k - 1);
        stdout.println(max - min);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


Measured memory_bytes: 26580
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    flg=0
    for i in range(n//7+1):
        if (n-i*7)%4==0:
            flg=1
    if flg==1:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        S: [String; N],
    }

    let mut A = vec![];
    for s in &S {
        let (mut cum, mut mi): (i64, i64) = (0, 0);
        for t in s.chars() {
            if t == '(' {
                cum += 1;
            } else {
                cum -= 1;
            }
            mi = min(mi, cum);
        }
        A.push((-mi, cum - mi));
    }

    let mut P: Vec<(i64, i64)> = A.iter().filter(|(l, r)| *l <= *r).cloned().collect();
    let mut N: Vec<(i64, i64)> = A.iter().filter(|(l, r)| *l > *r).cloned().collect();

    P.sort_by(|l, r| l.0.cmp(&r.0));
    N.sort_by(|l, r| l.1.cmp(&r.1));
    N.reverse();

    let mut M: i64 = 0;

    for (l, r) in &P {
        M -= l;
        if M < 0 {
            println!("No");
            return;
        }
        M += r;
    }
    for (l, r) in &N {
        M -= l;
        if M < 0 {
            println!("No");
            return;
        }
        M += r;
    }

    if M == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

#define N 100

int pr,stack[1000];

void push(int a){
  stack[++pr]=a;
}

int pop(){
  pr--;
  return stack[pr+1];
}

int main(){
  int x,y;
  char ary[N];
  pr=0;
  while(scanf("%s",ary)!=EOF){
    if(ary[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(ary[0]=='-'){
      y=pop();
      x=pop();
      push(x-y);
    }
    else if(ary[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else{
      push(atoi(ary));
    }
  }
  printf("%d\n",pop());
  return 0;
}
  



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int a, b;
    cin >> a >> b;
    if (b == 1){
        cout << 0 << endl;
        return 0;
    }
    b = max(0, b - a);
    int ans = 1;
    if (b != 0){
        a--;
        ans += (b + (a - 1)) / a;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, l, n) for(int i=(l); i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    vector<int> count(N);
    int ans = 0;

    rep(i, 0, N) cin >> h[i];

    for (int i=N-1; i>=0; i--){
        if (i == N-1) count[i] = 0;
        else {
            if (h[i] >= h[i+1]) {
                count[i] = count[i+1] + 1;
                if (ans < count[i]) {
                    ans = count[i];
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}



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

class Dice{
private:
  int tmp;
public:
  int q[6];
  void roll(char d){
    if(d=='N'){
      tmp = q[4];
      q[4] = q[0];
      q[0] = q[1];
      q[1] = q[5];
      q[5] = tmp;
    } else if(d=='E'){
      tmp = q[2];
      q[2] = q[0];
      q[0] = q[3];
      q[3] = q[5];
      q[5] = tmp;
    } else if(d=='W'){
      tmp = q[3];
      q[3] = q[0];
      q[0] = q[2];
      q[2] = q[5];
      q[5] = tmp;
    } else if(d=='S'){
      tmp = q[1];
      q[1] = q[0];
      q[0] = q[4];
      q[4] = q[5];
      q[5] = tmp;
    }
  }
};


int main(){
  Dice d;
  for(int i=0; i<6; i++){
    cin >> d.q[i];
  }
  int n;
  int a, b;
  int r;
  int ans;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a >> b;
    for(int i=0; i<=6;i++){
      //cout << "a";
      if(i==5){
        d.roll('E');
      } else if(i==6) {
        d.roll('E');
        d.roll('E');
      } else d.roll('N');
      //cout << d.q[0] << " " << d.q[1] << endl;
      if(d.q[0]==a)break;
    }
    for(int i=0; i<=4;i++){
      //cout << "b";
      d.roll('E');
      d.roll('N');
      d.roll('W');
      //cout << d.q[0] << " " << d.q[1] << endl;
      if(d.q[0]==a&&d.q[1]==b)break;
    }
    cout << d.q[2] << endl;
    //cout << ans << endl;
  }
}



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

const int INF = 1 << 30;

int main(){
	int n;
	scanf("%d", &n);
	int ans = INF;
	for(int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		int cnt = 0;
		while(a % 2 == 0) {
			cnt++;
			a /= 2;
		}
		ans = min(ans, cnt);
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq

MOD = 10**9+7

N = int(input())
r = math.ceil(math.sqrt(N))

ans = N-1
for i in range(1,r+1):
    if(N%i==0):
        q = N//i
        ans = min(ans, i+q-2)

print(ans)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (a, b) = readInputLine().split(" ").map{it.toInt()}
    
    if (a % 2 != b % 2) {
        println("IMPOSSIBLE")
        return
    }
    
    println((a + b) / 2)
}

fun readInputLine(): String {
    return readLine()!!
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int k,a,b;

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

    cin>>k>>a>>b;
    for (int i=a; i<=b; i++) {
	if (i%k==0) out("OK");
    }
    out("NG");
  

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int a[5], b[5];

int main(){
  int ans = 0;
  REP(i, 5) {
    cin >> a[i];
    if(a[i] % 10 == 0) b[i] = 10;
    else b[i] = a[i] % 10;
  }

  sort(b, b + 5);

  REP(i, 5) {
    if(a[i] % 10 != 0) a[i] = (a[i] / 10 + 1) * 10;
    ans += a[i];
  }

  ans -= 10 - b[0];
  
  cout << ans << endl;

  return 0;
}


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

using namespace std;

static const int kModulo = 1000 * 1000 * 1000 + 7;

class Tree {
  public:
    Tree(int size): m_edges(size) {}

    void add_edge(int x, int y) {
        m_edges[x].push_back(y);
        m_edges[y].push_back(x);
    }

    int count_independent_sets() const {
        auto answer = dfs(0);
        return (answer.first + answer.second) % kModulo;
    }

  private:
    pair<int, int> dfs(int node, int father = -1) const {
        int pick = 1, no_pick = 1;
        for (auto &x : m_edges[node]) {
            if (x == father)
                continue;

            int son_pick, son_no_pick;
            tie(son_pick, son_no_pick) = dfs(x, node);
            pick = (1LL * pick * son_no_pick) % kModulo;
            no_pick = (1LL * no_pick * (son_pick + son_no_pick)) % kModulo;
        }
        return {pick, no_pick};
    }

    vector< vector<int> > m_edges;
};

int main() {
    ios::sync_with_stdio(false);

    int N; cin >> N;

    Tree T(N);
    for (int i = 1; i < N; ++i) {
        int x, y; cin >> x >> y;
        T.add_edge(x - 1, y - 1);
    }

    cout << T.count_independent_sets() << "\n";
}


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

int main() {
    int n;
    cin >> n;
    vector<int> t(n + 1), x(n + 1), y(n + 1);
    t[0] = x[0] = y[0] = 0;
    REP(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    string ans = "Yes";
    REP(i, n) {
        int distance = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        int time = t[i + 1] - t[i];
        if(distance == 0) {
            if(time % 2 > 0) ans = "No";
        } else if(time % distance > 0)
            ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
//Chandigarh University
//author:- shivamkr21
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
    lli n,q,l,r,tp=0;
    string s;
    cin>>n>>q>>s;
    lli ar[n];
    for(lli i=0;i<n-1;i++)
    {
        if(s[i]=='A' && s[i+1]=='C')
        {
            tp++;
        }
        ar[i]=tp;
    }
    ar[n-1]=tp;
    lli sum=0;
    while(q--)
    {
        cin>>l>>r;
        l--;
        r=r-2;
        sum=ar[r]-ar[l];
        if(s[l]=='A' && s[l+1]=='C')
        {
            sum++;
        }
        cout<<sum<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1792
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int a;
	int b;
	int k;
	cin >> a >> b >> k;

	vector<int> v;

	// odd numbers
	for (int i = 1; (i <= a && i <= b); i++) {
		if (a % i == 0 && b % i == 0) {
			v.push_back(i);
		}
	}
	sort(v.begin(), v.end(), greater<int>());

	int vsize = v.size();
	int ans = v.at(k - 1);

	cout << ans << endl;
	return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー


Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int h,w;
vector<string> field(1000);
vector<vector<int>> used(1000, vector<int>(1000, 0)); 

int to_black(int di_start, int d, vector<Pii> blacks) {
    for(Pii p: blacks) {
        used[p.first][p.second] = 1;
    }
    for(int di=0;di<d;++di) {
        vector<Pii> new_blacks;
        
        for(Pii p: blacks) {
            int i = p.first, j = p.second;
            for(int k=0;k<4;++k) {
                int ii = i + dyx[k][0];
                int jj = j + dyx[k][1];
                if(ii >= 0 && jj >= 0 && ii < h && jj < w && !used[ii][jj] && field[ii][jj] == '.') {
                    new_blacks.emplace_back(ii, jj);
                    used[ii][jj] = 1;
                }
            }
        }
        if(new_blacks.empty()) return di;
        swap(blacks, new_blacks);
    }
    return 2000;
}

int main() {
    cin >> h >> w;
    for(int i=0;i<h;++i) cin >> field[i];

    vector<Pii> blacks;
    for(int i=0;i<h;++i) {
        for(int j=0;j<w;++j) {
            if(field[i][j] == '#') {
                blacks.emplace_back(i, j);
            }
        }
    }

    cout << to_black(0, 2000, blacks) << endl;
    return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int k, x;
    cin >> k >> x;
    if(500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
/**
 * @author khokharnikunj8
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class DCaracalVsMonster {
public:
    long long findIt(long long n) {
        if (n == 1) return 1;
        return 2 * findIt(n / 2) + 1;
    }

    void solve(std::istream &in, std::ostream &out) {
        long long h;
        in >> h;
        out << findIt(h) << "\n";
    }
};


int main() {
    DCaracalVsMonster solver;
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

#define Emax 500001
#define Vmax 100001
#define Dmax 1<<31

using namespace std;

typedef unsigned int uint;

struct Edge {
  int to, cost;
};

vector<Edge> edges[Vmax];
static uint d[Vmax + 1];
static int Vnum, Enum, r;
static bool visited[Vmax];

void dijkstra() {
  fill_n(d, Vnum + 1, Dmax);
  fill_n(visited, Vnum, false);
  d[r] = 0;
  for (int i = 0; i < Vnum; i++) {
    int u = Vnum;
    for (int j = 0; j < Vnum; j++) {
      if (!visited[j] && d[j] < d[u]) {
        u = j;
      }
    }
    if (u == Vnum) {
      break;
    }
    visited[u] = true;
    for (int j = 0; j < edges[u].size(); j++) {
      auto v = edges[u][j];
      d[v.to] = min(d[v.to], d[u] + v.cost);
    }
  }
}

void dijkstra_priority_queue() {
  auto c = [](int a, int b) {
    return d[a] > d[b];
  };
  priority_queue<int, vector<int>, decltype(c)> Q(c);

  fill_n(d, Vnum, Dmax);
  d[r] = 0;
  for (int i = 0; i < Vnum; i++) {
    Q.push(i);
  }
  while (!Q.empty()) {
    int u = Q.top();
    Q.pop();
    for (int i = 0; i < edges[u].size(); i++) {
      auto v = edges[u][i];
      auto alt = d[u] + v.cost;
      if (d[v.to] > alt) {
        d[v.to] = alt;
        Q.push(v.to);
      }
    }
  }
}

int main(int ac, char **av) {
  scanf("%d %d %d", &Vnum, &Enum, &r);

  for (int i = 0; i < Enum; i++) {
    int s, t, d;
    scanf("%d %d %d", &s, &t, &d);
    Edge e;
    e.to = t;
    e.cost = d;
    edges[s].push_back(e);
  }

  dijkstra_priority_queue();

  for (int i = 0; i < Vnum; i++) {
    if (d[i] == Dmax) {
      printf("INF\n");
    } else {
      printf("%d\n", d[i]);
    }
  }
  return 0;
}



Measured memory_bytes: 12604
#import<bits/stdc++.h>
using namespace std;typedef
long long ll;ll N,d[1<<20]
[2],i,a,c
;ll t(int
b){return
((b-3>=0)
?d[b-3][1]
+N-b+1:N-1+810-810)%int(1e9+7)
;}main(){;;scanf("%lld",&N);a=
c=(N-1)*(N-1)%1000000007;"MM";
d[0][0]=N;d[0][1]=N;;for(i=1;i
<=N;++i){*d[i]=(*d[i-1]+c+t(i)
)%int(1e9+7)
;d[i][1]=(
d[i-1][1]+
*d[i])%int(
1e9+7);}cout
<<*d[N - 1]
<<endl;}


Measured memory_bytes: 16640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
#include <iomanip>
using namespace std;
// type alias
typedef long long LL;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))

// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');

// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpf(args...) if(TRACE) { fprintf(stderr, ##args); putchar('\n'); }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
template<class Iter> void dumpc(Iter begin, Iter end) { if (TRACE) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; } }

// $ cp-batch OneCardPoker | diff OneCardPoker.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address OneCardPoker.cpp && ./a.out

/*
 
 1/16/2019
 
 18:33-
 
 */

int A,B;

const string p1="Alice",p2="Bob",draw="Draw";
void solve() {
  string res=draw;
  if(A==1&&B!=1) res=p1;
  else if(B==1&&A!=1) res=p2;
  else if(A>B) res=p1;
  else if(A<B) res=p2;
  else res=draw;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;
    a -= k;
    if(a <= 0){
        k = abs(a);
        a = 0;
        b -= k;
        if(b <= 0) b = 0;
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
int main(){
    char str1[1000]={},str2[1000]={};
    int c1=0,c2=0,n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %s",str1,str2);
        if(strcmp(str1,str2)==0){
            c1++;
            c2++;
        }else if(strcmp(str1,str2)>0){
            c1 += 3;
        }else {
            c2 += 3;
        }
    }
    printf("%d %d\n",c1,c2);

}


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

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner input = new Scanner(System.in);
        int N;
        
        while (true){
            N = input.nextInt();//入力
            
            if (N == 0) break; //0000の時終了
            
            if (N % 1111 == 0){
                //全ての桁の数が同じとき
                System.out.println("NA");
                continue;
            }
            
            int count = 0;
            
            while (N != 6174){
                int L, S;
                
                int[] num = new int[4];
                
                //Nを1文字ずつ読み込み
                for (int i = 0; i < 4; i++){
                    num[i] = N % 10;
                    N = N / 10;
                }
                
                //並べ替え
                Arrays.sort(num);
                //System.out.println(N);
                
                L = S = 0;
                for(int i = 0; i < 4; i++){
                    S = S * 10 + num[i];     //Nの桁それぞれの数値を大きい順に並べた結果取得
                    L = L * 10 + num[3 - i]; //Nの桁それぞれの数値を小さい順に並べた結果取得
                }
                //System.out.println(L);
                //System.out.println(S);
                
                N = L - S; //差 L-S を新しい N とする(1回分の操作終了)
                //System.out.println(N);
                
                count++;
            }
        System.out.println(count);
            
        }
    }
}



Measured memory_bytes: 49140
#include <iostream>
#include <vector>

using namespace std;
int main(void) {
    int N; cin >> N;
    vector<int> A(N); for (int i=0; i<N; i++) cin >> A[i];

    int count=1, d=0;
    for (int i=1; i<N; i++) {
        if (A[i]-A[i-1] == 0) continue;
        else if ((A[i]-A[i-1]) * d >= 0) d = (A[i] - A[i-1]) >= 1 ? 1 : -1;
        else {
            d = 0;
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#define min(a, b) ((a) < (b)) ? (a) : (b)
#define max(a, b) ((a) > (b)) ? (a) : (b)
int main(int argc, const char *argv[])
{
  int n, a, b;
  scanf("%d%d%d", &n, &a, &b);
  printf("%d\n", min(n*a, b));
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  unordered_map<string,int> res;
  res["AC"]=0;
  res["WA"]=0;
  res["TLE"]=0;
  res["RE"]=0;
  string tmp;
  for (int i=0; i<N; i++) {
    cin >> tmp;
    res.at(tmp)++;
  }
  cout << "AC x " << res.at("AC") << endl;
  cout << "WA x " << res.at("WA") << endl;
  cout << "TLE x " << res.at("TLE") << endl;
  cout << "RE x " << res.at("RE") << endl;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <vector>
using namespace std;
 
const int N = 3e5 + 7;
 
int L[N];
 
int n;
 
struct item {
    bool zero;
    int x;
};
 
bool can(int al) {
    vector<item> st = {{true, L[0]}};
    for (int i = 1; i < n; i++) {
        if (L[i] > L[i - 1]) {
            st.emplace_back(item {true, L[i] - L[i - 1]});
        } else if (al == 1) {
            return false;
        } else {
            int cur = L[i - 1];
            while (cur > L[i]) {
                if (!st.back().zero) {
                    st.pop_back();
                    --cur;
                } else {
                    int dec = min(st.back().x, cur - L[i]);
                    st.back().x -= dec;
                    cur -= dec;
                    if (st.back().x == 0) {
                        st.pop_back();
                    } else {
                        break;
                    }
                }
            }
            for (int i = (int)st.size() - 1; i >= -1; i--) {
                if (i == -1) {
                    return false;
                }
                if (st[i].zero) {
                    st[i].x--;
                    st.insert(st.begin() + i + 1, item {false, 1});
                    if (st[i].x == 0) {
                        st.erase(st.begin() + i);
                    }
                    break;
                } else if (st[i].x + 1 == al) {
                    st[i].x = 0;
                } else {
                    st[i].x++;
                    break;
                }
            }
        }
    }
    return true;
}
 
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &L[i]);
    }
    int lo = 0, hi = n;
    while (lo + 1 < hi) {
        int mid = (lo + hi) / 2;
        if (can(mid)) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    printf("%d\n", hi);
}

Measured memory_bytes: 4660
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

const int N = 1e5 + 10;

int n, m, p[N], tar[N], sta[N], top, vis[N];

ll k, a[N], ans[N];

int main() {
    scanf("%d", &n);
    for(int i = 1 ; i <= n ; ++ i) {
        scanf("%lld", &a[i]);
        p[i] = i;
    }
    for(int i = n ; i ; -- i) {
        a[i] -= a[i - 1];
    }
    scanf("%d%lld", &m, &k);
    for(int i = 1 ; i <= m ; ++ i) {
        int x; scanf("%d", &x);
        swap(p[x], p[x + 1]);
    }

    for(int i = 1 ; i <= n ; ++ i) {
        if(vis[i]) continue;
        top = 0;
        sta[top ++] = i;
        int cur = p[i];
        while(cur != i) {
            vis[cur] = 1;
            sta[top ++] = cur;
            cur = p[cur];
        }
        for(int j = 0 ; j < top ; ++ j) {
            tar[sta[j]] = sta[(j + k) % top];
        }
    }

    for(int i = 1 ; i <= n ; ++ i) {
        ans[i] = a[tar[i]] + ans[i - 1];
        printf("%lld.0\n", ans[i]);
    }
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

vector<pair<long, int>> v;
int main() {
	int N, M; cin >> N >> M;
	for(int i=0; i<N; ++i){
	    long A;
	    int B;
	    cin >> A >> B;
	    v.push_back(make_pair(A, B));
	}
	sort(v.begin(), v.end());
	long ans=0;
	int res=M;
	for(int i=0; res>0; ++i){
	    ans += v[i].first*min(v[i].second, res);
	    res -= min(v[i].second, res);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3444
#include<stdio.h>
int main() {
   int n,a,b;
   scanf("%d%d%d", &n, &a, &b);
   int r = 0;
   for(int i=1; i<=n; i++) {
      int c = 0, t = i;
      for(int j=0; j<5; j++) c+=t%10, t/=10;
      if (a<=c && c<=b) r+=i;
   }
   printf("%d\n", r);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    int s[N];
    int total = 0;
    REP(0, i, N) {
        cin >> s[i];
        total += s[i];
    }

    sort(s, s + N);

    if (total % 10 == 0) {
        REP(0, i, N) {
            if (s[i] % 10 != 0) {
                total -= s[i];
                break;
            }
        }
    }

    if (total % 10 == 0) {
        total = 0;
    }

    cout << total << endl;

    return 0;
}


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


int main() {
  ll n;
    cin >> n;
    string s = "";
    while(n > 0){
        n--;
        ll rem = n%26;
        s += 'a'+rem;
        n /= 26;
        //cout << n << " " << rem << nl;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}

Measured memory_bytes: 3616
#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"
#include "ctime"

using namespace std;

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

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

struct Node {
	long long int a, b;
	//Node(const int aa, const int bb) {
	//	a = a, b = bb;
	//}
	bool operator<(const Node&n)const {
		return a + b > n.a + n.b;
	}
};

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

	cin >> N >> K;
	vector<Node>v(N);
	for (auto &i : v)cin >> i.a >> i.b;
	if (K == 100) {
		cout << N << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		v[i].a *= 100 - K;
	}
	for (int i = 0; i < N; i++) {
		v[i].b *= K;
	}
	sort(v.begin(), v.end());
	long long int bsum = 0;
	for (auto i : v)bsum += i.b;
	long long int asum = 0;
	for (int i = 0; i < N; i++) {
		asum += v[i].a;
		bsum -= v[i].b;
		if (asum >= bsum) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1792
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let mut h = get!(usize);
    let mut count = 0;
    while h>0 {
        count += 1;
        h /= 2;
    }
    println!("{}", 2usize.pow(count as u32)-1);
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int a, b, k;
  cin >> a >> b >> k;

  int cnt = 0;
  for (int i = 100;; i--) {
    if (a % i == 0 && b % i == 0) cnt++;
    if (cnt == k) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		String s1 = sc.next();
		String s2 = sc.next();
		long ans;
		long mod = 1000000007;
		int mode;
		int now;
		if (s1.charAt(0) == s2.charAt(0)) {
			mode = 1;
			now = 1;
			ans = 3;
		} else {
			mode = 2;
			ans = 6;
			now = 2;
		}
		for (int i = now; i < s1.length(); i++) {
			if (s1.charAt(i) == s2.charAt(i)) {
				if (mode == 1) {
					ans *= 2;
					ans %= mod;
				} else {
					ans *= 1;
					ans %= mod;
				}
				mode = 1;
			} else {
				if (mode == 1) {
					ans *= 2;
					ans %= mod;
				} else {
					ans *= 3;
					ans %= mod;
				}
				mode = 2;
				i++;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 20948
#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}};
//priority_queue<int, vector<int>, less<int>> que;
//next_permutation
int num[5];
int main()
{
        int a, b, c;
        cin >> num[1] >> num[2] >> num[3];
        sort(num + 1, num + 4);
        int anser = 2 * num[3] - num[2] - num[1];
        if (anser % 2 == 0)
        {
                cout << anser / 2 << endl;
        }
        else
        {
                cout << (anser + 1) / 2 + 1 << endl;
        }
}


Measured memory_bytes: 256
A, B, C = map(int,input().split())

K = int(input())

flag = False

for i in range(0, K+1):
    for j in range(0, K+1):
        for k in range(0, K+1):
            x = A * 2**i
            y = B * 2**j
            z = C * 2**k
            # print(x, y, z)

            if x < y < z and i + j + k <= K:
                flag = True


if flag == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
long long a[200005],s[200005],x[200005],tot;
int main()
{	
	int n,i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x[i];
		a[x[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		s[i]=(long long)a[i]*(a[i]-1)/2;
		tot+=s[i];
	}
	for(i=1;i<=n;i++)
		if(a[x[i]]-2>=0)
			cout<<tot-(long long)s[x[i]]+(long long)(a[x[i]]-1)*(a[x[i]]-2)/2<<endl;
		else
			cout<<tot-s[x[i]]<<endl;
			//cout<<tot<<endl;
	return 0;
}






Measured memory_bytes: 6784
'use strict'
const Main = (input) =>{
  let xs = input.trim().split(' ').map(v=>parseInt(v,10));
  let A = xs[0];
  let B = xs[1];
  let K = xs[2];
  
  let eat_T = A - K;
  let eat_A = 0
  if(eat_T > 0){
  	eat_A = B;
  }else{
    eat_A = B - (eat_T * -1);
  }
  //console.log(eat_A)
  let ans = [];
  if(eat_T <= 0){
  	ans.push(0);
  }else{
  	ans.push(eat_T)
  }
  if(eat_A <= 0){
  	ans.push(0);
  }else{
  	ans.push(eat_A);
  }
  console.log(ans[0]+' '+ans[1]);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;

    vi arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }

    map<ll, ll> m, ind;
    for (int i = 0; i < n; i++) {
        m[arr[i]]++;
    }
    m[0] = 0;

    for (int i = n - 1; i >= 0; i--) {
        ind[arr[i]] = i;
    }

    vi ans(n, 0);
    ll curr = LLONG_MAX;
    for (auto it = m.rbegin(); it->ff != 0;) {
        curr = min(curr, ind[it->ff]);
        ll mult = it->ss;
        ll minus = it->ff;
        it++;
        minus -= it->ff;
        it->ss += mult;

        ans[curr] += mult * minus;
    }

    for (auto it : ans) {
        cout << it << "\n";
    }
}


Measured memory_bytes: 15104
n = int(input())
li = list(map(int,input().split()))
lipos = [i for i in li if i>0]
lineg = [i for i in li if i<0]
li0 = [i for i in li if i==0]
np = len(lipos)
ng = len(lineg)
n0 = len(li0)

if ng == 0:
  lipos = lipos + li0
  np = len(lipos)
  print(sum(lipos)-2*min(lipos))
  lipos.sort()
  tmp = lipos[0]
  for i in range(1,np-1):
    print("{} {}".format(tmp,lipos[i]))
    tmp -= lipos[i]
  print("{} {}".format(lipos[np-1],tmp))
elif np == 0:
  lineg = lineg + li0
  ng = len(lineg)
  print(2*max(lineg)-sum(lineg))
  lineg.sort()
  lineg.reverse()
  tmp = lineg[0]
  for i in range(1,ng):
    print("{} {}".format(tmp,lineg[i]))
    tmp -= lineg[i]
else:
  lipos = lipos + li0
  np = len(lipos)
  print(sum(list(map(abs,lineg))) + sum(lipos))
  lipos.sort()
  lineg.sort()
  lineg.reverse()
  tmp = lineg[0]
  for i in range(1,np):
    print("{} {}".format(tmp,lipos[i]))
    tmp -= lipos[i]
  print("{} {}".format(lipos[0],tmp))
  tmp = lipos[0] - tmp
  for i in range(1,ng):
    print("{} {}".format(tmp,lineg[i]))
    tmp -= lineg[i]

Measured memory_bytes: 13968
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sum = 0;
        for(int i=1;i<=9;i++)
        {
            if(num%i==0)
            {
                if(num/i<10)
                {
                    sum++;
                }
            }
        }
        if(sum==0)
        {
            System.out.println("No");
        }
        else
        {
            System.out.println("Yes");
        }
    }
}



Measured memory_bytes: 23124
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    int n, d, cnt = 0;
    cin >> n >> d;

    vector<vector<int>> x(n, vector<int>(d));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int l = 0;
            for (int k = 0; k < d; k++)
            {
                l += pow(x[j][k] - x[i][k], 2);
            }

            if (sqrt(l) == (int)sqrt(l))
                cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from operator import attrgetter
class Card:
    def __init__(self, suit, number):
        self.suit = suit
        self.number = number

def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j].number <= x.number:
            i = i + 1
            tp = A[j]
            A[j] = A[i]
            A[i] = tp
        else:
            continue
    A[r] = A[i+1]
    A[i+1] = x
    return i+1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)


def main():
    n = int(input())
    A = []
    for _ in range(n):
        suit, num = map(str, input().split())
        A.append(Card(suit, int(num))) 
    comp = sorted(A, key=attrgetter('number'))
    quickSort(A, 0, n-1)
    if A == comp:
        print('Stable')
    else:
        print('Not stable')
    for p in A:
        print(p.suit, p.number)
main()


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

int main() {
  long N, X, M;
  cin >> N >> X >> M;

  long now = 1, ans = X;
  vector<bool> used(M);
  used.at(X) = true;
  vector<long> hist {-1, X};

  while (now < N) {
    long next = X * X % M;
    if (used.at(next)) break;
    X = next, now++;
    ans += X;
    used.at(X) = true;
    hist.push_back(X);
  }

  if (now == N) return cout << ans << "\n", 0;

  long x = find(hist.begin(), hist.end(), X * X % M) - hist.begin();
  long len = now - x + 1;
  long sum = accumulate(hist.begin() + x, hist.begin() + x + len, 0L);
  long rem = N - now;

  ans += rem / len * sum;
  ans += accumulate(hist.begin() + x, hist.begin() + x + rem % len, 0L);
  cout << ans << "\n";
}

Measured memory_bytes: 3884
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner s = new Scanner(System.in);
        
        String S = s.next();
        int a = Integer.parseInt(S.substring(0,2));
        int b = Integer.parseInt(S.substring(2,4));
        
        boolean a1 = (a > 12 || a == 0) ? false : true;
        boolean b1 = (b > 12 || b == 0) ? false : true;
        
        String res = a1 ? (b1 ? "AMBIGUOUS" : "MMYY") : (b1 ? "YYMM" : "NA");
        
        System.out.println(res);

    }
}


Measured memory_bytes: 23764