akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

const int MAXN=100005;
int ct[MAXN];
int N,M;

int main() {
	cin >> N >> M;
	for (int i=0; i<M; i++) {
		int a,b;
		cin >> a >> b;
		ct[a]++;
		ct[b]++;
	}

	for (int i=1; i<=N; i++) {
		if (ct[i]%2 == 1) {
			cout << "NO\n";
			return 0;
		}
	}

	cout << "YES\n";
	return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int[] a = Read.ints();
        Console.WriteLine(a[0]*a[1]%2==0?"Even":"Odd");
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }

        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13268
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    S = input()
    if S[0] == "S":
        print('Cloudy')
    elif S[0] == "C":
        print('Rainy')
    else:
        print('Sunny')




if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import sys,math
def input():
    return sys.stdin.readline()[:-1]
K = int(input())
ANS = 0

for i in range(1,K+1):
    for j in range(1,K+1):
        elm = math.gcd(i,j)
        if elm==1:
            ANS += K
            continue
        for k in range(1,K+1):
            ANS += math.gcd(elm,k)
print(ANS)

Measured memory_bytes: 69048
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int n = sc.nextInt();
    int ans = 0;
    for(int i = 0; i <= n; i++) {
      for(int j = 0; j <= n; j++) {
        if(((n - r * i - g * j) >= 0) && ((n - r * i - g * j) % b == 0)) ans++;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main( )
{	
    int n;
    cin>>n;
    
    vector<int> A(n);
    
    for( int i=0; i<n; i++ ) {
    	cin>>A[i];
    }
    int cnt = 0;
    for( int i=0; i<n; i++ ) {
    	for( int j=n-1; i<j; j-- ) {
    		if( A[j] < A[ j-1 ] ) {
    			swap( A[j], A[ j-1 ] );
    			cnt++;
    		}
    	}
    }
    for( int i=0; i<n; i++ ) {
    	cout<<A[i];
    	if( i != n-1 ) { cout<<" "; }
    }
    cout<<"\n"<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 1200
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import numpy as np
import sys
from functools import lru_cache
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


@lru_cache(maxsize=None)
def dp(i, j):
    if i == 0:
        return 0 if j == 0 else -INF
    if j == 0:
        return max(dp(i - 1, 0) + a[i-1], dp(i - 1, 1) - a[i-1])
    else:
        return max(dp(i - 1, 0) - a[i - 1], dp(i - 1, 1) + a[i - 1])


n = I()
a = LI()


def main():
    print(dp(n, 0))


if __name__ == "__main__":
    main()


Measured memory_bytes: 160544
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let n = iter.to();
    let mut words: Vec<String> = (0..n).map(|_| iter.to()).collect();
    let b0 = words.windows(2).all(|w| {
        w[0].chars().last() == w[1].chars().nth(0)
    });
    words.sort();
    let b1 = words.windows(2).all(|w| w[0] != w[1]);
    println!("{}", if b0 && b1 { "Yes" } else { "No" });
}

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

int main() {
  int x, y;
  cin >> x >> y;
  
  cout << x + y/2 << 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"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
double const pi = 3.1415926535;

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	h += m / 60;
	double wa = h * pi / 6;
	double wb = m * pi / 30;
	double x1 = a * cos(wa);
	double x2 = a * sin(wa);
	double y1 = b * cos(wb);
	double y2 = b * sin(wb);
	double x = (x1 - y1) * (x1 - y1);
	double y = (x2 - y2) * (x2 - y2);
	cout << fixed << setprecision(20);
	cout << sqrt(x + y) << endl;
	return 0;
} 

Measured memory_bytes: 4096
def ALDS1_2_B():
    """
    1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
    2   for i が 0 から N-1 まで
    3     minj = i
    4     for j が i から N-1 まで
    5       if A[j] < A[minj]
    6         minj = j
    7     A[i] と A[minj] を交換

    ＜問題＞
    数列Aを読み込み、選択ソートのアルゴリズムで昇順に並び替え出力するプログラムを作成してください。
    上の疑似コードに従いアルゴリズムを実装してください。
    疑似コード 7 行目で、i と minj が異なり実際に交換が行われた回数も出力してください。

    ＜入力＞
    入力の最初の行に、数列の長さを表す整数 N が与えられます。２行目に、N 個の整数が空白区切りで与えられます。

    ＜出力＞
    出力は 2 行からなります。１行目に整列された数列を 1 行に出力してください。
    数列の連続する要素は１つの空白で区切って出力してください。2 行目に交換回数を出力してください。

    ＜制約＞
    1 ≤ N ≤ 100
    0 ≤ A の要素 ≤ 100
    """
    N = int(input())
    A = [int(e) for e in input().split(" ")]
    switch_cnt = 0
    for i in range(N):
        min_j = i
        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j
        if i != min_j:
            A[i], A[min_j] = A[min_j], A[i]
            switch_cnt += 1
    print(" ".join(map(str, A)))
    print(switch_cnt)


def main():
    ALDS1_2_B()


if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
#include <bits/stdc++.h>
typedef long long ll;
const int inf = 1e9;
using namespace std;






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

    string s, t;
    cin >> s >> t;
    int cnt = 1e9;
    for(int i = 0; i < s.size(); i++){
        int ans = 0;
        for(int j = 0; j < t.size(); j++){
            if(i+j >= s.size()){
                ans = 1e9;
                break;
            }
            if(s[i+j] != t[j]){
                ans++;
            }
        }
        cnt = min(ans, cnt);
    }
    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	vector<vector<int>>G(V, vector<int>(V, INF));
	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}
	vector<vector<int>>dp((1 << V), vector<int>(V, INF));
	dp[(1 << V) - 1][0] = 0;
	for (int bits = (1 << V) - 1 - 1; bits >= 0; bits--) {
		rep(i, 0, V) {
			rep(j, 0, V) {
				if (!(bits&(1 << j)))
					chmin(dp[bits][i], dp[bits | (1 << j)][j] + G[i][j]);
			}
		}
	}
	cout << (dp[0][0]==INF?-1:dp[0][0]) << endl;
	return 0;
}

