akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int x = scan.nextInt();
        int t = scan.nextInt();
        int ans = (n + x - 1) / x * t;
        System.out.println(ans);
    }
}


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

using namespace std;
typedef long long nagai;

string cur;

int calc(string s)
{
	int ans = 0;
	for (auto& x : s)
		ans += x;
	return ans % 3;
}

int n;

vector<string> gg;

void gena(int x)
{
	if (cur.size() == n)
	{
		gg.push_back(cur);
		return;
	}
	for (char ch = 'a'; ch <= 'c'; ++ch)
	{
		cur.push_back(ch);
		gena(x + 1);
		cur.pop_back();
	}
}

bool bad(string s)
{
	for (int i = 0; i < n - 1; ++i)
		if (s[i + 1] == s[i])
			return true;
	return false;
}

void lol(string s)
{
	n = s.size();
	vector<string> q;
	set<string> used;
	used.insert(s);
	q.push_back(s);
	for (int i = 0; i < q.size(); ++i)
	{
		string x = q[i];
		for (int j = 0; j + 1 < x.size(); ++j)
			if (x[j] != x[j + 1])
			{
				char ch = 3 * 'b' - x[j] - x[j + 1];
				auto y = x;
				y[j] = y[j + 1] = ch;
				//cerr << x[j] + x[j + 1] - y[j] - y[j + 1] << '\n';
				if (!used.count(y))
					used.insert(y), q.push_back(y);
			}
		/*
			else
			{
				char ch = x[j] == 'a' ? 'b' : 'a';
				char ch1 = x[j] == 'b' ? 'c' : 'b';
				auto y = x;
				y[j] = ch;
				y[j + 1] = ch1;
				if (!used.count(y))
					used.insert(y), q.push_back(y);
				y[j] = ch1;
				y[j + 1] = ch;
				if (!used.count(y))
					used.insert(y), q.push_back(y);

			}
			*/
	}
	cout << q.size() << '\n';
}
int main()
{
	string s;
	cin >> s;
	bool fuck = true;
	for (int i = 0; i < s.size(); ++i)
		if (s[i] != s[0])
			fuck = false;
	if (fuck)
	{
		cout << 1 << endl;
		return 0;
	}
	if (s.size() <= 5)
	{
		lol(s);
		return 0;
	}
	n = s.size();
	nagai mod = 998244353;
	nagai cnt = 1;
	for (int i = 0; i < n - 1; ++i)
		cnt *= 3, cnt %= mod;
	vector<vector<vector<int>>> dp(n, vector<vector<int>>(3, vector<int>(3)));
	dp[0][0][0] = dp[0][1][1] = dp[0][2][2] = 1;
	for (int i = 0; i + 1 < n; ++i)
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k)
				for (int l = 0; l < 3; ++l)
				{
					if (k == l)
						continue;
					int j1 = j + l;
					if (j1 >= 3)
						j1 -= 3;
					dp[i + 1][j1][l] += dp[i][j][k];
					if (dp[i + 1][j1][l] >= mod)
						dp[i + 1][j1][l] -= mod;
				}
	int mem = calc(s);
	for (int i = 0; i < 3; ++i)
	{
		cnt -= dp[n - 1][mem][i];
	}
	if (!bad(s))
		++cnt;
	cnt %= mod;
	if (cnt < 0)
		cnt += mod;
	cout << cnt << '\n';
}


