akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
//#include<CastingInterop.h>
#include<string>
using namespace std;

int main()
{
    char arr[3];
    int arr1[3];
    string y;
    for (int i = 0; i < 3; i++)
    {
        cin >> arr[i];
    }
    string s[1000];
    for (int i = 0; i < 3; i++)
    {
        s[i] = arr[i];

    }
    for (int i = 0; i < 3; i++)
    {
        s[i] += s[i + 1] + s[i + 2];
    }

    //cout << s[0];
    string w;
    w = s[0];
    //cout << w;
    int num = stoi(w);
    if (num % 4 == 0)
        cout << "YES";
    else
        cout << "NO";
}

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

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

  int c = a * b;
  if ((a * b) % 2 == 0)
  {
    cout << "No";
  }

  else
  {
    cout << "Yes";
  }

  // cout << (a * b) % 2;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   int N;
   string S;
   cin>>N>>S;

   int left=0,right=0;
   int sum1 = 0;
   for(int i=0;i<N;i++){
      if(sum1 == 0){
         if(S[i] == ')')left++;
         if(S[i] == '(')sum1++;
      }
      else{
         if(S[i] == ')')sum1--;
         if(S[i] == '(')sum1++;
      }
   }
   int sum2 = 0;
   for(int i=N-1;i>=0;i--){
      if(sum2 == 0){
         if(S[i] == '(')right++;
         if(S[i] == ')')sum2++;
      }
      else{
         if(S[i] == '(')sum2--;
         if(S[i] == ')')sum2++;
      }
   }
   //cout<<S<<endl;
   //cout<<right<<" "<<left<<endl;
   for(int i=0;i<right;i++)S = S+')';
   for(int i=0;i<left;i++) S = '('+S;
   cout<<S<<endl;
   return 0;
}


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

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


// Write From This Line
int main()
{
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;
	if(10 % p == 0 ){
		// p  = 5 か2
		ll ans = 0;
		rep(r,n){
			if((s[r] - '0') % p == 0) {
				// 右端がpの倍数なので，左箸が何通りあるか
				ans += r + 1;
			}
		}
		cout << ans << endl;
		return 0; //sample 2
	}

	vector<int> d(n+1);// 累積和 後ろから求めたい
	int ten = 1;
	for (int i = n-1; i >= 0; i--){
		int a = (s[i]-'0') * ten % p;
		d[i] = (d[i+1] + a) % p;
		ten *= 10; ten %= p;
	}
	vector<int> cnt(p);
	ll ans = 0;
	for (int i = n; i >= 0; i--){ // i = n -1 スタートだと違う
		ans += cnt[d[i]];
		cnt[d[i]]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int a, b;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> a >> b;
  int rest = 1;
  int ans = 0;
  while (rest <= 20 && rest < b) {
    rest = rest - 1 + a;
    ans++;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n + 1];
            int b[] = new int[n];
            for (int i = 0; i < n + 1; i++) {
                a[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long answer = 0;
            for (int i = n - 1; i >= 0; i--) {
                if (b[i] >= a[i + 1]) {
                    answer += a[i + 1];
                    b[i] -= a[i + 1];
                    if (b[i] <= a[i]) {
                        a[i] -= b[i];
                        answer += b[i];
                    } else {
                        answer += a[i];
                        a[i] = 0;
                    }
                } else {
                    answer += b[i];
                }
            }
            out.println(answer);
        }

    }
}



Measured memory_bytes: 64096
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int i,n;cin>>n;
	cout<<n*180-360<<endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement as cwr , combinations , permutations
n=int(input())
a=tuple([int(i) for i in input().split()])
b=tuple([int(i) for i in input().split()])
ans=list(permutations(list(range(1,n+1))))
print(abs(ans.index(a)-ans.index(b)))

    
    

        

Measured memory_bytes: 8052
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
#define ll long long int
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int ctoi(char c) {
	return c - '0';
}



int main() {
	string S;
	cin >> S;
	if (S[1] == 'R')
		cout << "ABC";
	else
		cout << "ARC";
	return 0;
}

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

typedef long long LL;

const int N = 25;

int d;
LL p[N];
int sub1[N], sub2[N];      // sub1 not front, sub2 is front

vector <LL> v;

void dfs(int s, int e, vector <pair <LL, LL> > &w, LL val, LL cnt){
    if (s == e){
        w.push_back(make_pair(val, cnt));
        return ;
    }

    for (int i = -9; i < 10; i++)                     // 枚举差值
        dfs(s + 1, e, w, val + i * v[s], cnt * (s ? sub1[i + 10] : sub2[i + 10]));
}

LL solve(int len){
    v.clear();
    for (int i = 0; i < len - 1 - i; i++) v.push_back(p[len - 1 - i] - p[i]);

    vector <pair <LL, LL> > v1, v2;
    dfs(0, (v.size() + 1) >> 1, v1, 0, 1);
    dfs((v.size() + 1) >> 1, v.size(), v2, 0, 1);

    LL ans = 0;
    map <LL, LL> mp;
    for (int i = 0; i < v2.size(); i++) mp[v2[i].first] += v2[i].second;
    for (int i = 0; i < v1.size(); i++) ans += mp[d - v1[i].first] * v1[i].second;

    if (len & 1) ans *= 10;
    return ans;
}

int main(){
    p[0] = 1;
    for (int i = 1; i < 20; i++) p[i] = p[i - 1] * 10;
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 10; j++) sub1[i - j + 10]++;
    for (int i = 0; i < 10; i++)
        for (int j = 1; j < 10; j++) sub2[i - j + 10]++;

    scanf("%d", &d);
    LL ans = 0;
    for (int i = 2; i <= 18; i++) ans += solve(i);

    printf("%lld", ans);

    return 0;
}

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