Measured memory_bytes: 6176
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define ft first
#define sd second
#define flag bool fl=true

#define mod 1000003
#define N 100001
#define MX 1000000001
#define MXX 1000000000000000001

#define pb push_back
#define For(i, a, b) for(int i=a;i<=b;i++)
#define T int t, qq=0; cin>>t; while(qq++<t)
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define scarr(array, size) for(int i=0;i<size;i++) cin>>array[i]

#define deg(rad) (rad*180.0)/pi
#define pi acos(-1)
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)


/*
//----------useful_functions----------

long long extended_euclid(ll a, ll b, ll &x, ll &y){//ax+by=c
    if(b==0)
    {
        x=1, y=0;
        return a;
    }

    ll x1, y1;
    ll d=extended_euclid(b, a%b, x1, y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
long long bigMod(ll a, ll b){//(a^b)%mod
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans%mod;
}
long long modInverse(ll a, ll b){//a*x=1 mod b
    ll x, y;
    ll gcd=extended_euclid(a, b, x, y);

    if(gcd==1) return ((x%b)+b)%b;
    else return 1;
}
long long nCr(ll n, ll r){//n<=1e6
    //declare globally-> ll fact[1000001];
    fact[1]=1;
    for(ll i=2;i<1000001;i++)
        fact[i]=(i*fact[i-1])%mod;

    return (fact[n]*modInverse(fact[r], mod)*modInverse(fact[n-r], mod))%mod;
}
long long josephus(ll n, ll k){//k'th person is killed out of n in the circle
    if(n==1) return 1;
    else return (josephus(n-1, k)+k-1)%n+1;
}
vector<int> sieve(ll n){//get primes up to n<=1e6 and the numbers can be handled up to 1e12
    bool fl[n+1];
    vector<int> primes;
    for(int i=0;i<=n;i++) fl[i]=false;

    for(int i=3;i*i<=n;i+=2)
        for(int j=i+i;j<=n;j+=i)
            fl[j]=true;

    primes.pb(2);
    for(int i=3;i<=n;i+=2) if(!fl[i]) primes.pb(i);
    return primes;
}

*/

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

    stack<char>s;
    while(n--)
    {
        char c;
        cin>>c;
        if(s.size()==0) s.push(c);
        else if(s.top()!=c) s.push(c);
    }
    cout<<s.size();