Measured memory_bytes: 39744
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(b%a==0)
    {
        cout<<a+b<<endl;
    }
    else
    {
        cout<<abs(a-b)<<endl;
    }

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >>n>>m;
  int c[m];
  for(int i=0;i<m;i++){
    int num;
    cin>>c[i]>>num;
  }
  sort(c,c+m);
  int count=0;
  for(int i=1;c[i]<n;i++){
    count+=n-c[i];
  }
  cout <<count<<endl;
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;

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

	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=1;i<n;i++)
	{
		if(a[i]==a[i-1])
		{
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";

} 
// I never lose. I either win or I learn

Measured memory_bytes: 1792
import java.io.*;
import java.util.ArrayList;
import java.util.List;

class Main {
    public static void main(String[] args) {
        try {
        	int point = 0;
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line;
            List<String> runner = new ArrayList<>();
            List<String> out = new ArrayList<>();
            while((line = br.readLine()) != null){
            int cntRunner = runner.size();
            if(line.equals("HIT")){
            	if(cntRunner == 3){
            		point++;
            	}else if (cntRunner < 3){
            	runner.add(line);
            	}
            }else if(line.equals("HOMERUN")){
            	point = point + cntRunner + 1;
            	runner.clear();
            }else if(line.equals("OUT")){
            	out.add(line);
            	int cntOut = out.size();
            	if(cntOut == 3){
            		System.out.println(point);
            		point = 0;
            		runner.clear();
            		out.clear();
            	}
              }
           }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    ll n, d; cin >> n >> d;
    int ans = 0;
    FOR(i, 1, n) {
        ll p, q; cin >> p >> q; 
        if (p * p + q * q <= d * d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==5&&a[1]==5&&a[2]==7)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

int main(){
    int n, m,i;
    int a[n];

    cin >> n >> m;
    for (i = 0; i <= n-1;i++){
        cin >> a[i];
    }

    int all = 0;

    for (i = 0; i <= n-1; i++)
    {
        all += a[i];
    }

    int s, t;

    for(s=0;s<n-1;s++){
        for (t = s + 1; t < n;t++){
            if(a[t]>a[s]){
                int temp = a[t];
                a[t] = a[s];
                a[s] = temp;
            }
        }
    }

    int count = 0;
    double allD = double(all) / (4.0 * double(m));

    for (i = 0; i < m;i++){
        if(a[i]>=allD){
            count++;
        }
    }

        if (count == m)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[500005];
int b[500005];
long long res=0;
void merge(int l,int r){
	int m=(l+r)/2;
	// l,m    m+1,r
	int p1=l,p2=m+1;
	for(int i=l;i<=r;i++){
		if(p2>r||(p1<=m&&a[p1]<=a[p2])){
			b[i]=a[p1];
			p1++;
		}else{
			res+=m-p1+1;
			b[i]=a[p2];
			p2++;
		}
	}
	for(int i=l;i<=r;i++)a[i]=b[i];
}
void ms(int l,int r){
	if(l>=r)return;
	ms(l,(l+r)/2);
	ms((l+r)/2+1,r);
	merge(l,r);
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//	freopen("1010.in","r",stdin);
//	freopen("b.txt","w",stdout);
	while(cin>>n){
		for(int i=1;i<=n;i++)cin>>a[i];
		ms(1,n);
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 4732
#include <stdio.h>
#define MAX_N 100000
typedef struct e{
  int a[1000];
  int point;
  int point2;
}el;
int max(int a,int b){
  if(a>b)return a;
  else return b;
}
int s[MAX_N+1];
el edge[MAX_N+1];
int dp[MAX_N];
int main(){
  int n,m;
  int x,y;
  int i,j;
  int idx = 0;

  scanf("%d %d", &n,&m);
  for(int i=0; i<m;i++){
    scanf("%d %d", &x, &y);
    edge[x-1].a[edge[x-1].point] = y-1;
    edge[x-1].point+=1;
    edge[y-1].point2 += 1;
  }


  for(int i=0; i<n; i++){
    if(edge[i].point2==0)s[idx++]=i;
  }
  j = 0;
  while(j<idx){
    for(int k=0; k<edge[s[j]].point; k++){
      edge[edge[s[j]].a[k]].point2 -= 1;
      if(edge[edge[s[j]].a[k]].point2==0){
        s[idx++] = edge[s[j]].a[k];
      }
    }
    j+=1;
  }
  int ans = 0;
  for(i=n-1;i>-1;i--){
    //printf("%d: ", s[i]);
    for(j=0;j<edge[s[i]].point;j++){
      //printf("%d ", edge[s[i]].a[j]);
      dp[s[i]] = max(dp[s[i]], dp[edge[s[i]].a[j]]+1);
    }
    ans = max(ans, dp[s[i]]);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 392320
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;cin >> N;
    int ans = 11451419;
    for(int i = 1;i<N;i++){
        int A = i;
        int B = N-i;
        int digitsum = 0;
        while(A > 0){
            digitsum += A%10;
            A /= 10;
        }
        while(B > 0){
            digitsum += B%10;
            B /= 10;
        }
        ans = min(ans,digitsum);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n; cin >> n;
	if ((n / 10) == 9) cout << "Yes" << endl;
	else if ((n % 10) == 9) cout << "Yes" << endl;
	else cout << "No" << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int ans = 0;

	for(int i=1; i<=N; i++){

	String n = Integer.toString(i);

	if(n.length()%2 == 1){

	ans += 1;

}
}

	System.out.println(ans);

 }
}

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

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

  vector<int> a(n);

  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }

  int ans = 0;

  for(int i = 1; i < n - 1; i++){
    if((a.at(i - 1) < a.at(i) && a.at(i) < a.at(i + 1)) || (a.at(i - 1) > a.at(i) && a.at(i) > a.at(i + 1))){
      ans++;
    }
  }

  cout << ans << endl;

  
}

Measured memory_bytes: 256
S, T = input().split()
A, B = map(int, input().split())
U = input()

if S == U:
  out_1 = A - 1
  if out_1 < 0: out1 = 0
  out_2 = B
  print(out_1, out_2)

if T == U:
  out_1 = A
  out_2 = B -1
  if out_2 < 0: out_2 = 0
  print(out_1, out_2)

Measured memory_bytes: 3064
import java.io.*;
class Main
{
public static void main(String args[])throws IOException
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));

int sum=0;
for(int i=0;i<4;i++)
{
sum+=Integer.parseInt(input.readLine());
}
System.out.println(sum/60);
System.out.println(sum%60);
}
}

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

from collections import deque

N,M = map(int,readline().split())
if M == 0:
    print(-1)
    exit()
m = map(int,read().split())
P,Q,C = zip(*zip(m,m,m))

V = []
V += [p<<32 for p in range(1,N+1)]
V += [(p<<32)+c for p,c in zip(P,C)]
V += [(q<<32)+c for q,c in zip(Q,C)]
V = set(V)
label = {x:i for i,x in enumerate(V)}
start = label[1<<32]
goal = label[N<<32]

N = len(V)
graph = [[] for _ in range(N)]
for p,q,c in zip(P,Q,C):
    v0 = label[p<<32]; v1 = label[(p<<32)+c]
    w0 = label[q<<32]; w1 = label[(q<<32)+c]
    graph[v0].append((v1,1))
    graph[w0].append((w1,1))
    graph[v1].append((v0,0))
    graph[w1].append((w0,0))
    graph[v1].append((w1,0))
    graph[w1].append((v1,0))

INF = 10 ** 10
dist = [INF] * N
dist[start] = 0
q = deque([start])
ar = q.append; al = q.appendleft
pl = q.popleft
while q:
    v = pl()
    for w,cost in graph[v]:
        dw = dist[v] + cost
        if dw >= dist[w]:
            continue
        dist[w] = dw
        if not cost:
            al(w)
        else:
            ar(w)

answer = dist[goal]
if answer == INF:
    answer = -1
print(answer)

Measured memory_bytes: 184860
using System;
using System.Collections.Generic;

class ExceptionHandling
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var temp = new int[N];
        var sortedArray = new int[N];
        var secondMax = 0;
        var max = 0;
        var canSearch = true;
        var existsMultipleMaxVal = false;

        for (var i = 0; i < N; i++)
        {
            temp[i] = int.Parse(Console.ReadLine());
            sortedArray[i] = temp[i];
        }

        Array.Sort(sortedArray);

        max = sortedArray[N - 1];

        //お隣さんも最大値である場合、最大値は複数存在する
        if (max == sortedArray[N - 2])
        {
            existsMultipleMaxVal = true;
        }

        //初期化時は最大値を入れとく
        secondMax = sortedArray[N - 1];

        for (var i = 0; i < N; i++)
        {
            if (temp[i] < max)
            {
                Console.WriteLine(max);
            }
            else if (temp[i] == max)
            {
                if (existsMultipleMaxVal)
                {
                    Console.WriteLine(max);
                }
                //2番目に大きい値が必要になった時に1回だけ値を探しに行く。
                else if (canSearch)
                {
                    //ケツから探索して2番目に大きい値を探す
                    for (var j = N - 1; j > 0; j--)
                    {
                        if (max > sortedArray[j - 1])
                        {
                            secondMax = sortedArray[j - 1];
                            canSearch = false;
                            break;
                        }
                    }
                    Console.WriteLine(secondMax);
                }
            }
        }
    }
}


Measured memory_bytes: 18004
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      int N=int.Parse(Console.ReadLine());
      int x=0;
      x +=1000*(N/500);
      x +=5*((N%500)/5);
      Console.WriteLine(x);

  }
}
}


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


