akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    int A, B, C;
    long X, Y;
    cin >> A >> B >> C >> X >> Y;

    long ans1 = A * X + B * Y;
    long ans2 = (2 * C) * X + B * ((Y - X) < 0 ? 0 : (Y - X));
    long ans3 = A * ((X - Y) < 0 ? 0 : (X - Y)) + (2 * C) * Y;

    cout << min(min(ans1, ans2), min(ans2, ans3)) << endl;
}

Measured memory_bytes: 256
//package beginner166.b;

import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            int[] ss = new int[n];

            for (int i = 0; i < k; ++i) {
                int cnt = in.nextInt();
                for (int j = 0; j < cnt; ++j) {
                    ss[in.nextInt()-1] += 1;
                }
            }

            int result = 0;
            for (int i = 0; i < n; ++i) {
                if (ss[i] == 0) {
                    ++result;
                }
            }

            out.println(result);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

Measured memory_bytes: 26860
di = {"m":1000,"c":100,"x":10,"i":1}
num = input()

def decod(st):
    buf = 1
    tot = 0
    for i in st:
        if ((i == 'm') or (i == 'c') or (i == 'x') or (i == 'i')):
            tot += buf * di[i]
            buf = 1
        else:
            buf = int(i)
    return tot


def encod(num):
    l = []
    st2 = ""
    st = str(num)
    st = "0"*(4-len(st)) + st
    for i in range(len(st)):
        l.append(st[len(st) - (i + 1):len(st) - i])
    for i in range(len(l)):
        st2 += l[3-i] + di.keys()[3-i]
    st2 = st2.replace("0m", "").replace("1m", "m").replace("0c", "")\
        .replace("1c", "c").replace("0x", "").replace("1x", "x")\
        .replace("0i", "").replace("1i", "i")
    return st2

for j in range(num):
    op1,op2 = raw_input().split()
    print encod(decod(op1)+decod(op2))

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