//        cout<<"Case "<<qq<<": ";
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace  std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define ll long long
int main(void)
{
	ll n, p, q;
	cin >> n >> p >> q;
	vec<ll> c(n);
	ll sum = 0;
	rep(i,n) {
		ll cc;
		cin >> cc;
		sum += cc;
		c[i] = p * (q - i) - cc;
	}
	sort(c.begin(), c.end());
	reverse(c.begin(), c.end());

	ll ret = sum;
	ll keep = sum;
	rep(i, n + 1) {
		ret = max(2 * p * i *  (i - 1) / 2 + keep, ret);
		keep += c[i];
	}
	cout << ret << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < n; i ++){
        if(i%2 == 0){
            Alice += a[i];
        }else{
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int l_mx = 1, r_mn = n;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l_mx = max(l_mx, l);
        r_mn = min(r_mn, r);
    }

    cout << max(0, r_mn - l_mx + 1) << endl;
}

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

int main() {
  double W, H;
  int x, y;
  cin >> W >> H >> x >> y;
  
  double ans = W*H/2;
  cout << ans << " " << (x*2 == W && y*2 == H ? 1 : 0) << endl;
}

Measured memory_bytes: 256
# 配列の中がすべて奇数になるまでの試行回数最大値を求める
N = gets.strip.to_i
arr = gets.strip.split(' ').map(&:to_i)
arr.select!{|v| v % 2 == 0}
total = 0
arr.each do |target|
  count = 0
  while target % 2 == 0
    target = target / 2
    count += 1
  end
  total += count
end

puts total


Measured memory_bytes: 2428
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<int, lli> il;
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;}

#ifdef LOCAL
#define eprintf(...) printf(__VA_ARGS__)
#else
#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
#define int long long

#define MOD (lli)(1e9 + 7)
int modmul(int a, int b) {
    return ((a %MOD) * (b % MOD)) % MOD;
}

int modpower(int x, int y) {
    if (y == 0) return 1;
    else if (y == 1) return x;
    else if (y & 1) {
        int t = modpower(x, y >> 1);
        return modmul(modmul(t, t), x);
    }
    else {
        int t = modpower(x, y >> 1);
        return modmul(t, t);
    }
}

int moddiv(int a, int b) {
    return modmul(a ,modpower(b, MOD-2));
}

int f[200010], fr[200010];
int comb(int n, int m) {
    return modmul(modmul(f[n], fr[m]), fr[n - m]);
}