int first(int n){
    int first=n;
    while(first>9){
        first = first/10;
    }
    return first;
}


void pre_calc(int n, int table[10][10]){
    for(size_t tmp=n;tmp>0;tmp--){
        table[first(tmp)][tmp%10]+=1;
    }
}



int main(){
    // あとで消す
    //std::ifstream in("din1.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    cin >> N;

    int table[10][10];

    for(size_t i=0;i<=9;i++){
        for(size_t j=0;j<=9;j++){
            table[i][j] = 0;
        }
    }

    /*
    for(size_t i=1;i<=9;i++){
        for(size_t j=1;j<=9;j++){
            printf("%d, ",table[i][j]);
        }
        printf("\n");
    }
    */

    pre_calc(N, table);
    //cout << endl;

    /*
    for(size_t i=1;i<=9;i++){
        for(size_t j=1;j<=9;j++){
            printf("%d, ",table[i][j]);
        }
        printf("\n");
    }
    */

    int count = 0;
    for(size_t i=1;i<=9;i++){
        for(size_t j=1;j<=9;j++){
            count += table[i][j]*table[j][i];
        }
    }
    cout << count <<endl;

    return 0;
}


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

using namespace std;

int main(){

	string s;
	string ans = "";
	cin >> s;
	for(int i = 0; i < s.length(); ++i){
		if(s[i] == '0'){
			ans += "0";
		}
		if(s[i] == '1'){
			ans += "1";
		}
		if(s[i] == 'B'){
			if(ans.length() == 0){}
			else{
				ans = ans.substr(0, ans.length() - 1);
			}
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>

using namespace std;

int main() {
  int A,B,C;
  string s="No";
  cin >> A >> B >> C;

  if (A==B && B==C) {
    s = "Yes";
  }

  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#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 dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

map<int, int> mp;
int func(int n){
  if(n%2 == 0)return n/2;
  return 3*n+1;
}
signed main(){
  int n;
  scanf("%lld", &n);
  mp[n] = 1;
  repi(i,2,inf){
    n = func(n);
    if(mp[n]){
      printf("%lld\n", i);
      return 0;
    }
    mp[n]++;
  }
  return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W; cin>>H>>W;
  int a[H+2][W+2];
  int N = 0;
  int p[250010],q[250010],r[250010],s[250010];
  REP1(i,H) {
    REP1(j,W) {
      cin>>a[i][j];
    }
  }

  REP1(i,H-1) {
    REP1(j,W) {
      if(a[i][j] % 2 == 1) {
        N++;
        a[i+1][j]++;
        p[N]=i;
        q[N]=j;
        r[N]=i+1;
        s[N]=j;
        // cout<<a[i]<<" "<<a[j]<<" "<<a[i+1]<<" "<<a[j]<<endl;
      }
    }
  }

  REP1(j,W-1) {
    if(a[H][j] % 2 == 1) {
      N++;
      a[H][j+1]++;
      p[N]=H;
      q[N]=j;
      r[N]=H;
      s[N]=j+1;
      // cout<<a[H]<<" "<<a[j]<<" "<<a[H]<<" "<<a[j+1]<<endl;
    }
  }

  cout<<N<<endl;
  REP1(i,N) {
    cout<<p[i]<<" "<<q[i]<<" "<<r[i]<<" "<<s[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;
int main() {
ll K, S, Ans = 0;cin >> K >> S;
vector<ll> A;

rep(i, 0, K + 1)A.push_back(i);

rep(x, 0, K + 1){
rep(y, 0, K + 1){

auto Iter1 = A.end() - upper_bound(ALL(A), S - x - y);
auto Iter2 = lower_bound(ALL(A), S - x - y) - A.begin();
ll N = K + 1 - Iter1 - Iter2;
Ans+=N;

}
}
cout << Ans;
}

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

int main() {
	string s;
	cin >> s;
	rep(i, s.size()){
		if(i%2 == 0 && s[i] == 'L'){
			cout << "No";
			return 0;
		}else if(i%2 == 1 && s[i] == 'R'){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	long int max = -1000000000;
	long int ri;
	long int rj;
	int loop;

	cin >> loop;
	cin >> ri;

	for (int i = 0; i < loop - 1; i++) {
		cin >> rj;
		if (max < rj - ri) {
			max = rj - ri;
		}

		if (ri > rj) {
			ri = rj;
		}
		//cout << "price : " << Ri << endl;
		//cout << "currentPrice : " << Rj << endl;
	}
	cout << max << endl;

	return 0;
}


Measured memory_bytes: 3112
import sys
sys.setrecursionlimit(10000)
n,m=map(int,input().split())
bra=[set() for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    bra[a-1].add(b-1)
    bra[b-1].add(a-1)

visit=[1]+[0]*(n-1)
#print(bra)
cnt=[]
def dfs(a,visit):
    if visit==[1]*n:
        cnt.append(1)
        return 
    for e in bra[a]:
        if visit[e]==0:
            visit[e]=1
#            print(visit)
            dfs(e,visit)
            visit[e]=0  
    return 
dfs(0,visit)
print(len(cnt))

Measured memory_bytes: 3064
#include <stdio.h>

int digit(int x);

int main(void)
{
	int a, b;
	
	while (scanf("%d %d", &a, &b) != EOF){
		printf("%d\n", digit(a + b));
	}
	
	return (0);
}

int digit(int x)
{
	int n;
	
	n = 0;
	while (x > 0){
		x /= 10;
		n++;
	}
	
	return (n);
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i=0;i<N;i++) cin >> A[i];
    int mx = A[0];
    ll ans = 0;
    for (int i=1;i<N;i++){
        if (mx > A[i]) {
            ans += mx - A[i];
        } else {
            mx = A[i];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3956
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		boolean possible = true;
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int c = input.nextInt();
		if (a != b && a == c) {
			System.out.println(b);
		} else if (a == b && a != c) {
			System.out.println(c);
		} else {
			System.out.println(a);
		}
	}
}


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

int main() {
  int a[3]; cin >> a[0] >> a[1] >> a[2]; sort(a, a + 3);
  cout << (a[1] - a[0]) / 2 + (a[1] - a[0]) % 2 * 2 + a[2] - a[1] << '\n';
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define vec vector
#define DEBUG 0
const ll MOD = 1000000007;
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

void solve()
{
    ll H,W,h,w;
    cin >> H >> W;
    vec<string> S(H);
    vec<vec<ll>> dp(H, vec<ll>(W, 0));
    for1(h,H) {
        cin >> S[h];
    }
    dp[0][0] = 1;
    for1(h,H) {
        for1(w,W) {
            //cout << h << " " << w << endl;
            if (S[h][w] == '.') {
                if (h > 0) {
                    dp[h][w] += dp[h-1][w];
                }
                if (w > 0) {
                    dp[h][w] += dp[h][w-1];
                }
                dp[h][w] %= MOD;
            }
        }
    }

    cout << dp[H-1][W-1] << endl;
}

int main()
{
    do {
        solve();
    } while (DEBUG);
}


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

typedef long double ld;									//XD
#define int long long   
#define PB push_back 
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int> 
#define vii vector< ii >
#define F first
#define S second 
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);         
#endif
}

const int mod = 1e18+7;
const int maxn = 2e3+5;

void solve(){
	int n; cin>>n;
	int ans = INT_MAX;
	rep(i, 1, 11){
		int z = 1000*i-n;
		if(z >= 0) ans = min(ans, z);
	}
	cout<<ans;
}
signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);// io();
    cout<<setprecision(16);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}


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

int main(){
	
	int k;
	char s[102];
	
	scanf ("%d", &k);
	scanf ("%s", &s);
	int l = strlen(s);
	
	if (k < l){
	
	for (int i = 0; i < k; i++){
		printf ("%c", s[i]);
	}printf ("...");
}
	else {
		for (int j = 0; s[j] != '\0'; j++){
			printf ("%c", s[j]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1688
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <unordered_map>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    string S, T;
    cin >> S >> T;
    unordered_map<char, int> ss;
    vector<int> ves;
    int num = 0;
    rep(i, 0, S.size()) {
        if(ss.count(S[i]) != 0) {
            ves.push_back(ss[S[i]]);

        } else {
            ss.emplace(S[i], num);
            ves.push_back(num);
            num++;
        }
    }
    unordered_map<char, int> st;
    vector<int> vet;
    int num2 = 0;
    rep(i, 0, T.size()) {
        if(st.count(T[i]) != 0) {
            vet.push_back(st[T[i]]);

        } else {
            st.emplace(T[i], num2);
            vet.push_back(num2);
            num2++;
        }
    }
    bool res = true;
    rep(i, 0, S.size()) {
        if(ves[i] != vet[i]) {
            res = false;
        }
    }
    if(res) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s;
    cin >> s;
    set<int> st;
    int x = s;
    while(st.count(x) == 0){
        st.insert(x);
        if(x % 2 == 0) {
            x /= 2;
        }
        else {
            x = x * 3 + 1;
        }
    }
    cout << st.size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 3e5+1;
const ll inf = 1e12;
ll mod = 1e9+7;
ll n;

struct Matrix{
	ll e[51][51];
};
Matrix uni;
Matrix mul(Matrix a,Matrix b){
	Matrix ans;
	f(i,0,n){
		f(j,0,n){
			ans.e[i][j] = 0;
			f(k,0,n){
				(ans.e[i][j] += (a.e[i][k]*b.e[k][j] )%mod )%=mod;
			}
		}
	}
	return ans;
}

Matrix bp(Matrix a, ll e){
	if(e == 0) return uni;
	if(e&1) return mul(a,bp(a,e-1));
	Matrix x = bp(a,e>>1);
	return mul(x,x); 
}

int main(){
	ll tc,k;
	tc = 1;	
	while(tc--){
		Matrix x;
		cin >> n >> k;
		f(i,0,n) f(j,0,n) uni.e[i][j] = (i==j? 1:0);
		f(i,0,n) f(j,0,n) cin >> x.e[i][j];		
		ll ans = 0;
		Matrix res = bp(x,k);
		f(i,0,n) f(j,0,n) ans += res.e[i][j];
		cout << ans%mod << endl;
	}
}



Measured memory_bytes: 13048
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
const int Mod = 1e9 + 7; 
const int MAX_N = 3e3 + 5; 
int N, M; 
int f[MAX_N][MAX_N][2]; 
void pls(int &x, int y) { x += y; if (x >= Mod) x -= Mod; } 
int main () { 
	cin >> N >> M; 
	f[0][0][1] = 1; 
	for (int i = 1; i <= N; i++) f[0][i][0] = 1; 
	for (int i = 0; i < M; i++) 
		for (int j = 0; j <= N; j++) { 
			if (j >= 1) {
				//2 black
				pls(f[i + 1][j - 1][1], f[i][j][1]); 
				if (j == 1) pls(f[i + 1][j - 1][1], f[i][j][0]); 
				else pls(f[i + 1][j - 1][0], f[i][j][0]); 
			} 
			if (j < N) { 
				//2 white
				pls(f[i + 1][j + 1][1], f[i][j][1]); 
				pls(f[i + 1][j + 1][0], f[i][j][0]); 
			} 
			if (j >= 1) { 
				//1 black 1 white 
				pls(f[i + 1][j][1], f[i][j][1]); 
				if (j == 1) pls(f[i + 1][j][1], f[i][j][0]); 
				else pls(f[i + 1][j][0], f[i][j][0]); 
			} 
			if (j < N) { 
				//1 white 1 black 
				pls(f[i + 1][j][1], f[i][j][1]); 
				pls(f[i + 1][j][0], f[i][j][0]); 
			} 
		} 
	int ans = 0; 
	for (int i = 0; i <= N; i++) pls(ans, f[M][i][1]); 
	printf("%d\n", ans); 
    return 0; 
} 

Measured memory_bytes: 70656
#include<stdio.h>

int return_min(int a,int b)
{
  if(a>b){
    return b;
  }else{
    return a;
  }
}

int main(void)
{
  int n;
  scanf("%d",&n);
  int a[n];
  int b[n-1];
  for(int i=0;i<n-1;i++){
    scanf("%d",&b[i]);
  }
  a[0]=b[0];
  a[n-1]=b[n-2];
  for(int i=1;i<n-1;i++){
    a[i]=return_min(b[i-1],b[i]);
  }
  int result=0;
  for(int i=0;i<n;i++){
    result+=a[i];
  }
  printf("%d\n",result);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N, K;
int ans = 0;
int X, Y;

int main(){
	
	
	cin>>N>>K;
	cin>>X>>Y;
	
	if( K < N ){
		ans = X*K+(N-K)*Y;
	}
	else{
		ans = N*X;
	}
	
	cout<<ans<<endl;
	
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct Block
{
    int s,t,x;
};
int main()
{
    int n,q;
    cin>>n>>q;
    vector<Block> blocks(n);
    for(int i=0;i<n;++i)cin>>blocks[i].s>>blocks[i].t>>blocks[i].x;
    vector<int> men(q);
    vector<vector<int>> flags(q);
    for(int i=0;i<q;++i)cin>>men[i];
    for(auto b:blocks)
    {
        int s = b.s - b.x;
        int s_id = lower_bound(men.begin(),men.end(),s) - men.begin();
        int t = b.t - b.x;
        int t_id = lower_bound(men.begin(),men.end(),t) - men.begin();
        if(s_id < q)
            flags[s_id].emplace_back(b.x);
        if(t_id < q)
            flags[t_id].emplace_back(-b.x);
    }
    multiset<int> tokens;
    for(int i=0;i<q;++i)
    {
        sort(flags[i].begin(),flags[i].end(),greater<int>());
        for(int f:flags[i])
        {
            if(f>0)
            {
                tokens.insert(f);
            }else
            {
                tokens.erase(tokens.find(-f));
            }
        }
        if(tokens.size())
        {
            cout<<*tokens.begin()<<endl;
        }else
        {
            cout<<-1<<endl;
        }
    }
}

Measured memory_bytes: 25460
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b){
            System.out.println("a > b");
        }else if(a < b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26384
#include <cstdio>
using ll = long long;
ll cube(ll x) {
  return x * x * x;
}
int main() {
  ll n, k; scanf("%lld%lld", &n, &k);
  ll even_b = n / k;
  if(1LL & k) {
    printf("%lld\n", cube(even_b));
  } else {
    ll odd_b = n / (k / 2) - even_b;
    ll ans = cube(even_b) + cube(odd_b);
    printf("%lld\n", ans);
  }
  return 0;
}

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

void solve(vector<int> &a, vector<int> &b, vector<int> &c){
    int n = a.size();
    vector<vector<int>> dp(n, vector<int>(3, 0));
    
    // Base Cases
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    
    // Filling the dp table
    for(int i = 1 ; i < n ; i++){
        dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
        dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
    }
    
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

int main(){
    // INPUT
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
    }
    
    // OUTPUT
    solve(a, b, c);
}

Measured memory_bytes: 9792
m, d = map(int, input().split())
ans = 0
if d < 10:
  print(0)
  exit()
for i in range(10, d+1):
  a, b = map(int, str(i))
  if a * b <= m and a >= 2 and b >= 2:
    ans += 1

print(ans)

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    int x = n / 500;
    n %= 500;
    cout << x * 1000 + n / 5 * 5;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

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

using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 2e9;

int N, A, B, C;
vector<int> l(1000);

int dfs(int cur, int a, int b, int c) {
  if (cur == N) {
    if (a * b * c > 0) return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    else return INF;
  }
  int x = dfs(cur + 1, a, b, c);
  int y = dfs(cur + 1, a + l[cur], b, c) + 10;
  int z = dfs(cur + 1, a, b + l[cur], c) + 10;
  int w = dfs(cur + 1, a, b, c + l[cur]) + 10;
  return min({x, y, z, w});
}

int main() {
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; ++i) cin >> l[i];
  cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
n=int(input());D=list(map(int,input().split()))
m=int(input());T=list(map(int,input().split()))
dic1={};dic2={}
for d in D:
  dic1.setdefault(d,0)
  dic1[d]+=1
for t in T:
  dic1.setdefault(t,0)
  dic2.setdefault(t,0)
  dic2[t]+=1

x="YES"
for k in dic2:
  if dic2[k]>dic1[k]:
    x="NO";break
print(x)

Measured memory_bytes: 56672
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n,m;
    cin>>n>>m;
    int s,c;
    int ans;
    int ret=0;
    string k2;
    vector<int>vs(m);
    vector<int>vc(m);
    for(int i=0; i<m; i++){
        cin>>s>>c;
        s--;
        vs.at(i)=s;
        vc.at(i)=c;
    }
    for(int k=0; k<=999; k++){
        k2=to_string (k)  ;
        if(k2.size()!=n){
            continue;
        }
        ret=0;
        for(int j=0; j<m; j++){
            if(k2.at(vs.at(j))!=vc.at(j)+'0'){
                ret++;
            }
        }
        if(ret==0){
            cout<<k2<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
}


Measured memory_bytes: 3680
/**
 *    author:   K.R.Surrya  
 *    created:  03/05/2020 17:32:26
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() { 
    int N,K;
    cin >> N >> K;
    vector<bool> visited(N+1,false);
    while(K--) { 
        int d;
        cin >> d;
        while(d--) { 
            int x;
            cin >> x;
            if(!visited[x])
            visited[x]=true;
        }
    }
    int ret=0;
    for(int i=1;i<=N;++i) { 
        if(!visited[i]) ++ret;
    }
    cout << ret << '\n';
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

     auto start = chrono::high_resolution_clock::now();
     solve();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string a,b;

int main()
{
	getline(cin,a),getline(cin,b);
	for(int i=0;i<a.size();i++)
	{
		cout << a[i];
		if(i<b.size())
			cout << b[i];
	}
	cout << '\n';
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
b,c,d=[],set([]),0
for i in range(200000):
    b.append(d)
    c.add(d)
    if len(b)!=len(c):
        break
    d=a[d]-1
for i in range(len(b)):
    if b[-1]==b[i]:
        e=i
        break
if k<e:
    print(b[k]+1)
else:
    print(b[(k-e)%(len(b)-e-1)+e]+1)

Measured memory_bytes: 35456
# -*- coding: utf-8 -*-

import sys
import os

for s in sys.stdin:
    n = int(s) # node num
    if n == 0:
        break

    m = int(input()) # edge num

    # adjacency matrix
    M = [[float('inf') for i in range(n)] for j in range(n)]

    for i in range(m):
        a, b, d = map(int, input().split(','))
        M[a][b] = d
        M[b][a] = d

    for i in range(n):
        M[i][i] = 0

    X = [] # selected
    Y = [i for i in range(n)] # not selected

    X.append(0)
    Y.remove(0)

    light_num = 0
    while len(X) != n:
        lst = []
        for x in X:
            for y in Y:
                dist = M[x][y]
                lst.append((dist, x, y))
        lst.sort()

        # selected node
        dist, x, y = lst[0]
        light_num += (dist // 100) - 1

        if x not in X:
            X.append(x)
            Y.remove(x)
        else:
            X.append(y)
            Y.remove(y)
    print(light_num)

Measured memory_bytes: 8128
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B, C, X;
  cin >> A >> B >> C >> X;
  ll sum = 0;
  REP(a, 0, A+1) {
    REP(b, 0, B+1) {
      REP(c, 0, C+1) {
        if (a * 500 + b * 100 + c * 50 == X) {
          sum++;
        }
      }
    }
  }
    cout << sum << endl;


  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include <set>
#define ff(i,m,n) for(int i=m;i<n;i++)
#define i64 int64_t
using namespace std;


int main() {
	int a, b;
	cin >> a;
	char c;
	cin >> c >> b;
	if (c == '+') {
		cout << a + b << endl;
			return 0;
	}
	cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
	long long int c;
	scanf ("%lld", &c);
	long long int sum = 0;
	for (int i = 1; i <= c; i++){
		if (i % 3 == 0 && i % 5 == 0){
			continue;
		}else if (i % 3 == 0){  
		    continue;
		}else if (i % 5 == 0){
			continue;
		}else {
			sum += i;
		}
	}
	printf ("%lld", sum);
	return 0;
}

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

int main(){
  int n,x,y;
  cin >> n;
  for(int i = 1;i * i <= n;i++){
    if(n % i == 0 && i < 10 && n / i < 10){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cout << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  double s = 0.0;
  ini(N);
  rep(i,N){
    double c; in(c);
    s += 1.0 / c;
  }
  out(1.0 / s);

}

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

bool pal(string& s){
	int l = 0, r = s.size()-1;
  while(l<r){
  	if (s[l]!=s[r]){return false;}
    l++;r--;
  }
  return true;
}

int main(){
  string s;cin>>s; int n = s.size();
  string s1 = s.substr(0,n/2), s2 =s.substr(n/2+1, n/2); 
	bool ans = (pal(s) && pal(s1) && pal(s2));
  cout<<(ans?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
import sys

N = int(input())
A = list(map(int,input().split()))

for n in range(N):
  if A[n] >  n+1:
    print(-1)
    sys.exit()

ans = []

while A != []:
  tmp = 0
  for p in range(len(A)):
    if A[p] == p+1:
      tmp = p
  ans.insert(0,A.pop(tmp))

  
for x in ans:
  print(x)

Measured memory_bytes: 8960
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define rep(j, n) for (int i = j; i < n; i++)
#define repd(j, n) for (int i = j; i > n; i--)
#define maxx 100010

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;


int main() {
		int a, b, ans;
		cin >> a >> b;
		if (b%a == 0) {
			ans = a + b;
		}
		else {
			ans = b - a;
		}
		cout << ans;
		return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String input = sc.next();
		if (input.length() <= N) {
			System.out.println(input);
		} else {
			System.out.println(input.substring(0, N) + "...");
		}
	}
}

Measured memory_bytes: 38724