using namespace std;

int main(){
  int s, a;
  const int M = 1000000;
  vector<char> flag(M, 0);
  cin >> s;
  flag[s] = 1;
  a = s;
  for( int i = 2; i < M; ++i ){
    if( a & 1 ){
      a = 3*a+1;
    }else{
      a = a/2;
    }
    if( flag[a] == 0 ){
      flag[a] = 1;
    }else{
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

int main(){
    int T,i,j,n;
    map<string,int> mp;

    cin>>n;
    string s;
    string a[n+1];
    int p=1;
    int cnt[n+1];
    memset(cnt,0,sizeof(cnt));

    for(i=0;i<n;i++){
        cin>>s;
        if(mp.find(s)==mp.end()){
            mp[s]=p;
            a[p]=s;
            cnt[p]=1;
            p++;
        }
        else{
            cnt[mp[s]]++;
        }
    }

    set<string> st;
    int mx=0;
    for(i=1;i<p;i++){
        if(cnt[i]>mx) mx=cnt[i];
    }
    for(i=1;i<p;i++){
        if(cnt[i]==mx){
            st.insert(a[i]);
        }
    }
    for(set<string>:: iterator itr=st.begin();itr!=st.end();itr++){
        cout<<*itr<<endl;
    }



return 0;
}


Measured memory_bytes: 41840
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
const ll mod = 1000000007;
ll dp[62][2][2];
//digit tight carrier
ll N;

int main() {
    cin >> N;
    dp[61][1][0] = 1;
    for(int d = 60; d >= 0; d--) {
        for(int t = 0; t < 2; t++) {
            for(int c = 0; c < 2; c++) {
                for(int a = 0; a < 2; a++) {
                    for(int b = 0; b <= a; b++) {
                        for(int newc = 0; newc < 2; newc++) {
                            int u = a ^ b;
                            int v = a + b + newc;
                            if((v >= 2) ^ (c == 1)) continue;
                            v %= 2;
                            if(t and ((N >> d) & 1LL) < v) continue;
                            int newt = t;
                            if(((N >> d) & 1LL) > v) newt = 0;
                            dp[d][newt][newc] += dp[d+1][t][c];
                            dp[d][newt][newc] %= mod;
                        }
                    }
                }
            }
        }
    }
    ll ans = dp[0][0][0] + dp[0][1][0];
    ans %= mod;
    cout << ans << endl;
    return 0;
}


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

bool ans(int i,int j,int l){
    if(j-i<=l)return true;
    else return false;
}
int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a<=k) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    edpe()
}

fun edpe() {
    val (n, weightLimit) = readLine()!!.split(" ").map { it.toInt() }
    val items = (1..n)
        .map { readLine()!!.split(" ").map { it.toInt() }.let { ItemE(it[0], it[1]) } }

    val inf = Long.MAX_VALUE / 100
    val dp = Array(n + 1) { LongArray(101010) { inf } }
    dp[0][0] = 0

    for (i in items.indices) {
        val (weight, value) = items[i]
        for (j in 0..100000) {
            dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j])
            if (j + value <= 100000) dp[i + 1][j + value] = Math.min(dp[i + 1][j + value], dp[i][j] + weight)
        }
    }

    val answer = dp[n].indexOfLast { it <= weightLimit }

    println(answer)
}