signed main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    f[0] = f[1] = 1;
    for (int i = 2; i < 200010; i++) {
        f[i] = modmul(f[i - 1], i);
    }
    fr[200009] = modpower(f[200009], MOD-2);
    for (int i = 200008; i >= 0; i--) {
        fr[i] = modmul(fr[i + 1], i + 1);
    }

    int ans = 0;
    for (int i = B + 1; i <= W; i++) {
        ans = (modmul(comb((H - A) + i - 2, i - 1), comb(A + (W - i + 1) - 2, A - 1)) + ans) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
import math
import sys
N, H = list(map(int, input().split()))

A = []
B = []
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append((a, i))
    B.append((b, i))

A.sort(reverse=True)
B.sort(reverse=True)

maxA = max(A)
maxAcount = N-1
for i in range(N-1):
    if A[i] != A[i+1]:
        maxAcount = i
        break

i = 0
ans = 0
while H > 0:
    if i == N:
        ans += math.ceil(H/maxA[0])
        H = 0
    else:
        b, k = B[i]
        if b > maxA[0]:
            H -= b
            i += 1
            ans += 1
        else:
            ans += math.ceil(H/maxA[0])
            H = 0

print(ans)


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

using lint = long long;

lint n;

int main() {
    cin >> n;

    lint l = 0, r = 1e9;

    while (l+1<r) {
        lint m = (l+r)/2;
        if (m*m >= n) r = m;
        else l = m;
    }


    cout << 0 << ' ' << 0 << ' ' << r << ' ' << 1 << ' ' << (r*r-n) << ' ' << r << '\n';
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn gcd(mut a: usize, mut b: usize) -> usize {
    if a<b {
        let mut tmp = a;
        a = b;
        b = tmp;
    } 
    let mut r = a % b;
    while r!=0 {
        a = b;
        b = r;
        r = a % b;
    }
    b
}


#[fastout]
fn main() {
    input!{
        n: usize,
        init: i64,
        mut x: [i64;n],
    }

    for i in 0..n {
        x[i] = (x[i] - init).abs();
    }

    let mut ans = x[0] as usize;
    for i in 1..n {
        ans = gcd(ans, x[i] as usize);
    }

    println!("{}", ans);

}


Measured memory_bytes: 3608
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int,readline().split())
data = list(map(int,read().split()))

links = [set() for _ in range(n+1)]
it = iter(data)
for a,b in zip(it,it):
    links[a].add(b)
    links[b].add(a)

ans = [1]
done = [0] * (n+1)
done[1] = 1
now = 1
while(links[now]):
    i = links[now].pop()
    if(done[i]==1):
        continue
    done[i] = 1
    ans.append(i)
    now = i

ans = ans[::-1]
now = 1
while(links[now]):
    i = links[now].pop()
    if(done[i]==1):
        continue
    done[i] = 1
    ans.append(i)
    now = i
    
print(len(ans))
print(' '.join(map(str,ans)))

Measured memory_bytes: 123676
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<long long> right;
    vector<long long> left;
    for(int i = 0; i < n; i++){
        long long x;
        cin >> x;
        if(x >= 0){
            right.push_back(x);
        }else{
            left.push_back(abs(x));
        }
    }
    sort(right.begin(), right.end());
    sort(left.begin(), left.end());

    long long ans = 1000000000;

    for(int i = 0; i <= k; i++){//iは左側の数
        int migi_hashi = k-i;
        if(migi_hashi <= right.size() && i <= left.size()){
            if(i>0 && migi_hashi >0){
                long long ouhuku = min(left[i-1], right[migi_hashi-1]);
                long long dist = left[i-1] + right[migi_hashi-1] + ouhuku;
                ans = min(ans, dist);
            }else if(i == 0){
                long long dist = right[migi_hashi-1];
                ans = min(ans, dist);
            }else if(migi_hashi == 0){
                long long dist = left[i-1];
                ans = min(ans, dist);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1656
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    string s = "Yes";
    while(true){
        C-=B;
        if(C <= 0) break;
        A-=D;
        if(A <= 0){
            s="No";
            break;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFINITY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int M[MAX][MAX];
int n;

int prim(){
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i = 0; i < n; i ++){
        d[i] = INFINITY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1){

        // for(int i = 0; i < n; i++){ //for check
        //     printf("%d ", d[i]);
        // }

        // printf("\n");

        minv = INFINITY;
        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] != INFINITY){
                if (d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;
    for (int i = 0; i < n; i++){
        if (p[i] != -1){
            sum += M[i][p[i]];
        }
    }
    return sum;
}

int main(void){
    cin >> n;

    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            int e;
            cin >> e;
            if (e != -1){ 
                M[i][j] = e;
            }else{
                M[i][j] = INFINITY; //無限大を挿入
            }
        }
    }

    cout << prim() << endl;

    return 0;

}

/*
5
-1 2 3 1 -1
2 -1 -1 4 -1
3 -1 -1 1 1
1 4 1 -1 3
-1 -1 1 3 -1
 */


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int SolutionB()
{
    int n,k,m;
    cin>>n>>k>>m;
    int sum=0;
    for(int i=0;i<n-1;i++){
        int tmp;
        cin>>tmp;
        sum+=tmp;
    }
    int left=n*m-sum;
    if(left>k) return -1;
    else return max(0,left);
}
void SolutionD()
{
    int n,m;
    cin>>n>>m;
    vector<bool> vis(n+1,false);
    vector<int> W(n+1,0);
    int ac=0,wa=0;
    for(int i=0;i<m;i++){
        int p;
        string res;
        cin>>p>>res;
        if(vis[p]==false){
            if(res=="AC"){
                vis[p]=true;
                ac++;
                wa+=W[p];
            }
            else W[p]++;
        }
    }
    cout<<ac<<" "<<wa<<endl;
}
int main()
{
	SolutionD();
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int count=0,x=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='I'){
            x++;
            if(x>count)
            count=x;
        }
        else
        x--;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll h,n;cin>>h>>n;
    vector<ll>a(n+1),b(n+1);
    ll amax=0;
    for(ll i=1;i<=n;i++){
        cin>>a[i]>>b[i];
        chmax(amax,a[i]);
    }
    ll dp1[100001];ll ans=INF;
    for(ll i=0;i<=10000+amax;i++)dp1[i]=INF;
    dp1[0]=0;
    for(ll i=1;i<=n;i++){
        for(ll j=a[i];j<=h+10000;j++){
                if(dp1[j]>=dp1[j-a[i]]+b[i]){
                ll ncnt=j/a[i];
                    chmin(dp1[j],dp1[j-ncnt*a[i]]+b[i]*ncnt);
                }
                chmin(dp1[j],dp1[j-a[i]]+b[i]);
        }
    }
    for(ll i=h;i<=h+amax;i++)
        chmin(ans,dp1[i]);
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------









Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define fcout cout << fixed << setprecision(15)
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
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;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N);
	for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
		a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

	vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

	vector<int> oya(N, -1);

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
			if(oya[nv] == -1) oya[nv] = v;
			else {
				if(dist[oya[nv]] > dist[v]) oya[nv] = v;
			}
            que.push(nv);
        }
    }
	cout << "Yes" << endl;
	REP(i, 1, N) {
		cout << oya[i] + 1 << endl;
	}
	//cout << endl;
	return 0;
}