namespace abc55 {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            ulong ans = 1;
            while (n > 0) {
                ans *= (ulong)n;
                ans %= (ulong)(10e8 + 7);
                n--;
            }
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
    ll n;
    cin >> n;
    int m=1;
    ll s = pow(n,0.5);
    for (int i=1; i<=s+1; i++){
        if(n%i==0) m=max(i,m);
    }
    cout << m + n/m - 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 1005;
int id[MAX_N][MAX_N],A[MAX_N][MAX_N],dp[MAX_N*MAX_N];
bool visit[MAX_N*MAX_N],calc[MAX_N*MAX_N];
vector<int> G[MAX_N*MAX_N];

void init()
{
	rep(i,MAX_N)
	{
		rep(j,MAX_N)
		{
			id[i][j] = -1;
		}
	}
	rep(i,MAX_N*MAX_N)
	{
		dp[i] = 1;
		visit[i] = false;
		calc[i] = false;
	}
	return;
}

int getid(int a, int b)
{
	if (a > b) swap(a,b);
	return id[a][b];
}

int dfs(int n)
{
	//cout << "visiting:" << n << endl;
	if (visit[n])
	{
		//cout << "b";
		if (!calc[n]) return -1;
		return dp[n];
	}
	visit[n] = true;
	int res;
	rep(i,G[n].size())
	{
		res = dfs(G[n][i]);
		if (res == -1) 
		{
			//cout << "c";
			return -1;
		}
		dp[n] = max(dp[n],res+1);
	}
	calc[n] = true;
	//cout << "return:" << dp[n] << endl;
	return dp[n];
}

int main()
{
	init();
	int N;
	cin >> N;
	int cnt = 0;
	rep(i,N)
	{
		rep(j,N-1)
		{
			int idx = i+1;
			cin >> A[i][j];
			if (getid(idx,A[i][j]) == -1)
			{
				if (idx > A[i][j]) id[A[i][j]][idx] = cnt;
				else id[idx][A[i][j]] = cnt;
				cnt++;
			}
			if (j > 0)
			{
				G[getid(idx,A[i][j-1])].push_back(getid(idx,A[i][j]));
			}
		}
	}
	/*
	rep(i,N)
	{
		rep(j,N)
		{
			if (i == j) cout << "  ";
			else cout << getid(i+1,j+1) << " ";
		}
		cout << endl;
	}
	rep(i,N)
	{
		rep(j,G[i].size())
		{
			cout << G[i][j] << " ";
		}
		cout << endl;
	}
	*/
	int ans = 0;
	rep(i,N*(N-1)/2)
	{
		int res = dfs(i);
		if (res == -1)
		{
			cout << "-1" << endl;
			return 0;
		}
		ans = max(ans,res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 53376
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N;
    cin >> N;
    vector<ll> num(N);
    map<ll,ll> kazu;
    ll wa = 0;
    rep(i,N){
        cin >> num[i];
        wa += kazu[num[i]];
        kazu[num[i]]++;
    }
    rep(i,N){
        cout << wa - kazu[num[i]] + 1 << endl;
    }
}

Measured memory_bytes: 11008
from bisect import  bisect_left
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
l[0]=a[0]
for i in range(1,n):
    l[i]=l[i-1]+a[i]
ans=l[n-1]
for i in range(1,n):
    chk=l[i]//2
    x=bisect_left(l,chk)
    p1,p2=l[x-1],l[x]
    if abs(p1-chk)>=abs(p2-chk):
        p=p2
    else:
        p=p1
    q=l[i]-p
    chk=l[i]+(l[n-1]-l[i])//2
    x=bisect_left(l,chk)
    r1,r2=l[x-1],l[x]
    if abs(r1-chk)>=abs(r2-chk):
        r=r2-l[i]
    else:
        r=r1-l[i]
    s=l[n-1]-r-l[i]
    ans=min(ans,max(p,q,r,s)-min(p,q,r,s)) 
print(ans) 

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

using namespace std;

string calc(int n) {
	if (n == 0) return "0";
	string s = "";

	while (n != 0) {
		int x = n / -2;
		int y = abs(n % 2);
		if (y && n < 0) x += 1;
		s += to_string(y);
		n = x;
	}

	reverse(s.begin(), s.end());
	return s;
}

int main() {
	int n;
	scanf("%d", &n);
	printf("%s\n", calc(n).c_str());
	return 0;
}		

Measured memory_bytes: 256
x = int(input())

p = x%100
n = (x-p)//100
b = 0
for i in range(n+1):
    if b==1:
        break
    for j in range(n+1-i):
        if b==1:
            break
        for k in range(n+1-i-j):
            if b==1:
                break
            for l in range(n+1-i-j-k):
                if b==1:
                    break
                for m in range(n+1-i-j-k-l):
                    if i + 2*j + 3*k + 4*l + 5*m == p:
                        print(1)
                        b =1
                        break
if b==0:
    print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main() {
    int N,k;
    int a[200100];
    cin >> N >> k;
    for (int i = 0;i < N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    int p = 0;
    vector<int> kazu;
    for (int i = 0;i < N - 1;i++){
        if (a[i] == a[i + 1]){
            p = p + 1;
            if (i == N - 2){
                kazu.push_back(p + 1);
            }
        }
        else{
            kazu.push_back(p + 1);
            if (i == N - 2){
                kazu.push_back(1);
            }
            p = 0;
        }
    }
    size_t kazusize = kazu.size();
    sort(kazu.begin(),kazu.end());
    int q = 0;
    if(kazusize <= k){
        q = 0;
    }
    else{
        for (int i = 0;i < kazusize - k;i++){
            q = q + kazu[i];
        }
    }
    cout << q << endl;
}

Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
        }
        int cur = 0;
        for (int i = 0; i < N; i++) {
            cur = a[cur] - 1;
            if (cur == 1) {
                System.out.println(i + 1);
                return;
            }
        }
        System.out.println(-1);
    }
}


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

int main(){
  int n;
  cin >> n;
  if(n%2 == 1){
  	cout << n/2 + 1 << endl;
  }else{
  	cout << n/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int countDivisors(int n){
	int count=0;
	for(int i=1; i<=sqrt(n); i++){
		if(n%i==0){
			if(n/i==i)
				count++;
			else
				count+=2;
		}
	}
	return count;
} 
int main(){
	int n, count=0;
	cin>>n;
	for(int i=1; i<n; i++){
		count+=countDivisors(i);
	}
	cout<<count<<'\n';
	return 0;
}


Measured memory_bytes: 3568
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, t;
	vector <int> v;

	cin >> n;

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

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

	cout << v[n / 2] - v[n / 2 - 1] << '\n';

	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,k;
	while(cin>>n>>k)
	{
		int a;
		int ans=0;
		while(n--)
		{
			cin>>a;
			if(a>=k) 
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 3

int main(void){
  char ch[N];

  for( int i=0 ; i<N ;  i++ ){
    scanf("%c",&ch[i]);
  }
  if(ch[0]=='R' && ch[1]=='R' && ch[2]=='R'){
    printf("3\n");
  }else if((ch[0]=='R' && ch[1]=='R') || (ch[1]=='R' && ch[2]=='R')){
    printf("2\n");
  }else if(ch[0]=='R' || ch[1]=='R' || ch[2]=='R'){
    printf("1\n");
  }else{
    printf("0\n");
  }

  return 0;
}


Measured memory_bytes: 2016
#include <bits/stdc++.h>
using namespace std;
int main() {
	cin.tie(0); cin.sync_with_stdio(false);
	long long n, m;
	cin >> n >> m;
	vector<long long> dp(n + 1, 0);
	for (long long i = 0; i < m; i++) {
		long long l, r;
		cin >> l >> r;
		dp[l]++; dp[r + 1]--;
	}
	for (long long i = 1; i <= n; i++) {
		dp[i] += dp[i - 1];
	}
	long long ret = 0;
	for (long long i = 1; i <= n; i++) {
		if (dp[i] == m) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1024
#import sys
#input = sys.stdin.readline
#template input
import bisect

def IT(): #整数1個
    return int(input())
def IL(): #整数複数
    return [int(_) for _ in input().split()]
def IS(): #文字列複数
    return [_ for _ in input().split()]
def ILS(n): #整数1つ　縦にズラーってなってるやつ
    return [int(input()) for _ in range(n)]
def SLS(n): #文字列　縦にズラーってなってるやつ
    return [input() for _ in range(n)]
def ILSS(n): #整数複数　縦にズラーってなってるやつ
    return [[int(_) for _ in input().split()] for j in range(n)]

#template technique
def bit_full_search2(A):
    #https://blog.rossywhite.com/2018/08/06/bit-search/
    value = []
    for i in range(1 << len(A)):
        output = []

        for j in range(len(A)):
            if ((i >> j) & 1) == 1:
                #output.append(A[j])
                output.append(A[j])
        value.append([format(i, 'b').zfill(16), sum(output)])

    value.sort(key=lambda x:x[1])
    bin = [value[k][0] for k in range(len(value))]
    val = [value[k][1] for k in range(len(value))]
    return bin, val

"""ここからメインコード"""
def main():
    n = IT()
    #それぞれ半分全列挙
    list1 = [(-2) ** i for i in range(16)]
    list2 = [(-2) ** (i + 16) for i in range(16)]
    list1_bin, list1_val = bit_full_search2(list1)
    list2_bin, list2_val = bit_full_search2(list2)

    #2分探索
    ans = 0
    for i in range(len(list1_val)):
        j = bisect.bisect_left(list2_val, n - list1_val[i])
        if j < len(list2_val):
            if list1_val[i] + list2_val[j] == n:
                ans = list2_bin[j] + list1_bin[i]
                break
    print(int(ans))

main()



Measured memory_bytes: 25532
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int n,c=0;
  cin >> n;
  for(int i=1;i<=n;i++){
  	if(i<10)
      c++;
    if(i > 99 && i<1000)
      c++;
    if(i > 9999 && i<100000)
      c++;
  }
  cout << c;
  
 
}

Measured memory_bytes: 256
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------



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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
void writeln(int x) {
	int s = 0; char f[10];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) reader(&a[i]), reader(&b[i]);
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.push(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.push(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) z[a[i]].push_back(make_pair(b[i], d[i]));
		if (dist[b[i]] > dist[a[i]]) z[b[i]].push_back(make_pair(a[i], d[i]));
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 23296
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int q;
    cin >> q;

    multiset<ll, greater<ll>> stl;
    multiset<ll> str;
    ll ans = 0;
    
    while (q--) {
        ll a, b, c;
        cin >> c;
        
        if (c == 1) {
            cin >> a >> b;
            ans += b;

            if (stl.size() == 0) {
                stl.insert(a);
                continue;
            }

            ll lmx = *stl.begin();
            if (a < lmx) stl.insert(a);
            else str.insert(a);
            ans += abs(lmx - a);

            auto lsz = stl.size(), rsz = str.size();
            if (lsz == rsz + 2) {
                str.insert(lmx);
                stl.erase(stl.begin());
            } else if (lsz + 1 == rsz) {
                stl.insert(*str.begin());
                str.erase(str.begin());
                ans -= *stl.begin() - lmx;
            }
        } else {
            cout << *stl.begin() << ' ' << ans << '\n';
        }
    }

    return 0;
}

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


int main(){
  int n,ma,mb;
  cin >>n >> ma >> mb;
  int a[n],b[n],c[n];
  rep(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }

  int dp[401][401];
  int ndp[401][401];  
  rep(i,401) rep(j,401){
    dp[i][j]=INT_MAX;
    ndp[i][j]=INT_MAX;
  }
  dp[0][0]=0;
  ndp[0][0]=0;
  rep(i,n){
    rep(j,401) rep(k,401){
      if(j+a[i]<=400 && k+b[i]<=400){
	if(dp[j][k]!=INT_MAX){
	  ndp[j+a[i]][k+b[i]]=min(dp[j][k]+c[i],dp[j+a[i]][k+b[i]]);
	}
	else{
	  ndp[j+a[i]][k+b[i]]=dp[j+a[i]][k+b[i]];
	}
      }
    }
    rep(j,401) rep(k,401){
      dp[j][k]=ndp[j][k];
      //      ndp[j][k]=INT_MAX;
    }
    //    dp[0][0]=0;
    //    cout << dp[3][5] << endl;
  }
  int ai=1;
  int ans=INT_MAX;

  while(ma*ai<401 && mb*ai<401){
    //    cout << ans << endl;
    ans=min(dp[ma*ai][mb*ai],ans);
    ai++;
  }
  if(ans==INT_MAX) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;

}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

int main()
{
    fastread();


   ll a,b;

   cin>>a>>b;




   if(a*500>=b)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;



}


Measured memory_bytes: 3600
import java.util.*;
import java.lang.*;

class Main {
	static class Graph {
		List<List<Edge>> adjList;

		public Graph(List<Edge> edges, int numVertices) {
			adjList = new ArrayList<>(numVertices);

			for(int i = 0; i < numVertices; i++) {
				adjList.add(new ArrayList<>());
			}

			for(Edge edge : edges) {
				adjList.get(edge.source).add(edge);
			}
		}
	}

	static class Edge {
		int source;
		int dest;
		int weight; // weight of edge

		public Edge(int s, int d, int w) {
			source = s;
			dest = d;
			weight = w;
		}
	}

	static class Node {
		int index;
		int weight; // weight in min-heap

		public Node(int i, int w) {
			index = i;
			weight = w;
		}
	}

	public static void findSSSP(Graph g, int source, int numVertices) {
		// Create min-heap and push the source into it
		PriorityQueue<Node> minHeap = new PriorityQueue<>((lhs, rhs) -> lhs.weight - rhs.weight);
		minHeap.add(new Node(source, 0)); // dist of source is 0

		// Initialize distance of all vertices to Infinity
		List<Integer> dist = new ArrayList<>(Collections.nCopies(numVertices, Integer.MAX_VALUE));

		// Set distance of source to 0
		dist.set(source, 0);

		// Mark processed vertices to True
		boolean[] done = new boolean[numVertices];
		done[source] = true; // no need to process source

		// Store predecessors of a vertex
		int[] prev = new int[numVertices];
		prev[source] = -1; // source has no predecessor

		while(!minHeap.isEmpty()) {
			// Get best vertex and remove from minHeap
			Node n = minHeap.poll();

			// Get vertex number
			int vertex = n.index;

			// Process all neighbors of vertex
			for(Edge edge : g.adjList.get(vertex)) {
				int dest = edge.dest;
				int weight = edge.weight;

				// Relaxation step
				if(!done[dest] && dist.get(dest) > dist.get(vertex) + weight) {
					// Update predecessor
					prev[dest] = vertex;
					dist.set(dest, dist.get(vertex) + weight);
					minHeap.add(new Node(dest, dist.get(dest)));
				}
			}

			// Finished processing vertex
			done[vertex] = true;
		}

		// Print results
		for(int i = 0; i < numVertices; i++) {
			int distance = dist.get(i);

			System.out.println(distance == Integer.MAX_VALUE ? "INF" : distance);
		}
	}

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

		int vertices = scanner.nextInt();
		int edges = scanner.nextInt();
		int source = scanner.nextInt();

		// Read edges
		List<Edge> edgesList = new ArrayList<>();
		for (int i = 0; i < edges; i++) {
			Edge edge = new Edge(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
			edgesList.add(edge);
		}

		// Create new graph
		Graph g = new Graph(edgesList, vertices);

		findSSSP(g, source, vertices);
	}
}


Measured memory_bytes: 318796
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int alphabet[26] = {0};
    int H,W;
    cin >> H >> W;
    for ( int i = 0; i < H; i++ ) {
        string S;
        cin >> S;
        
        for ( auto& s : S ) {
            alphabet[ s - 'a' ]++;
        }        
    }
    
    int a = W%2;
    int b = W/2;
    
    int c = H%2;
    int d = H/2;
    
    int four = b*d;
    int two = a*d+c*b;
    int one = a*c;
    
    // cout << "four: " << four << endl;
    // cout << "two: " << two << endl;
    // cout << "one: " << one << endl;
    
    // if ( H == 1 || W == 1 ) {
        // int x = (H*W)%2;
        // for ( int i = 0; i < 26; i++ ) {            
            // if ( !alphabet[i] ) { continue; }
            // if ( alphabet[i]%2 && x ) { x = 0; continue; }
            // if ( alphabet[i]%2 && !x ) {
                // cout << "No" << endl;  return 0;
            // }
        // }
        // cout << "Yes" << endl; return 0;
    // }
    
    for ( int i = 0; i < 26; i++ ) {        
        if ( !alphabet[i] ) { continue; }
        if ( alphabet[i]%2 && one ) {
            alphabet[i]--;
            one = 0;
            continue;
        }
        if ( alphabet[i]%2 && !one ) {
            cout << "No" << endl;  return 0;
        }
    }
    
    int f = 0;
    for ( int i = 0; i < 26; i++ ) {
        if ( alphabet[i] >= 4 ) {
            f += alphabet[i]/4;
        }
    }

    if ( four > f ) { cout << "No" << endl; return 0; }
    
    
    
    // for ( int i = 0; i < 26; i++ ) {
        // if ( !alphabet[i] ) { continue; }
        // if ( alphabet[i] >= 4 && four ) {
            // int x = max( 0, four-(alphabet[i]/4) );
            // alphabet[i] = x*4;
            // four = x;
        // }
    // }
    // if ( four ) { cout << "No" << endl;  return 0; }
    
    
    // for ( int i = 0; i < 26; i++ ) {
        // if ( !alphabet[i] ) { continue; }
        // if ( alphabet[i] >= 2 && two ) {
            // int x = max( 0, two-alphabet[i]/2 );
            // alphabet[i] = x*2;
            // two = x;
        // }
    // }
    // if ( two ) { cout << "No" << endl;  return 0; }
    
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
        
        dividend %= mod;
        divisor %= mod;
    }
    return (dividend %mod) / (divisor%mod);
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
ll facctorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    ll x, y;
    cin >> x >> y;
    
    ll res = 0;
    if(x < 4){
        res += (4 - x) * 100000;
    }
    if(y < 4){
        res += (4 - y) * 100000;
    }
    if(x == 1 && y == 1){
        res += 400000;
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split(' ')))

import itertools

ans = 0
for p in itertools.combinations(l,3):
    ab = p[0] + p[1]
    bc = p[1] + p[2]
    ca = p[0] + p[2]
    if (ab > p[2]) and (bc > p[0]) and (ca > p[1]) and (p[0] != p[1]) and (p[1] != p[2]) and (p[0] != p[2]):
        ans += 1
print(ans)

Measured memory_bytes: 72996
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    long long ans = 0;
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            if(a[j] < a[i]){
                ans += k * (k - 1LL) / 2;
                ans %= MOD;
                if(i < j){
                    ans += k;
                    ans %= MOD;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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


void solve(){
long long n,k;
cin>>n>>k;
unordered_map<long long,long long> vis;
vector<long long> v(n+1);
for(long long i=1;i<=n;i++){
	cin>>v[i];
}
long long start=1;

long long rep=0;
long long end=1;
while(!vis[start]){

	vis[start]=1;
	start=v[start];
	rep++;	
	end=start;

}
long long start1=1;
long long j=0;
while(start1!=end){
	start1=v[start1];
	j++;
}


long long l=(k-j)%(rep-j);

if(k-j<0){
	int start2=1;
	while(k--){
		
		start2=v[start2];
	}
	cout<<start2;
	return ;
}
while(l--){
	end=v[end];
}
cout<<end;
}


int main() {

solve();



}



Measured memory_bytes: 12840
#include <cstdio>
typedef long long int64;
static const int MAXN = 200005;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS

int h, w, a, b;
int64 fact[MAXN], fact_inv[MAXN];

inline int64 fpow(int64 base, int exp)
{
    int64 ans = 1;
    for (; exp; exp >>= 1, (base *= base)__) if (exp & 1) (ans *= base)__;
    return ans;
}

inline void preprocess()
{
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) fact[i] = fact[i - 1] * i _;
    fact_inv[MAXN - 1] = fpow(fact[MAXN - 1], MODULUS - 2);
    for (int i = MAXN - 2; i >= 0; --i) fact_inv[i] = fact_inv[i + 1] * (i + 1)_;
}

inline int64 binom(int n, int m)
{
    if (n < m || m < 0) return 0;
    return fact[n] * fact_inv[n - m]_ * fact_inv[m]_;
}

inline int64 ways(int r, int c)
{
    return binom(r + c, c);
}

int main()
{
    preprocess();
    scanf("%d%d%d%d", &h, &w, &a, &b);

    int64 ans = 0;
    for (int i = b; i < w; ++i)
        (ans += ways(h - a - 1, i) * ways(a - 1, w - i - 1))__;
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define Pii pair<int,int>
#define mod 1000000007
#define sp fixed<<setprecision(12)
using namespace std; 

#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}    


void solve(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if((a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]) and ((a[i]+a[j]>a[k]) and (a[j]+a[k]>a[i]) and (a[i]+a[k]>a[j]))){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<'\n';

}

int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;
    //sieve();
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    
    return 0;
    
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; edge(ll f, ll t, ll c) : from(f), to(t), cost(c) { } };
// struct edge{ ll to, cost; edge(ll t, ll c) : to(t), cost(c) { } };
struct edge{ ll from, to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
using Graph = vector<edge>;
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

const ll MAX_E = 2000, MAX_V = 1000;  // 制約に従って決める
ll V, E;  // 入力で受け取る

Graph es(MAX_E);  // 0-basedにして順番に辺を入れる
ll d[MAX_V];


bool bellman_ford(ll s){  // 始点の頂点番号が引数(0-based)
    FILL(d, INF);
    d[s] = 0;
    // ll cnt = 0;
    rep(loop, V-1){
        // cnt++;
        bool update = false;
        rep(i, E){
            edge e = es[i];
            if(d[e.from] != INF && chmin(d[e.to], d[e.from] + e.cost)) update = true;
        }
        if(!update){
            // ans = d[V-1];
            return true;
        }
        // if(cnt == V) return false;
    }
    rep(loop, V){
        // cnt++;
        bool update = false;
        rep(i, E){
            edge e = es[i];
            if(d[e.from] != INF && chmin(d[e.to], d[e.from] + e.cost) && e.to == V-1) update = true;
        }
        if(update){
            return false;
        }
        // if(cnt == V) return false;
    }
    return true;
}


int main(){
    cin >> V >> E;
    rep(i, E){
        ll a, b, c; cin >> a >> b >> c; a--, b--, c *= -1;
        es[i] = edge{a, b, c};
    }
    if(bellman_ford(0)) cout << -1 * d[V-1] << endl;
    else cout << "inf" << endl;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);
//桁数に注意 long long　にする

int main() {
  
  string s;
  cin >> s;
  
  int ans = 0;
  
  rep(i,s.size()) {
    repo(j,s.size()-i+1) {
      string ss = s.substr(i,j);
      bool t = true;
      rep(k,j) {
        if(ss.at(k)!='A' && ss.at(k)!='C' && 
          ss.at(k)!='G' && ss.at(k)!='T') {
        t = false;
        }
      }
      if (t) ans = max(ans, j);
    }
  }
  
  cout << ans << endl;
  
}

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

using namespace std;

int main() {
    int input[3];
    for (int i = 0; i < 3; ++i) {
        scanf("%d", &input[i]);
    }

    int tmp = input[1]/input[0];

    if (tmp >= input[2]) {
        cout << input[2];
    } else  {
        cout << tmp;
    }
    return 0;
}

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

bool is_prime(int N){
    if(N<=1) return false;
    for (int i = 2; i*i <= N; i++)
    {
        if(N%i==0) return false;
    }
    return true;
}

int main(){
    using namespace std;
    int Q; cin >> Q;
    vector<pair<int, int>> q(Q);
    int minl = 100001, maxr = 0;
    for (int i = 0; i < Q; i++){
        cin >> q[i].first >> q[i].second; 
        minl = min(minl, q[i].first);
        maxr = max(maxr, q[i].second);
    } 

    vector<long> sum;
    long cnt = 0;
    for (int i = minl; i <= maxr; i+=2)
    {
        if(is_prime(i) && is_prime((i+1)/2)) cnt++;
        sum.push_back(cnt);
    }
    //for(int i : sum) cout << i << " ";
    //cout << endl;
    for (int i = 0; i < Q; i++)
    {
        if(q[i].first-minl-1>=0)
            cout << sum[(q[i].second-minl)/2] - sum[(q[i].first-minl)/2-1] << endl;
        else 
            cout << sum[(q[i].second-minl)/2] << endl;

    }
}

Measured memory_bytes: 1912
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		int a = x+y;
		int b = x-y;
		int c = x*y;
		
		int ans = Math.max(a,Math.max(b,c));
		System.out.println(ans);
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a) for(int i = 0; i < (a); ++i)
//0 == first's turn 1 == second's turn
vector<vector<bool>> dp;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> stones (n);
    FOR(i, n) cin >> stones[i];
    dp.assign(2, vector<bool>(k + 1, true));
    //false == they lose, 
    //0 is person 1 and their turn, 1 is person 2 and their turn
    FOR(i, stones[0])
    {
        dp[0][i] = false;
        dp[1][i] = false;
    }
    for(int i = stones[0]; i < k + 1; ++i)
    {
        bool isFalse0 = false;
        bool isFalse1 = false;
        for(int j = 0; j < n; ++j)
        {
            if(i - stones[j] < 0) continue;
            if(!dp[0][i - stones[j]]) isFalse1 = true;
            if(!dp[1][i - stones[j]]) isFalse0 = true;
        }
        dp[0][i] = isFalse1;
        dp[1][i] = isFalse0;
    }
    cout << (dp[0][k] ? "First" : "Second");
    return 0;
}

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

int main(void) {
    int N,sum=0,i,score[100]={0},s,j=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
    	scanf("%d",&s);
    	score[s-1]++;
    	sum+=s;
    }
    if(sum%10==0){
    	for(i=0;i<100;i++){
    		if((i+1)%10!=0){
    			if(score[i]!=0){
    				sum-=i+1;
    				j=1;
    				break;
    			}
    		}
    		if(j==1) break;
    		if(i==99) sum=0;
    	}
    }
    printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 128
//PseudoName

    #pragma GCC optimize("O3")
    #include <bits/stdc++.h>
/*
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
    #define FOR(i,n) for(i=0;i<n;i++)
    #define FOR1(i,n) for(i=1;i<=n;i++)
    #define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
    #define pb push_back
    #define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
    #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define endl "\n"
    #define min3(a,b,c) min(a,min(b,c))
    #define forr(n) for(int i=0;i<n;i++)
    #define frr(n) for(int i=1;i<=n;i++)
    #define MAX 200005
    #define inf 200008

    using namespace std;

    typedef long long ll;
    typedef long li;
    typedef vector<int> vi;
    typedef vector<ll> vli;
    typedef vector<vi> vvi;
    typedef vector<vli> vvli;
    typedef pair<int,int> pi;
    typedef pair<ll,ll> pli;
    typedef vector<pi> vpi;
    typedef vector<pli> vpli;




    int main() {
        fast();
        string s;
        bool ok=0;
        cin>>s;
        forr(3)if(s[i]=='7')ok=1;
        if(ok)cout<<"Yes\n";
        else
            cout<<"No\n";

    }


Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>
int main(void){
    int N;
    float T,A;
    //int H[1001];
    int H;
    int i,num;
    float diff,diffabs,mindiff;
    float temp;
    scanf("%d",&N);
    scanf("%f %f",&T,&A);
    mindiff = 100000.0;
    num = 0;
    /*for(i=0;i<1001;i++){
        H[i]=0;
    }*/ 
    for(i=1;i<=N;i++){
        scanf("%d",&H);
        temp = T - 0.006 * H;
        diff = A - temp;
        diffabs = fabsf(diff);
        if(diffabs<mindiff){
            num = i;
            mindiff = diffabs; 
        }
        temp=0;
        H=0;
    }
    //printf("%f\n",mindiff);
    printf("%d\n",num);
}

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

int main() {
  int n, K, c;
  cin >> n >> K;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h >= K) {
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
  int N, K,A;
  int i;
  
  scanf("%d %d",&N, &K);

  A = K;
  for(i = 0; i < N-1; i++){
    A = A * (K-1);
  }
  
  printf("%d\n",A);
  
  return 0;
}

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

int N;
void dfs(vector<int> &a,int now,int mx){
  if(now==N){
    for(int i=0;i<N;i++)  cout << (char)(a.at(i)+'a');
    cout << endl;
    return;
  }

  for(int i=0;i<=mx+1;i++){
    a.at(now)=i;
    dfs(a,now+1,max(mx,i));
  }
}

int main(){
  cin >> N;

  vector<int> a(N,0);
  dfs(a,1,0);

  return 0;
}


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

import static java.lang.Integer.parseInt;

/*
 * Problem D: Big Hit !
 * PCK2010 ??¬???4
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			words = line.split(" ");

			int b, r, g, c, s, t;
			b = parseInt(words[0]);
			r = parseInt(words[1]);
			g = parseInt(words[2]);
			c = parseInt(words[3]);
			s = parseInt(words[4]);
			t = parseInt(words[5]);
			if ((b | r | g | c | s | t) == 0) break;

			int sum = 100;
			//use
			sum -= (b + r + g + c + s) * 3;
			sum -= ((b * 5) + (r * 3)) * 2;
			sum -= (t - (b + r + g + c + (s * 2) + (b * 5) + (r * 3))) * 3;
			//get
			sum += b * (1 + 5) * 15;
			sum += r * (1 + 3) * 15;
			sum += g * 7;
			sum += c * 2;

			System.out.println(sum);
		}
	}
}

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

int main() {
	//input
	string S;
	cin >> S;

	//calculation
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    x=int(input())
    ans=(x//500)*1000
    x=(x%500)
    ans+=(x//5)*5
    print(ans)
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		char[] S = stdIn.next().toCharArray();
		char[] T = stdIn.next().toCharArray();
		
		int cnt = 0;
		
		for(int i = 0; i < S.length; i ++) {
			if(S[i] != T[i]) {
				cnt ++;
			}
		}
		
		System.out.println(cnt);
	}
}

Measured memory_bytes: 41812
#include <iostream>
#define rep(n) for(int i=0;i<(n);i++)
using namespace std;

int main(void){
	int a[5];
	while(cin>>a[0],a[0]){
		cin>>a[1]>>a[2]>>a[3]>>a[4];
		int b[4];
		b[1]=0;
		b[2]=0;
		b[3]=0;
		rep(5)b[a[i]]++;
		if(b[1]>0&&b[2]>0&&b[3]>0||b[1]==5||b[2]==5||b[3]==5){
			rep(5) cout<<3<<endl;
			continue;
		}
		if(b[1]&&b[2]){
			rep(5){
				if(a[i]==1)cout<<"1"<<endl;
				else cout<<"2"<<endl;
			}
		}else if(b[2]&&b[3]){
			rep(5){
				if(a[i]==2)cout<<"1"<<endl;
				else cout<<"2"<<endl;
			}
		}else if(b[3]&&b[1]){
			rep(5){
				if(a[i]==3)cout<<"1"<<endl;
				else cout<<"2"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3072
n, m = list(map(int, input().split()))
b = [["W", 1] for _ in range(n)]
b[0] = ["R", 1]

for i in range(m):
    x, y = list(map(int, input().split()))

    b[x-1][1] -= 1
    if b[x-1][0] == "R":
        b[y-1] = ["R", b[y-1][1]+1]

        if b[x-1][1] == 0:
            b[x-1][0] = "W"
    else:
        b[y-1][1] += 1

cnt = 0
for i in range(n):
    if b[i][0] == "R":
        cnt += 1

print(cnt)

Measured memory_bytes: 17800
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


N,M=input2()

if N==M:
	print("Yes")
else:
	print("No")




Measured memory_bytes: 2940
package main

import "fmt"

const INF = 100100100

func fill(s []int, v int) {
	for i := range s {
		s[i] = v
	}
}

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

func main() {
	var H, N int
	fmt.Scan(&H, &N)
	A := make([]int, N)
	B := make([]int, N)
	for i := range A {
		fmt.Scan(&A[i], &B[i])
	}
	dp := make([]int, H+10000+10)
	fill(dp, INF)
	dp[0] = 0
	for i := 0; i <= H+10000; i++ {
		for j := 0; j < N; j++ {
			if i < A[j] {
				continue
			}
			dp[i] = min(dp[i], dp[i-A[j]]+B[j])
		}
	}
	ans := INF
	for i := H; i <= H+10000; i++ {
		ans = min(ans, dp[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long mpow(long long x,long long y){
  long long ans = 1;
  while(y){
    if(y%2) ans = (ans*x)%mod;
    x = (x*x)%mod;
    y >>= 1;
  }
  return ans;
}
long long mdiv(long long x){
  return ((x%mod==0) ? x/mod:mpow(x,mod-2));
}
int main(){
  long long n,m,i,j,t = 0,ans = 1;cin >> n >> m;
  j = m;vector<long long> p;
  for(i=2;i*i<=m;i++){
    if(j%i) continue;
    p.push_back(0);
    while(j%i==0){
      j /= i;p.back()++;
    }
    t = max(t,p.back());
  }
  if(j!=1) p.push_back(1);
  long long f[n+t] = {},d[max(n,t+1)] = {};f[0] = f[1] = 1;
  for(i=2;i<n+t;i++) f[i] = (f[i-1]*i)%mod;
  for(i=0;i<max(n,t+1);i++) d[i] = mdiv(f[i]);
  for(i:p) ans = ans*f[n+i-1]%mod*d[n-1]%mod*d[i]%mod;
  cout << ans << "\n";
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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; }

const int INF = 1001001001;
// long long max => LLONG_MAX

// Aの薬品a(g)とBの薬品b(g)をi番目までの薬品で作る最小の値段のdp
int dp[41][410][410];


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, ma, mb;
    cin >> n >> ma >> mb;
    
    for(int i = 0; i <= n; i++){
        for(int j = 0; j < 410; j++){
            for(int k = 0; k < 410; k++) dp[i][j][k] = INF;
        }
    }
    
    dp[0][0][0] = 0;


    for(int i = 0; i < n; i++){
        int a, b, c; cin >> a >> b >> c;
        for(int j = 0; j + a < 410; j++){
            for(int k = 0; k + b < 410; k++){

                // i番目の薬品を使う
                dp[i+1][j+a][k+b] = min(dp[i+1][j+a][k+b], dp[i][j][k]+c);

                //　使わない
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
            }
        }
    }
    
    int ans = INF;
    for(int i = 1; i < 410; i++){
        for(int j = 1; j < 410; j++){
            if(i * mb == j * ma) ans = min(ans, dp[n][i][j]);
        }
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 27136
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int a[] = new int[N];
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[N-1]-a[0]);
  }
  

  
}

Measured memory_bytes: 21076