private data class ItemE(val weight: Int, val value: Int)


Measured memory_bytes: 153636
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll top = a[0], cnt1 = 0;
    if (top >= 0) {
        top = -1;
        cnt1 = a[0] + 1;
    }
    for (int i = 1, sign = 1; i < n; i++, sign *= -1) {
        if ((top + a[i]) * sign < 0) {
            cnt1 += abs(top + a[i]) + 1;
            top = sign;
        } else if ((top + a[i]) == 0) {
            cnt1++;
            top = sign;
        } else {
            top += a[i];
        }
    }
    top = a[0];
    ll cnt2 = 0;
    if (top <= 0) {
        top = 1;
        cnt2 = abs(a[0]) + 1;
    }
    for (int i = 1, sign = -1; i < n; i++, sign *= -1) {
        if ((top + a[i]) * sign < 0) {
            cnt2 += abs(top + a[i]) + 1;
            top = sign;
        } else if ((top + a[i]) == 0) {
            cnt2++;
            top = sign;
        } else {
            top += a[i];
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int main()
{
    string s;
    cin >> s;

    //0塗り
    int res0 = 0;
    string ss = s;
    if (ss[0] == '1')
    {
        res0++;
        ss[0] = '0';
    }
    for (int i = 1; i < s.size(); i++)
    {
        if (ss[i - 1] == ss[i])
        {
            res0++;
            if (ss[i] == '0')
            {
                ss[i] = '1';
            }
            else
            {
                ss[i] = '0';
            }
        }
    }

    //0塗り
    int res1 = 0;
    ss = s;
    if (ss[0] == '0')
    {
        res1++;
        ss[0] = '1';
    }
    for (int i = 1; i < s.size(); i++)
    {
        if (ss[i - 1] == ss[i])
        {
            res1++;
            if (ss[i] == '0')
            {
                ss[i] = '1';
            }
            else
            {
                ss[i] = '0';
            }
        }
    }

    cout << min(res0, res1);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <climits>
#include <algorithm>
using namespace std;

typedef long long int ll;

int main()
{
    ll x, y;
    cin >> x >> y;

    ll ans = 0;
    ll dif = abs(y) - abs(x);
    if (dif > 0) {
        if (y > 0 && x > 0) { // 2 5
            ans = min(dif, (abs(x) + abs(y) + 1));
        } else if (y < 0 && x < 0) { // -2 -5
            ans = min((dif + 2), (abs(x) + abs(y) + 1));
        } else if (y > 0 && x < 0) { // -2 5
            ans = min((abs(x) + abs(y)), (dif + 1));
        } else if (y < 0 && x > 0) { // 2 -5
            ans = dif + 1;
        } else if (y > 0 && x == 0) { // 0 5
            ans = dif;
        } else if (y < 0 && x == 0) { // 0 -5
            ans = dif + 1;
        } else {
            ans = -1;
        }
    } else if (dif < 0) {
        if (y > 0 && x > 0) { // 5 2
            ans = min((abs(dif) + 2), (abs(x) + abs(y) + 1));
        } else if (y < 0 && x < 0) { // -5 -2
            ans = abs(dif);
        } else if (y < 0 && x > 0) { // 5 -2
            ans = abs(dif) + 1;
        } else if (y > 0 && x < 0) { // -5 2
            ans = min((abs(x) + abs(y)), (abs(dif) + 1));
        } else if (y == 0 && x > 0) { // 5 0
            ans = abs(dif) + 1;
        } else if (y == 0 && x < 0) { // -5 0
            ans = abs(dif);
        } else {
            ans = -1;
        }
    } else {
        if (x == y) {
            ans = 0;
        } else {
            ans = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
w = input()

w = sorted(w)
w.append("A")

ans = "Yes"
count = 1
for i in range(len(w)-1):
  if w[i+1] == w[i]:
    count += 1
  else:
    if count % 2 != 0:
      ans  = "No"
      break
    else:
      count = 1
print(ans)

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

#define loop(i,n) for(int i=1;i<=n;i++)
int dp[102][4][4];
int ket[102];

int main(){
  int n,k,a,b;
  cin>>n>>k;
  loop(i,k){
    cin>>a>>b;
    ket[a]=b;
  }
  loop(s1,3){
    if(ket[1]&&ket[1]!=s1)continue;
    loop(s2,3){
      if(ket[2]&&ket[2]!=s2)continue;
      dp[2][s1][s2]=1;
    }
  }
  loop(i,n){
    if(i<=2)continue;
    loop(s3,3){
      if(ket[i]&&ket[i]!=s3)continue;
      loop(s1,3){
        loop(s2,3){
          if(s1==s2&&s2==s3)continue;
          dp[i][s2][s3]+=dp[i-1][s1][s2];
          dp[i][s2][s3]%=10000;
        }
      }
    }
  }
  int sum=0;
  loop(s1,3)loop(s2,3)sum+=dp[n][s1][s2];
  sum%=10000;
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;

int sx,sy,tx,ty;

int main()
{
	scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
	tx-=sx;
	ty-=sy;
	cout<<string(ty,'U')<<string(tx,'R')<<string(ty,'D')<<string(tx,'L')<<"L"<<string(ty+1,'U')<<string(tx+1,'R')<<"D"<<"R"<<string(ty+1,'D')<<string(tx+1,'L')<<"U";
	return 0;
}

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


using namespace std;

int main(void) {

	int n, x;
	cin >> n >> x;
	vector<int> a(n);

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


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

	int satisfyed = 0;

	for (int i = 0; i < a.size();i++) {
		x -= a[i];
		if (x >= 0) {
			satisfyed++;
		}
		else {
			break;
		}
	}

	if (x > 0) {
		satisfyed--;
	}

	cout << satisfyed;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int p = sc.nextInt();
        int q = sc.nextInt();
        int r = sc.nextInt();
        System.out.println(p + q + r - Math.max(p, Math.max(q, r)));
        sc.close();

    }

}


Measured memory_bytes: 22228
#include<iostream>
#include<algorithm>

using namespace std;

const int INF=1<<21;

int main()
{
	int n;
	while(cin>>n,n)
	{
		int m[10][10]={};
		for(int i=0;i<10;i++)for(int j=0;j<10;j++)if(i!=j)m[i][j]=INF;
		int a,b,w,maxn=0;
		for(int i=0;i<n;i++)
		{
			cin>>a>>b>>w;
			m[a][b]=m[b][a]=w;
			maxn=max(maxn,max(a,b));
		}
		maxn++;
		for(int k=0;k<maxn;k++)
			for(int i=0;i<maxn;i++)
				for(int j=0;j<maxn;j++)
					m[i][j]=min(m[i][j],m[i][k]+m[k][j]);
		
		int d[10];
		for(int i=0;i<maxn;i++)d[i]=0;
		for(int i=0;i<maxn;i++)
		{
			for(int j=0;j<maxn;j++)
			{
				d[i]+=m[i][j];
			}
		}
		int mini=0,mind=INF;
		for(int i=0;i<maxn;i++)
		{
			if(mind>d[i])
			{
				mini=i;
				mind=d[i];
			}
		}
		cout<<mini<<" "<<d[mini]<<endl;;
	}
	return 0;
}

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

using namespace std;
typedef pair<int, double> P;

void solve()
{
	int t;
	cin >> t;
	double maxExpectedValue = 0;
	for (int i = 0; i < t; ++i)
	{
		int n, m;
		cin >> n >> m;
		vector<P> dice(m);
		double probSum = 0;
		for (int j = 0; j < m; ++j)
		{
			cin >> dice[j].first >> dice[j].second;
			probSum += dice[j].second;
		}
		double expectedValue = 0;
		for (int j = 0; j < m; ++j)
		{
			expectedValue += dice[j].first * dice[j].second / probSum;
		}
		maxExpectedValue = max(maxExpectedValue, expectedValue);
	}
	int p, q;
	cin >> p >> q;
	vector<P> masterDice(q);
	double masterProbSum = 0;
	for (int i = 0; i < q; ++i)
	{
		cin >> masterDice[i].first >> masterDice[i].second;
		masterProbSum += masterDice[i].second;
	}
	double masterExpectedValue = 0;
	for (int i = 0; i < q; ++i)
	{
		masterExpectedValue += masterDice[i].first * masterDice[i].second / masterProbSum;
	}
	if (maxExpectedValue - masterExpectedValue < 1e-7)
	{
		cout << "NO" << endl;
	}
	else
	{
		cout << "YES" << endl;
	}
}

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

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if(m1==4 ||m1==6 ||m1==9 ||m1==11){
        if(d1==30){
            cout << 1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }else if(m1==2){
        if(d1==28){
            cout << 1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }else{
        if(d1==31){
            cout << 1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    
    map<int, int> m;
    m[A[0]] = 1;
    REP(i, N-1){
        A[i+1] += A[i];
        if(m.find(A[i+1]) == m.end()) m[A[i+1]] = 1;
        else m[A[i+1]]++;
    }

    int ans = 0;
    for(auto i : m){
        if(i.first == 0) ans += i.second;
        ans += (i.second)*(i.second-1)/2;
    }
    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    // vector<int> AS(N+2);
    vector<int> AS;
    int as = 0;
    AS.push_back(as);
    int last = 0;
    for (int i = 0; i < N; ++i) {
        as += A[i] - last;
        AS.push_back(as);
        last = A[i];
    }
    AS.push_back(as+K-A[A.size()-1]);

    // for (const auto& i : AS) {
    //     cout << i << " ";
    // }
    // cout << endl;

    int ans = 1e8;
    for (int sp = 1; sp < N+1; sp++) {
        int tmp;
        if (sp == 1) {
            tmp = AS[N] - AS[1];
        } else {
            tmp = AS[N+1] - AS[sp] + AS[sp-1];
        }
        // printf("tmp: %d\n", tmp);
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

struct State {
    int tx, ty;
    int kx, ky;
    State(int tx, int ty, int kx, int ky) : tx(tx), ty(ty), kx(kx), ky(ky) {}
    bool isComplete(){
        return tx == kx && ty == ky;
    }
};

int range(int maxi, int x, int mini)
{
    if (maxi <= x) return maxi;
    if (mini >= x) return mini;
    return x;
}

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
char visited[64][64][64][64];

int main()
{
    int w, h;
    while (w = in(), h = in(), w){
        int tx, ty, kx, ky;
        tx = in();
        ty = in();
        kx = in();
        ky = in();

        int field[128][128] = {};
        rep(i, h){
            rep(j, w){
               field[i + 1][j + 1] = in();
            }
        }

        queue<State> Q;
        State init = State(tx, ty, kx, ky);
        Q.push(init);
        memset(visited, 0, sizeof(visited));
        visited[tx][ty][kx][ky] = 1;
        bool ok = false;
        rep(turn, 101){
            queue<State> nQ;
            while (!Q.empty()){
                State state = Q.front();
                Q.pop();
                if (state.isComplete()){
                    ok = true;
                    break;
                }
                rep(i, 4){
                    State n = state;
                    n.tx = range(w, n.tx + dx[i], 1);
                    n.kx = range(w, n.kx - dx[i], 1);
                    n.ty = range(h, n.ty + dy[i], 1);
                    n.ky = range(h, n.ky - dy[i], 1);
                    if (field[n.ty][n.tx]){
                        n.ty = state.ty;
                        n.tx = state.tx;
                    }
                    if (field[n.ky][n.kx]){
                        n.ky = state.ky;
                        n.kx = state.kx;
                    }

                    if (!visited[n.tx][n.ty][n.kx][n.ky]){
                        visited[n.tx][n.ty][n.kx][n.ky] = 1;
                        nQ.push(n);
                    }
                }
            }
            if (ok){
                printf("%d\n", turn);
                break;
            }
            Q = nQ;
        }
        if (!ok){
            puts("NA");
        }
    }
    return (0);
}

Measured memory_bytes: 18188
#include<bits/stdc++.h>
using namespace std;
#define ll long
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	for (int i = 1; i <= ty - sy; i++) {
		cout << "U";
	}
	for (int i = 1; i <= tx - sx; i++) {
		cout << "R";
	}
	for (int i = 1; i <= ty - sy; i++) {
		cout << "D";
	}
	for (int i = 1; i <= tx - sx; i++) {
		cout << "L";
	}
	cout << "L";
	for (int i = 1; i <= ty - sy + 1; i++) {
		cout << "U";
	}
	for (int i = 1; i <= tx - sx + 1; i++) {
		cout << "R";
	}
	cout << "D";
	cout << "R";
	for (int i = 1; i <= ty - sy + 1; i++) {
		cout << "D";
	}
	for (int i = 1; i <= tx - sx + 1; i++) {
		cout << "L";
	}
	cout << "U";

}

Measured memory_bytes: 3588
ary = [
  [[0] * 10, [0] * 10, [0] * 10],
  [[0] * 10, [0] * 10, [0] * 10],
  [[0] * 10, [0] * 10, [0] * 10],
  [[0] * 10, [0] * 10, [0] * 10]
]

n = gets.to_i
(1..n).each do
  b, f, r, v = gets.split.map(&:to_i)
  ary[b - 1][f - 1][r - 1] += v
end
ary.each_with_index do |b, idx|
  b.each do |f|
    puts ' ' + f.join(' ')
  end
  puts '#' * 20 if idx != 3
end

Measured memory_bytes: 8716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > s(m);
    
    int k[m];
    rep(i, m){
        cin >> k[i];
        s[i] = vector<int>(k[i]);
        rep(j, k[i]){
            cin >> s[i][j];
            s[i][j] -= 1;
        }
    }
    
    int p[m];
    rep(i, m){
        cin >> p[i];
    }
    int res = 0;
    
    rep(i, 1<<n){
        int hit[n];
        rep(j, n){
            hit[j] = (i>>j & 1);
        }
        
        bool flag = true;
        rep(l, m){
            int count = 0;
            rep(j, k[l]){
                count += hit[s[l][j]];
            }
            if(count % 2 != p[l]){
                flag = false;
                break;
            }
        }
        if(flag){
            ++res;
        }
    }
    
    cout << res << endl;
    return 0;
}

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

static constexpr int MAX_N{8};
bool edges[MAX_N + 1][MAX_N + 1];
int perm[]{1, 2, 3, 4, 5, 6, 7, 8};

int N, M;

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

  int ans{};
  do {
    bool path{true};
    for (int i{}; i < N - 1 && path; ++i) {
      int v1 = perm[i];
      int v2 = perm[i+1];
      if (!edges[v1][v2]) {
        path = false;
      }
    }
    if (path)
      ++ans;
  } while (next_permutation(perm + 1, perm + N));

  cout << ans << endl;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def div_ceil(x, y): return (x + y - 1) // y

N, M = map(int, input().split())
*A, = map(int, input().split())
A = list(set([a // 2 for a in A]))
L = A[0]
for a in A[1:]:
    L *= a // gcd(L, a)
for a in A:
    if (L // a) % 2 == 0:
        ans = 0
        break
else:
    ans = div_ceil(M // L, 2)
print(ans)

Measured memory_bytes: 14244
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
string s;
int pos = 0;
int k = 0;

int main() {
	cin >> n >> s;
	int pre = 0;
	string ans = "";
	REP(i, n) {
		//cout << ans << endl;
		if (s[i] == '(') {
			pre++;
			ans += s[i];
		}
		else {
			if (pre > 0) {
				pre--;
				ans += s[i];
			}
			else {
				ans = "(" + ans + ")";
			}
		}
	}
	REP(i, pre) {
		ans += ")";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.3.1
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define PI 3.141592653589793238462
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  Vi a(n);
  Vin(a);
  
  Vi b(n),c(n);
  
  b[0] = a[0];
  rep(i,1,n){
    b[i] = b[i-1] + a[i];
  }
  //Verr(b);
  reverse(ALL(a));
  
  c[0] = a[0];
  rep(i,1,n){
    c[i] = c[i-1] + a[i];
  }
  //Verr(c);
  
  reverse(ALL(c));
  
  int ans = INF;
  int qw;
  rep(i,0,n-1){
    qw = abs(b[i]-c[i+1]);
    ans = min(qw,ans);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (max(a, max(b, c)) == 7) {
		if (min(a, max(b, c)) == 5) {
			if (a + b + c == 17) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
while True:
    n,x=map(int,input().split())
    if x == 0 and n==0:
        break
    cnt=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k == x:
                    cnt+=1
    print(cnt)


Measured memory_bytes: 5596
// Contest.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int rate_judge(int);

int main()
{
	int n, count[9] = { 0 }, min = 0;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b;	cin >> b;
		a.push_back(b);
	}

	for (int i = 0; i < n; i++) {
		switch (rate_judge(a[i])) {
		case 0: count[0]++;	break;
		case 1: count[1]++;	break;
		case 2: count[2]++;	break;
		case 3: count[3]++;	break;
		case 4: count[4]++;	break;
		case 5: count[5]++;	break;
		case 6: count[6]++;	break;
		case 7: count[7]++;	break;
		case 8: count[8]++;	break;
		}
	}

	for (int i = 0; i <= 7; i++) {
		if (count[i] != 0) {
			min++;
		}
	}
	if (min == 0) { 
		cout << 1 << " " << min + count[8] << endl;
	}
	else {
		cout << min << " " << min + count[8] << endl;
	}

	return 0;
}

int rate_judge(int n)
{
	if (1 <= n && n <= 399) { return 0; }
	else if (400 <= n && n <= 799) {
		return 1;
	}
	else if (800 <= n && n <= 1199) {
		return 2;
	}
	else if (1200 <= n && n <= 1599) {
		return 3;
	}
	else if (1600 <= n && n <= 1999) {
		return 4;
	}
	else if (2000 <= n && n <= 2399) {
		return 5;
	}
	else if (2400 <= n && n <= 2799) {
		return 6;
	}
	else if (2800 <= n && n <= 3199) {
		return 7;
	}
	return 8;
}



Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
				
		while(true){
			String dat = sc.next();
			char[] num = dat.toCharArray();
			int sum = 0;
			if(dat.equals("0")) return;

			for(int i=0;i<dat.length();i++){
				sum = sum + (num[i] - '0'); 
			}

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


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


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

    if(b-a <= 0) cout<<"delicious"<<endl;
    else if(b-a > x) cout<<"dangerous"<<endl;
    else cout<<"safe"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
long long MOD = 1e9 + 7;
long long modpow(long long a, long long n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
    {
        long long t = modpow(a, n / 2);
        return t * t % MOD;
    }
    return a * modpow(a, n - 1) % MOD;
}

long long modinv(long long a)
{
    // mod is prime
    return modpow(a, MOD - 2);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    map<int,int> mp;
    for(auto i:a){
        ll t = i;
        map<int,int> tmp;
        for(int j=2;j*j<=i && t>1;j++){
            while(t>1 && t%j==0){
                tmp[j]++;
                t/=j;
            }
        }
        tmp[t]++;
        for(auto p:tmp){
            mp[p.first] = max(mp[p.first],p.second);
        }
    }
    ll lcm = 1;
    for(auto p:mp){
        rep(j,p.second){
            lcm*=p.first;
            lcm%=MOD;
        }
    }
    ll ans = 0;
    for(auto i:a){
        ll inv = modinv(i);
        ans+=(inv*lcm)%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    int x = a + b;
    cout << (x+1) / 2 << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int a,b,x;
int main()
{
	cin>>a>>b;
	for(x=0;x<11111;++x)
	{
		int c=x/10;
		int d=x*8/100;
		if(c==b and d==a){cout<<x<<endl;return 0;}
	}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
	    int n = scanner.nextInt();
	    Map<Integer, Integer> status = new HashMap<>();
	    for (int i=0; i<n; i++) {
	    	status.put(i+1, scanner.nextInt());
	    }
	    // asc sort
	    status = status.entrySet().stream()
	    .sorted(Entry.<Integer,Integer>comparingByValue())
	    .collect(Collectors.toMap(Entry::getKey,Entry::getValue,(e1, e2)->e1,LinkedHashMap::new));

	    status.forEach((key,value) -> System.out.print(key + " "));

	    scanner.close();
	}

}


Measured memory_bytes: 73348
#include <stdio.h>

int main()
{
        char str[3];
        
        scanf("%s", str);

    if (str[0] == 'A' && str[1] == 'A' && str[2] == 'A')
        printf("No\n");
    else if (str[0] == 'B' && str[1] == 'B' && str[2] == 'B')
        printf("No\n");
    else 
        printf("Yes\n");
    return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,n;
    string str, str1, str2;
    cin >> N;
    if(N % 2 != 0)
    {
        cout << "No" <<endl;
    }
    else
    {
        cin >> str;
        n = N/2;
        int result = str.compare(0, n, str, n, n);
        if(result == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" <<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll c[12][12],a[205][205];
void solve(){
    ll h,w;cin>>h>>w;
    rep(i,10)rep(j,10)cin>>c[i][j];
    rep(i,h)rep(j,w)cin>>a[i][j];
    rep(i,10)rep(j,10)rep(k,10){
        chmin(c[j][k],c[j][i]+c[i][k]);
    }
    ll ans=0;
    rep(i,h)rep(j,w){
        if(a[i][j]==-1)continue;
        ans+=c[a[i][j]][1];
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 640
N,Q = map(int,input().split())
ABC = [list(map(int,input().split())) for i in range(Q)]
edge = [[] for _ in range(N)]

for a,b,c in ABC:
    edge[a-1].append([b-1,c])
    edge[b-1].append([a-1,-c])

numlist = [0] * N
MIN,MAX = 0,0
visited = [False] * N
ans = 0

for i in range(N):
    if visited[i]:
      continue
    stack = [i]
    visited[i] = True
    while stack:
      v = stack.pop()
      for u,d in edge[v]:
        if not visited[u]:
          numlist[u] = numlist[v] + d
          stack.append(u)
          visited[u] = True
ans = 0
for i in range(N):
    if numlist[i] < MIN: MIN = numlist[i]
    elif numlist[i] > MAX: MAX = numlist[i]
    for u,d in edge[i]:
      if numlist[i] + d != numlist[u]:
        ans = -1
        break
    else:
      continue
    break
if ans != -1:
    ans = 'Yes'
else:
  	ans = 'No'

    
print(ans)




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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll H, W;
    vector<vector<bool>> paint;
    vector<string> goal;
    cin >> H >> W;
    goal.resize(H);
    paint.resize(H, vector<bool>(W, true));
    for(ll i = 0;i < H;i++) cin >> goal[i];
    for(ll h = 0;h < H;h++) {
        for(ll w = 0;w < W;w++) {
            if(goal[h][w] == '.') {
                paint[h][w] = false;
            } else {
                bool flag = false;
                if(w > 0 && goal[h][w - 1] == '#') {
                    flag = true;
                    paint[h][w - 1] = false;
                }
                if(w < W - 1 && goal[h][w + 1] == '#') {
                    flag = true;
                    paint[h][w + 1] = false;
                }
                if(h > 0 && goal[h - 1][w] == '#') {
                    flag = true;
                    paint[h - 1][w] = false;
                }
                if(h < H - 1 && goal[h + 1][w] == '#') {
                    flag = true;
                    paint[h + 1][w] = false;
                }
                if(flag) paint[h][w] = false;
            }
        }
    }
    for(ll h = 0;h < H;h++) {
        for(ll w = 0;w < W;w++) {
            if(paint[h][w]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c) {
    cout << "1";
  }
  else if(a == b || b == c || c == a) {
    cout << "2";
  }
  else {
    cout << "3";
  }
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[][] = new int[2][n];
		int sum[][] = new int[2][n+1];
		for(int i=0; i<2; i++) {
			for(int j=0; j<n; j++) {
				a[i][j]=sc.nextInt();
				sum[i][j+1] = sum[i][j] + a[i][j];
			}
		}
		int ans = 0;
		for(int i=1; i<=n; i++) {
			int sum1 = sum[0][i];
			int sum2 = sum[1][n] - sum[1][i-1];
			ans = Math.max(ans, sum1+sum2);
		}
		System.out.println(ans);
		sc.close();
	}
}


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


int calc_sum(int n) {

    int sum = 0;
    while(true) {
        sum += n%10;
        n /= 10;
        if (n<1) break;
    }
    return sum;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int sum=0;
    for (int n=1; n<=N; ++n) {
        int ans = calc_sum(n);
        if (ans >=A && ans <= B) {
            sum += n;
        }   
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    # define LL long long
    # define int long long
    #define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    # define mo 998244353
    # define pi acos(-1)
    //vector<pair<int,int>> v;
    //int x0=INT_MAX,y0=INT_MAX;
    /*int crossprod(pair<int,int> a,pair<int,int> b,pair<int,int> c)
    {
        int x1 = a.first-b.first;
        int x2 = a.first-c.first;
        int y1 = a.second-b.second;
        int y2 = a.second-c.second;
        return x1*y2 - y1*x2;
    }
    int direction(pair<int,int> a,pair<int,int> b,pair<int,int> c) {
       int val = (b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y);
       if (val == 0)
          return 0;     //colinear
       else if(val < 0)
          return 2;    //anti-clockwise direction
          return 1;    //clockwise direction
    }*/

signed main()
{

   gok

 int x;
 cin>>x;
 int an = (x/500)*1000;
 x = x%500;
 an += (x/5)*5;
cout<<an;

























	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n;
	 cin>>n;
	 char s[10000];
	 cin>>s;
	// cout<<n<<" ";
	 for(int i=0;s[i]!='\0';i++)
	 {
	 	if((s[i]+n)>90)
	 	{
	 		s[i]=64+(s[i]+n)-90;
		 }
		 else
		 s[i]=s[i]+n;
	 }
	 cout<<s;
}

Measured memory_bytes: 256