Measured memory_bytes: 13764
package main

import (
	"bufio"
	"fmt"
	"os"
)

func generated_lib_swap(a int, b int) (int, int) {
	return b, a
}
func (u generated_lib_UnionFind) Size(x int) int {
	return -u.par[u.Find(x)]
}
func (u generated_lib_UnionFind) Union(x, y int) {
	xr := u.Find(x)
	yr := u.Find(y)
	if xr == yr {
		return
	}
	if u.Size(yr) < u.Size(xr) {
		yr, xr = generated_lib_swap(yr, xr)
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u generated_lib_UnionFind) Find(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.Find(u.par[x])
	return u.par[x]
}
func generated_lib_NewUnionFind(N int) *generated_lib_UnionFind {
	u := new(generated_lib_UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}

type generated_lib_UnionFind struct{ par []int }

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n, m int
	fmt.Fscan(r, &n, &m)
	uf := generated_lib_NewUnionFind(n)
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Fscan(r, &a, &b)
		a--
		b--
		uf.Union(a, b)
	}
	ans := 0
	for i := 0; i < n; i++ {
		if ans < uf.Size(i) {
			ans = uf.Size(i)
		}
	}
	fmt.Fprintln(w, ans)
}


Measured memory_bytes: 6304
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()
#define F first
#define S second

bool could[100010];
int balls[100010];

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

	memset(could, 0, sizeof(could));
	
	int n, m; cin >> n >> m;
	forn(i,n) { could[i + 1] = 0, balls[i + 1] = 1; }
	could[1] = 1;
	
	while (m--) {
		int x, y; cin >> x >> y;
		
		could[y] |= could[x];
		balls[y]++;
		balls[x]--;
		if (balls[x] == 0) could[x] = false;
		//~ could[x] &= balls[x];
	}
	
	int res = 0;
	forn(i, n) res += could[i + 1];
	
	cout << res << endl;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

bool dp[777][777];

int main(){
	
	int n,m;cin >> n >> m;
	
	vector<vector<int>> tmpv(n);
	vector<vector<int>> v(n);
	
	REP(i,m){
		int a,b;cin >> a >> b;
		a--;b--;
		tmpv[a].PB(b);
		tmpv[b].PB(a);
	}
	
	REP(i,n){
		vector<bool> used(n);
		used[i] = true;
		REP(j,tmpv[i].size())used[tmpv[i][j]] = true;
		REP(j,n){
			if(!used[j])v[i].PB(j);
		}
	}
	
	vector<int> color(n);
	vector<pair<int,int>> seica;
	
	REP(i,n){
		if(color[i] == 0){
			pair<int,int> hoge = MP(0,0);
			color[i] = 1;
			queue<int> q;
			q.push(i);
			while(!q.empty()){
				int now = q.front();q.pop();
				if(color[now] == 1)hoge.FI++;
				else hoge.SE++;
				REP(j,v[now].size()){
					if(color[v[now][j]] == 0){
						color[v[now][j]] = -color[now];
						q.push(v[now][j]);
					}
					else if(color[v[now][j]] == color[now]){
						cout << -1 << endl;
						return 0;
					}
				}
			}
			seica.PB(hoge);
		}
	}
	
	dp[0][0] = true;
	
	REP(i,seica.size()){
		REP(j,777){
			if(dp[i][j]){
				dp[i+1][j+seica[i].FI] = true;
				dp[i+1][j+seica[i].SE] = true;
			}
		}
	}
		
	ll ans = LLINF;
	REP(i,777){
		if(dp[seica.size()][i]){
			ll tmp = (i * (i - 1) + (n-i) * (n-i-1))/2;
			ans = min(ans,tmp);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3840
def solve():
  n, k = map(int,input().split())
  group_num = 10
  
  book_map = [[] for i in range(group_num)]
  acc_map = []

  for i in range(n):
    c, g = map(int,input().split())
    book_map[g - 1].append(c)

  for i in range(group_num):
    bmi = book_map[i]
    bmi.sort(reverse=True)
    ami = [0 for i in range(len(bmi) + 1)]
    for j in range(len(bmi)):
      ami[j + 1] = ami[j] + bmi[j] + j * 2
    acc_map.append(ami)
  
  dp = [[0] * (k + 1) for i in range(group_num + 1)]
  for y in range(1, k + 1):
    for x in range(1, group_num + 1):
      accs = acc_map[x - 1]
      dp_pre = dp[x - 1]
      dp[x][y] = max([dp_pre[y - z] + accs[z] for z in range(min(y + 1, len(accs)))])
  
  print(dp[group_num][k])
solve()



Measured memory_bytes: 6320
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int g(int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

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

    int N;
    cin >> N;
    int n = sqrt(N);
    vector<int> f(N + 1);
    FOR(i, 1, n + 1) {
        FOR(j, 1, n + 1) {
            FOR(k, 1, n + 1) {
                int v = g(i, j, k);
                if (v <= N) {
                    f[v]++;
                }
            }
        }
    }
    FOR(i, 1, N + 1) {
        cout << f[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3680
import java.util.*;
  
public class Main {
    Scanner sc = new Scanner(System.in);
  
    public static void main(String[] args) {
        new Main(); 
    }
  
    public Main() {
        new TEST().doIt();
    }
    class TEST{
        void doIt(){
        	int n = sc.nextInt();
        	for(int i = 1;i <= n;i++){
        		if(i % 3 == 0)System.out.print(" "+i);
        		else {
        			int x = i;
                    while(x!=0){
                        if(x % 10 == 3){
                        	if(x % 10 == 3)System.out.print(" "+i);
                            break;
                        }
                        x /= 10;
                    }
        		}
        	}
        	System.out.println();
        }
    }
}

Measured memory_bytes: 28528
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n-1):
    ans=0
    for j in range(i,n-1):
        c = csf[j][0]
        s = csf[j][1]
        f = csf[j][2]
        if j==i:
            ans+=s+c
        else:
            if ans<s:
                ans=s+c
            else:
                ans+=(f-(ans-s)%f)%f+c
    print(ans)
print(0)

Measured memory_bytes: 68544
#include <bits/stdc++.h>
 
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ii pair<int,int>
#define qu queue <int>
#define qmax priority_queue <int>
#define qmin priority_queue <int, vector<int>,greater<int>>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b;
    cin>>a>>b;

    cout<<max({a+b, a-b, a*b})<<endl;

    return 0;
}

Measured memory_bytes: 3652
from heapq import heappush, heappop

def Dijkstra(graph, start, goal):
    que = [(0, start)]
    visited = [False] * len(graph)
    while True:
        path_len, v = heappop(que)
        visited[v] = True
        if v == goal:
            print(path_len)
            break
        for w, edge_len in graph[v].items():
            if not visited[w]:
                heappush(que, (path_len + edge_len, w))

while(True):
    dicco = {}
    dicti = {}
    n,m = map(int, input().split())
    if n == 0 and m == 0:
        break
    for i in range(m):
        dicco[i] = {}
        dicti[i] = {}
    for _ in range(n):
        a,b,c,t = map(int, input().split())
        dicco[a-1][b-1] = c
        dicco[b-1][a-1] = c
        dicti[a-1][b-1] = t
        dicti[b-1][a-1] = t
    k = int(input())
    for _ in range(k):
        p,q,r = map(int, input().split())
        if not r:
            Dijkstra(dicco, p-1, q-1)
        else:
            Dijkstra(dicti, p-1, q-1)




Measured memory_bytes: 6752
//Created by: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 305;

ld dp[N][N][N];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
        cin >> n;
        int ar[4] = {0};
        for (i = 0; i < n; i++)
            cin >> m, ar[m]++;
        int mx_1 = ar[1] + ar[2] + ar[3], mx_2 = ar[2] + ar[3], mx_3 = ar[3];
        for (k = 0; k <= mx_3; k++)
        {
            for (j = 0; j <= mx_2 - k; j++)
            {
                for (i = 0; i <= mx_1 - j - k; i++)
                {
                    if (i + j + k == 0)
                        continue;
                    dp[i][j][k] = (ld)n / (i + j + k);
                    if (i > 0)
                        dp[i][j][k] += dp[i - 1][j][k] * i / (ld)(i + j + k);
                    if (j > 0)
                        dp[i][j][k] += dp[i + 1][j - 1][k] * j / (ld)(i + j + k);
                    if (k > 0)
                        dp[i][j][k] += dp[i][j + 1][k - 1] * k / (ld)(i + j + k);
                }
            }
        }
        cout << fixed << setprecision(10) << dp[i - 1][j - 1][k - 1];
    }
    return 0;
}

Measured memory_bytes: 216004
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

char str[10];
signed main(){
	int ans = 700;
	scanf("%s", str);
	rep(i,3)if(str[i] == 'o')ans += 100;
	printf("%lld\n", ans);
	return 0;
}




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

using namespace std;


int N;
vector<int> dists;
vector<vector<int>> to_froms;

int update_dist(int i){
  if(dists[i] != -1) return dists[i];

  int dist = 0;
  for(int from: to_froms[i]){
    dist = max(dist, update_dist(from) + 1);
  }
  dists[i] = dist;

  return dists[i];
}

int main() {
  //
  int M, x, y;
  cin >> N >> M;
  to_froms.resize(N);
  for (int i = 0; i < N; ++i) {
    to_froms[i] = vector<int>();
  }

  for (int i = 0; i < M; ++i) {
    cin >> x >> y;
    x--; y--;
    to_froms[y].push_back(x);
  }

  // i番目までの頂点の長さ
  dists.resize(N);
  fill(dists.begin(), dists.end(), -1);

  //
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans = max(ans, update_dist(i));
  }
//  for(int d: dists)
//    cout << d << endl;
  cout << ans << endl;


return 0;
}




Measured memory_bytes: 10624
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    deque<ll int> q;
    ll int n;
    cin>>n;
    rep(i,n){
        ll int a;
        cin>>a;
        if(i%2) q.push_front(a);
        else q.push_back(a);
    }
    if(n%2){
        for(int i=n-1;i>=0;i--){
            cout<<q[i]<<" ";
        }
        return 0;
    }
    else {
        rep(i,n){
            cout<<q[i]<<" ";
        }
    }
    return 0;
}


Measured memory_bytes: 3840
n,y = map(int,input().split())
flag = True

for i in range(y//10000 + 1):
    for j in range((y - i*10000)//5000 + 1):
        k = (y - 10000*i - 5000*j)//1000        
        if i + j + k == n:
            print(i,j,k)
            flag = False
            break
    if flag:
        continue
    else:
        break            
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m;
    cin>>n>>m;
    vector<ll> a(n),b(n),c(m),d(m);
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,m) cin>>c[i]>>d[i];
    int ans;
    rep(i,n){
        ll mini=300000010;
        rep(j,m){
            ll dx=abs(a[i]-c[j]),dy=abs(b[i]-d[j]);
            if(mini>dx+dy){
                mini=dx+dy;
                ans=j+1;
            }
        }
        cout<<ans<<endl;
    }
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","w",stdout);
    //FILE *fptr2=freopen("out.txt","w",stdout);



    int d,t,s;
    cin>>d>>t>>s;

    if((d/(s*1.0))<=t)
    {
        cout<< "Yes";
    }
    else cout<< "No";



    return 0;
}


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

int main(void)
{
  string s;
  string res;
  cin >> s;
  cin >> res;
  int cnt = 0;
  for(int i = 0; i < 3; i++)
  {
    if(s[i] == res[i])
      cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ans = [-1]*N

for _ in range(M):
    s, c = map(int, input().split())
    if ans[s-1]==-1: ans[s-1]=c
    elif ans[s-1]!=c:
        print(-1)
        exit()

for k in range(N):
    if ans[k]==-1: ans[k]=1 if k==0 and N>1 else 0

if N>1 and ans[0]==0:
    print(-1)
    exit()
    
print(*ans, sep='')

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, l;
    cin >> n >> m >> l;

    int A[105][105];
    int B[105][105];
    long C[105][105];

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

    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> B[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            C[i][j] = 0;
            for (int k = 0; k < m; k++)
            {
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cout << C[i][j];
            if (j < l - 1)
                cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
const long long md=998244353;
const int maxn=1000100;
long long fac[maxn],inv[maxn];
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
long long C(int x,int y){
	if(x<0||y<0||x<y) return 0;
	return fac[x]*inv[y]%md*inv[x-y]%md;
}
int main(){
//	freopen("E.in","r",stdin);
	int n,m;
	scanf("%d%d",&m,&n);
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%md;
	inv[n]=powd(fac[n],md-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
	int R,B;
	long long ans=0;
	for(int i=(n+1)/2;i<=n;i++){
		R=i,B=n-i;
		if(R<m) continue;
      	if(R==B) B--;
		ans=(ans+C(R+B,R))%md;
		ans=(ans-C(R+B,((R-m+1)+R))+md)%md;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10496
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] weather = new String[]{"Sunny","Cloudy","Rainy"};
    String tw = sc.next();
    for(int i=0;i<weather.length;++i){
      if(tw.equals(weather[i])){
        System.out.println(weather[(i+1)%3]);
        break;
      }
    }
  }
}

Measured memory_bytes: 21460
#include <iostream>

int check_circle(const double xa, const double ya, const double ra,
                 const double xb, const double yb, const double rb){
  double distance;
  distance = (xa - xb)*(xa - xb) + (ya - yb)*(ya - yb);

  if(distance > (ra + rb)*(ra + rb) ){
    return 0;
  }
  else if(distance < (ra - rb)*(ra - rb) ){
    if(ra > rb){
      return 2;
    }
    else{
      return -2;
    }
  }
  else{
    return 1;
  }
}

int main(){
  int data_num;
  std::cin >> data_num;

  for(int i = 0; i < data_num; ++i){
    double xa, ya, ra, xb, yb, rb;
    std::cin >> xa >> ya >> ra
             >> xb >> yb >> rb;
    std::cout << check_circle(xa, ya, ra, xb, yb, rb) << std::endl;
  }

}

Measured memory_bytes: 1240