akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int max=0,min=0;
    ll hoge=0;
    if(a<b){
        max = b;
        min = a;
    }
    else{
        max = a;
        min = b;
    }
    while(1){
        hoge += max;
        if(hoge%min==0) break;
    }
    cout<<hoge<<endl;
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        String N = sc.next();

        int x = 0;
        for (int i = 0; i < N.length(); i++) {
            x += Character.getNumericValue(N.charAt(i));
        }

        if (Integer.parseInt(N) % x == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main(){
  string s,t;
  cin >>s>>t;
  vector <char> sd(s.length());
  vector <char> td(t.length());
  for (int i=0;i<s.length();i++){
    sd[i]=s.at(i);
  }
  for (int i=0;i<t.length();i++){
    td[i]=t.at(i);
  }
  sort(sd.begin(),sd.end());
  sort(td.begin(),td.end(),greater<char>());
  
  if(s.length()<t.length()){
    for (int i=0;i<s.length();i++){
      if(sd.at(i)>td.at(i)){
        cout<<"No"<<endl;
        return 0;
      }
      else if(sd.at(i)<td.at(i)){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
  }
  if(s.length()>=t.length()){
    for (int i=0;i<t.length();i++){
      if(sd.at(i)>td.at(i)){
        cout<<"No"<<endl;
        return 0;
      }
      else if(sd.at(i)<td.at(i)){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
  }                       
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];
    map<ll, ll> memo;
    ll ans = 0;
    rep(i, n) {
        ll a = i - A[i];
        ans += memo[a];
        ll b = A[i] + i;
        memo[b]++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 27532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b)
{
	int temp;

	temp = *a;
	*a = *b;
	*b = temp;
}

int main(void)
{
	int x, y;		//Value x, y.

	while(1)
	{
		scanf("%d %d", &x, &y);
		if( x == 0 && y == 0)
			return (0);
		if(x > y)
			swap(&x, &y);
		printf("%d %d\n", x, y);
	}

	return (0);
}



Measured memory_bytes: 2072
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        List<Student> students = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            Student student = new Student();
            student.a = scan.nextInt();
            student.b = scan.nextInt();
            students.add(student);
        }
        List<CheckPoint> points = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            CheckPoint point = new CheckPoint();
            point.c = scan.nextInt();
            point.d = scan.nextInt();
            points.add(point);
        }
        for (int i = 0; i < N; i++) {
            int nearest_point = Integer.MAX_VALUE;
            int nearest_distance = Integer.MAX_VALUE;
            for (int j = 0; j < M; j++) {
                int distance = points.get(j).distance(students.get(i));
                if (distance < nearest_distance) {
                    nearest_distance = distance;
                    nearest_point = j;
                }
            }
            System.out.println(nearest_point+1);
        }
    }
    class Student {
        int a;
        int b;
    }
    class CheckPoint {
        int c;
        int d;
        int distance(Student student) {
            return Math.abs(student.a - this.c) + Math.abs(student.b - this.d);
        }
    }
}


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

int main(){
int N[11]={},W[11]={},x;
int Ns=0,Ws=0;
for(int i=0;i<10;i++)
{cin>>N[i];}
for(int i=0;i<10;i++)
{cin>>W[i];}
for(int i=0;i<10;i++)
{for(int j=9;j>i;j--)
{if(N[j]>N[j-1]){int t=N[j];N[j]=N[j-1];N[j-1]=t;}
//if(W[j]>W[j-1]){int tt=W[j];W[j]=W[j-1];W[j-1]=tt;}
}
}
for(int i=0;i<10;i++)
{for(int j=9;j>i;j--)
{//if(N[j]>N[j-1]){int t=N[j];N[j]=N[j-1];N[j-1]=t;}
if(W[j]>W[j-1]){int tt=W[j];W[j]=W[j-1];W[j-1]=tt;}
}
}
for(int i=0;i<3;i++)
{Ns+=N[i];Ws+=W[i];}
cout<<Ns<<" "<<Ws<<endl;
return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 998244353;

     signed main(){
     
int n,k,ans=0;
cin>>n>>k;
int p[n];
for(int i=0;i<n;i++)cin>>p[i];
sort(p,p+n);
for(int i=0;i<k;i++)ans+=p[i];
cout<<ans<<endl;
     }


 


 






    





      

        


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

int main() {
    ll n, m;
    cin >> n >> m;
   
    if(n==1&& m==1) cout << 1 << endl; 
    else if(n==1) cout << m-2 << endl;
    else if(m==1) cout << n-2 << endl;    
    else {
        ll ans  = (n-2)*(m-2);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, A, B;
    cin >> N >> A >> B;
    while(true) {
        if (A+1 != B) A++;
        else {
            if (A == 1) {
                OUT("Borys")
                return 0;
            } else A--;
        }
        if (B-1 != A) B--;
        else {
            if (B == N) {
                OUT("Alice")
                return 0;
            } else B++;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define fi first
#define se second
#define mk(x, y) make_pair( x, y )
#define pk push_back
using namespace std;
const int M = 1e5 + 5;
const int N = 1e5 + 5;
const double PI = acos(-1.0);
int m, n;

int main( ){
    while( scanf( "%d", &n ) != EOF ){
        printf( "%.20lf\n", 2*PI*n );
    }
    return 0;
}


Measured memory_bytes: 3828
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
	 Scanner reader  =new Scanner(System.in);	
	 int A=reader.nextInt();
	 int B=reader.nextInt();
	 int S=A+B;
	 if(S>=10) {
		 System.out.println("error");
		 
	 }
	 else {
		 System.out.println(S);
	 }
	}

}


Measured memory_bytes: 21204
# https://atcoder.jp/contests/abc154/tasks/abc154_e
# 桁DPっぽいよなぁ => O

"""
memo
dp0[i][j]
  上からi桁目まで決めて，0でない桁がj個あり
  Nより小さいことが確定している (less)
dp1[i][j]
  上からi桁目まで決めて，0でない桁がj個あり
  Nより小さいことが確定していない (i桁目まで同じ)

通常の再帰
rec
"""

S = input()
K = int(input())
N = len(S)

def com(N, R):
    if R < 0 or R > N:
        return 0
    if R == 1:
        return N
    elif R == 2:
        return N * (N - 1) // 2
    elif R == 3:
        return N * (N - 1) * (N - 2) // 6
    else:
        raise NotImplementedError("NIE")


# 再帰呼出し
def rec(i, k, smaller):
    if i == N:
        return 1 if k == 0 else 0
    if k == 0:
        return 1
    if smaller:
        # 残っている桁数からk個を選び，それぞれ9^kのパターンがある
        return com(N - i, k) * pow(9, k)
    else:
        if S[i] == '0':
            return rec(i + 1, k , False)
        else:
            zero = rec(i + 1, k, True)
            aida = rec(i + 1, k - 1, True) * (int(S[i]) - 1)
            ichi = rec(i + 1, k - 1, False)
            return zero + aida + ichi

ans = rec(0, K, False)
print(ans)

Measured memory_bytes: 62068
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int n,m;
vector<int> g[101];
int main()
{
	cin>>n>>m;
	while(m--)
	{
		int from,to;
		cin>>from>>to;
		g[from].push_back(to);
		g[to].push_back(from);
	}
	for(int i=1;i<=n;i++)
	{
		cout<<g[i].size()<<endl;
	}
}


Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
                int S, h, m, s;

                String line = reader.readLine();
                S = Integer.parseInt(line);
                h = S / 3600;
                m = (S % 3600) / 60;
                s = ((S % 60));
                System.out.print(h);
                System.out.print(":" + m);
                System.out.print(":" + s);
                System.out.println(); 

        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24240
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>

int main() {
  long long sum = 0, n;
  std::string s;
  std::cin >> s;
  n = std::atoll(s.c_str());

  for (const char& c : s) {
    sum += c - '0';
  }

  std::cout << ((n % sum == 0) ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main(){
    cout<<fixed<<setprecision(10);
    int A,B;
    cin>>A>>B;
    int ans=0;
    if(A>B){
        ans+=A;
        A--; 
    }else{
        ans+=B;
        B--; 
    }
    if(A>B){
        ans+=A;
        A--; 
    }else{
        ans+=B;
        B--; 
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

template <class T>
void chmin(T& a, T b) {
  if (b < a) a = b;
}

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<int> C(N + 1, 0);
    for (int x : A) ++C[x];
    vector<int> cover(N + 2, 0);
    for (int i = 1; i <= N; i++) {
      ++cover[max(1, i - C[i] + 1)];
      --cover[i + 1];
    }
    for (int i = 1; i <= N; i++) cover[i] += cover[i - 1];
    int res = 0;
    for (int i = 1; i <= N; i++) res += cover[i] == 0;
    auto inc = [&](int X) {
      int left = X - C[X] + 1;
      if (left - 1 >= 1) {
        if (cover[left - 1]++ == 0) {
          --res;
        }
      }
      ++C[X];
    };
    auto dec = [&](int X) {
      int left = X - C[X] + 1;
      if (left >= 1) {
        if (--cover[left] == 0) {
          ++res;
        }
      }
      --C[X];
    };
    for (int i = 0; i < M; i++) {
      int X, Y;
      cin >> X >> Y;
      --X;
      int Z = A[X];
      A[X] = Y;
      dec(Z);
      inc(Y);
      cout << res << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;

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

        String s = sc.next();
        int ans = 0;
        int tmp = 0;
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'A' || s.charAt(i) == 'T' || s.charAt(i) == 'G' || s.charAt(i) == 'C') {
                tmp++;
            }else {
                ans = Math.max(ans, tmp);
                tmp = 0;
            }
        }
        ans = Math.max(ans, tmp);

        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 22740
n=int(input())
t0,x0,y0=0,0,0
ans=True
for i in range(n):
    t,x,y = map(int, input().split())
    if (abs(x-x0)+ abs(y-y0)-(t-t0)) %2 !=0 or abs(x-x0)+abs(y-y0)>(t-t0):
        ans=False
    else:
        t0,x0,y0=t,x,y
if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>a(n), b(n);
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
	vector<int>c(m), d(m);
	for (int i = 0; i < m; i++)cin >> c[i] >> d[i];
	for (int i = 0; i < n; i++) {
		int Min = 2*mod;
		int res;
		for (int j = 0; j < m; j++) {
			if (Min > abs(a[i] - c[j]) + abs(b[i] - d[j]))res = j+1;
			Min = min(Min, abs(a[i] - c[j]) + abs(b[i] - d[j]));
		}
		cout << res << endl;
	}
	return 0;
}

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

ll n,p,q;

int main(){
    cin >> n >> p;
    q = p;
    vector<pair<ll,ll>> res;
    
    for (long long i = 2;i * i <= p;i++) {
        if (p % i != 0) continue;
        long long ex = 0; 
        
        while (p % i == 0) {
            ex++;
            p /= i;
        }
        
        res.push_back(pair<ll,ll>(i, ex));
    }
    
    ll ans = 1;
    
    for(auto u : res){
        ans *= pow(u.first,(u.second / n));
    }
    
    if(n == 1)ans = q;
    
    cout << ans << endl;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}

int main(){
  string s;
  cin>>s;
  if(s.length()==2)cout<<s<<endl;
  else{reverse(s.begin(),s.end());
    cout<<s<<endl;}
    
    
  return 0;
}


Measured memory_bytes: 3636
N = int(input())
def dfs(s):
    if int(s)>N:#整数にキャスト、Nを超えたらオシマイ
        return 0;
    ret = 1 if all(s.count(c) > 0 for c in "753") else 0
    for c in "753":#文字列はイテラブル
        ret += dfs(s+c)#再帰、１回のretは0か1
    return ret#retには累積的に結果が加算される
print(dfs("0"))#引数は文字列

'''
>>> s = 'aAaAAbAccdd'
# "A"という文字が何個あるか調べる
>>> s.count('A') #4

>>> a = [True, True, True]
>>> all(a) #True　すべてTrueか？
>>> b = [True, True, False]
>>> all(b) #False
'''

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
};
const int INF = 1 << 30;
typedef pair< int, int > Pi;
 
int N, M, C;
vector< edge > graph[100000];
Pi min_cost[100000];
 
void Dijkstra()
{
  for(int i = 0; i < N; i++) {
    min_cost[i] = make_pair(INF, i);
  }
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  que.push(make_pair(0, 0));
  min_cost[0].first = 0;
  while(!que.empty()) {
    Pi p = que.top(); que.pop();
    if(min_cost[p.second].first < p.first) continue;
    for(int i = 0; i < graph[p.second].size(); i++) {
      const edge& e = graph[p.second][i];
      if(min_cost[e.to].first <= p.first + e.cost) continue;
      min_cost[e.to].first = p.first + e.cost;
      que.push(make_pair(min_cost[e.to].first, e.to));
    }
  }
}
 
 
int main()
{
  long long ALL = 0;
  scanf("%d %d %d", &N, &M, &C);
  for(int i = 0; i < M; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --a, --b;
    graph[a].push_back((edge){b, c});
    graph[b].push_back((edge){a, c});
    ALL += c;
  }
  Dijkstra();
  sort(min_cost, min_cost + N);
  vector< int > nums(N);
  for(int i = 0; i < N; i++) {
    nums[i] = min_cost[i].first;
  }
  nums.erase(unique(nums.begin(), nums.end()), nums.end());
  vector< bool > used(N, false);
  long long ret = 1LL << 60;
  for(int i = 0, ptr = 0; i < nums.size(); i++) {
    for( ; ptr < N && nums[i] == min_cost[ptr].first; ++ptr) {
      int curr = min_cost[ptr].second;
      used[curr] = true;
      for(int j = 0; j < graph[curr].size(); j++) {
        if(used[graph[curr][j].to]) ALL -= graph[curr][j].cost;
      }
    }
    ret = min(ret, ALL + (long long)C * nums[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 10884
using System;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputstr = Console.ReadLine().Split(char.Parse(" "));
            int W = int.Parse(inputstr[0]);
            int H = int.Parse(inputstr[1]);
            int x = int.Parse(inputstr[2]);
            int y = int.Parse(inputstr[3]);
            int r = int.Parse(inputstr[4]);
            string result = "Yes";
            if((x-r)<0 || (x + r) > W)
            {
                result = "No";
            }
            if((y-r)<0 || (y + r) > H)
            {
                result = "No";
            }
            Console.WriteLine(result);
        }
    }
}



Measured memory_bytes: 17932
N= gets.to_i
A = gets.split(' ').map(&:to_i)
MAX = 10 ** 18
result = 1
ng = false

A.sort!
A.each do |a|
    if a == 0
        puts "0"
        return
    end
    if a <= MAX/result
        result *= a
    else
        puts "-1"
        return
    end    
end

puts result


Measured memory_bytes: 22576
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double
using namespace std;

int main()
{
	fio
	int TC;
	// cin>>TC;
	TC=1;
	while(TC--)
	{
		ll n,m;
		cin>>n>>m;
		std::vector<ll> v(n);
		ll sum=0;
		for (int i = 0; i < m; ++i)
		{
			cin>>v[i],sum+=v[i];
		}
		(n-sum)>=0?cout<<n-sum<<endl:cout<<-1<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 11120
#include<stdio.h>

int main()
{   int n,ans=0,v=1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int cpy=i,cnt=0;
        while(cpy%2==0){
            cpy/=2;
            cnt++;
        }
        if(cnt>ans){
            ans=cnt;
            v=i;
        }
    }
    printf("%d",v);
    return 0;
}


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

using namespace std;

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

    int n, x;
    cin >> n >> x;

    if (x == 1 || x == n * 2 - 1) {
        cout << "No\n";
        return 0;
    }

    vector <int> A(2 * n - 1);
    A[n - 1] = x;
    A[n - 2] = x - 1;
    A[n] = x + 1;

    if (n > 2) {
        if (x == 2) {
            A[n - 3] = x + 2;
        } else {
            A[n + 1] = x - 2;
        }
    }
    vector <int> mark(2 * n);

    for (int i = 0; i < 2 * n - 1; i++) {
        mark[A[i]] = 1;
    }
    int ptr = 1;

    for (int i = 0; i < 2 * n - 1; i++) {
        if (A[i] != 0) {
            continue;
        }
        while (mark[ptr]) {
            ptr++;
        }
        A[i] = ptr;
        mark[ptr] = 1;
    }
    cout << "Yes\n";

    for (int i = 0; i < 2 * n - 1; i++) {
        cout << A[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;


int main() 
{
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int x = n/2;
    int k = a[x]-a[x-1];
    if(k<0) k = 0;
    cout << k;
}

Measured memory_bytes: 640
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
count=0
for i in range(n):
  sum=0
  a=list(map(int,input().split()))
  for j in range(m):
    sum+=a[j]*b[j]
  if sum+c>0:
    count+=1
print(count)

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

int main(void) {
	int i;
	int N, M;
	int *T, *P,*X;
	int T0;
	char buf[2048], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);

	T = (int *)calloc(N, sizeof(int));
	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	T[0] = atoi(ch);
	T0 = T[0];
	for(i = 1; i < N; i += 1) {
		ch = strtok(NULL, " ");
		T[i] = atoi(ch);
		T0 += T[i];
	}

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	M = atoi(ch);
	P = (int *)calloc(M, sizeof(int));
	X = (int *)calloc(M, sizeof(int));
	for(i = 0; i < M; i += 1) {
		fgets(buf, sizeof(buf), stdin);
		ch = strtok(buf, " ");
		P[i] = atoi(ch);
		P[i] -= 1;
		ch = strtok(NULL, " ");
		X[i] = atoi(ch);
	}
	for(i = 0; i < M; i += 1) {
		printf("%d\n", T0 + X[i] - T[P[i]]);
	}

	free(T);
	free(P);
	free(X);
	return 0;
}


Measured memory_bytes: 2124
#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

struct team_t {
  array<uint32_t, 11> wrongs;
  uint64_t penalty;
  uint32_t corrects;
  uint32_t id;
  team_t() : wrongs({}), penalty(0), corrects(0), id(0) {}

  void correct(uint32_t pid, uint32_t time) {
    corrects++;
    penalty += 1200 * wrongs[pid] + time;
  }

  void wrong(uint32_t pid) { wrongs[pid]++; }

  void println() { cout << id << " " << corrects << " " << penalty << endl; }

  bool operator<(const team_t &team) const {
    return corrects == team.corrects ? penalty < team.penalty
                                     : corrects > team.corrects;
  }
};

int32_t main() {
  while (true) {
    uint32_t T, P, R;
    cin >> T >> P >> R;
    if (T == 0) break;

    vector<team_t> teams(T + 1);
    for (uint32_t i = 1; i <= T; i++) {
      teams[i].id = i;
    }

    for (uint32_t i = 0; i < R; i++) {
      uint32_t tid, pid, t;
      string msg;
      cin >> tid >> pid >> t >> msg;
      if (msg == "WRONG") {
        teams[tid].wrong(pid);
      } else if (msg == "CORRECT") {
        teams[tid].correct(pid, t);
      }
    }

    stable_sort(teams.begin() + 1, teams.begin() + 1 + T);

    for (uint32_t i = 1; i <= T; i++) {
      teams[i].println();
    }
  }

  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int n[3];
    int ans;
    
  cin >> n[0] >> n[1] >> n[2];
  
  sort(n, n+3);
  
  if ((n[1] - n[0]) % 2 == 0){
    ans = n[2] - n[1] + (n[1] - n[0])/2;
  }else{
    ans = n[2] - n[1] + (n[1] - n[0])/2 + 2;
  }
  
  cout << ans;
  
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    if((abs(x) + k - 1) / k > d){
        if(x < 0) x += d*k;
        else x -= d*k;
        cout << abs(x) << endl;
        return 0;
    }
    else {
        ll count = abs(x) / d;
        if((k-count) % 2 != 0) {
            count ++;
        }
        if(x < 0) x += count*d;
        else x -= count*d;
        
        cout << abs(x) << endl;
    }

}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define clear cnyali
#define pow ORZ
#define ll long long
using namespace std;
const ll mod=1e9+7;
struct SDU
{
	int fa[2020];
	void clear(int cc){for (int i=1;i<=cc;++i) fa[i]=i;}
	int find(int x)
	{
		if (fa[x]==x) return x;
		fa[x]=find(fa[x]);
		return fa[x];
	}
	void merge(int x,int y)
	{
		x=find(x); y=find(y);
		if (x!=y) fa[x]=y;
	}
}s,a;
struct node
{
	int id;
	int x,y,v;
}line[2020];
int n,m;
ll X,V,doe;
int br[2020],num;
ll pow[3030];
bool cmp(node u,node w){return u.v<w.v;}
int main()
{
	scanf("%d%d",&n,&m);
	pow[0]=1;
	for (int i=1;i<=m+1;++i) pow[i]=pow[i-1]*2%mod;

	scanf("%lld",&X);
	s.clear(m); a.clear(n);
	for (int i=1;i<=m;++i) scanf("%d%d%d",&line[i].x,&line[i].y,&line[i].v),line[i].id=i;
	sort(line+1,line+1+m,cmp);

	for (int id=1;id<=m;++id)
	{
		a.clear(n); V=0;
		num=1; br[1]=id;
		for (int i=1;i<=m;++i) if (line[i].id==id) swap(line[1],line[i]);
		sort(line+2,line+1+m,cmp);
		
		a.merge(line[1].x,line[1].y); V+=line[1].v;
		for (int i=2;i<=m;++i)
			if (a.find(line[i].x)!=a.find(line[i].y))
			{
				V+=line[i].v;
				a.merge(line[i].x,line[i].y);
				++num; br[num]=line[i].id;
			}
		if (V<X)
		{
			for (int i=2;i<=num;++i) s.merge(id,br[i]);
		}
	}
	int ans=0;
	for (int i=1;i<=m;++i) if (s.find(i)==i) ++ans;
	
	for (int id=1;id<=m;++id)
	{
		a.clear(n); V=0;
		num=1; br[1]=id;
		for (int i=1;i<=m;++i) if (line[i].id==id) swap(line[1],line[i]);
		sort(line+2,line+1+m,cmp);
		
		a.merge(line[1].x,line[1].y); V+=line[1].v;
		for (int i=2;i<=m;++i)
			if (a.find(line[i].x)!=a.find(line[i].y))
			{
				V+=line[i].v;
				a.merge(line[i].x,line[i].y);
				++num; br[num]=line[i].id;
			}
		if (V==X)
		{
			for (int i=2;i<=num;++i) s.merge(id,br[i]);
		}
	}
	int sss=0;
	for (int i=1;i<=m;++i) if (s.find(i)==i) ++sss;
	printf("%lld\n", ((pow[ans]-pow[sss])%mod+mod)%mod );
	return 0;
}

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


int main() {
    long long int x;
    cin >> x;
    long long int a=0, b=0;
    a = x/500;
    b = (x - 500*a)/5;
    long long int ans = 1000*a + 5*b;
    cout << ans << endl;
}

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

void BFS(vector<vector<int> > G, int N, int start) {
    queue<int> que;
    vector<int> dist(N, -1);
    vector<int> prev(N, -1);
    dist[0] = 0;
    que.push(start);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto e : G[v]) {
            if (dist[e] != -1) continue;
            dist[e] = dist[v] + 1;
            prev[e] = v + 1;
            que.push(e);
        }
    }

    cout << "Yes" << endl;
    for (size_t i = 1; i < N; i++) cout << prev[i] << endl;
    return;
}

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > G(n, vector<int>());
    for (size_t i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    BFS(G, n, 0);
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int c = 0;
  for(int i = 0; i < s.length(); i++){
    for(int j = 0; j < s.length(); j++){
      if(s[i] == s[j]){
        c++;
      }
    }
  }
  if( c == s.length()){
    cout << "yes" << endl;
  }else{
    cout << "no" << endl;
  }
}


Measured memory_bytes: 384
def main():
    N, K = map(int, input().split())

    c = [[0] * 4000 for _ in range(4000)]
    c[0][0] = 1
    for i in range(1, 4000):
        ci = c[i]
        ci1 = c[i - 1]
        ci[0] = 1
        for j in range(1, i + 1):
            ci[j] = (ci1[j - 1] + ci1[j]) % 1000000007

    def f(n, k):
        return c[n+k-1][k-1]

    for i in range(1, K + 1):
        print((f(K-i, i) * f(N-K-(i-1), i+1)) % 1000000007)


main()


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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    cout << s[0] << s[1] << s[2];
    return 0;
}

Measured memory_bytes: 3600
import itertools

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

combinations = list(itertools.combinations(range(N), 3))

count = 0
for cmb in combinations:
    flag = True
    for i in range(3):
        if L[cmb[i]] + L[cmb[(i + 1) % 3]] > L[cmb[(i + 2) % 3]] and L[cmb[i]] != L[cmb[(i + 1) % 3]]:
            continue
        else:
            flag = False
            break
    if flag:
        count += 1

print(count)

Measured memory_bytes: 20404
import scala.io.StdIn.readLine;
import scala.reflect.ClassTag;
object Main {
    def main(args: Array[String]): Unit = {
        def c(a: Long, b: Long): Int = if (a < b) -1 else if (a > b) 1 else 0;
        val h = Heap[Long](c);
        sub(h)
    }
    def sub(heap: Heap[Long]): Unit = {
        readLine.split(" ") match {
            case Array("insert", key) =>
                heap.insert(key.toLong);
                sub(heap);
            case Array("extract") => 
                println(heap.extract.getOrElse(-1L));
                sub(heap);
            case Array("end") => ()
        }
    }
}

class Heap[A](size: Int, compare: (A, A) => Int)(implicit m: ClassTag[Option[A]]) {
    var tree: Array[Option[A]] = m.newArray(size).map(a => None);
    var cnt = 0;
    
    def insert(key: A): Unit = {
        def _insert(currPtr: Int): Unit = {
            if (currPtr > 0) {
                // currPtr が奇数の場合は左側の子, 偶数の場合は右側の子
                val parentPtr = if (currPtr % 2 != 0) (currPtr - 1) / 2 else  (currPtr - 2) / 2;
                if (compare(tree(currPtr).get, tree(parentPtr).get) > 0) {
                    swap(currPtr, parentPtr);
                    _insert(parentPtr);
                }
            }
        }
        if (cnt < size) {
            tree(cnt) = Option(key);
            _insert(cnt);
            cnt += 1;
        }
        
    }
    def extract(): Option[A] = {
        if (cnt > 0) {
            val top = tree(0);
            if (cnt == 1) {
                tree(0) = None;
            } else {
                tree(0) = tree(cnt - 1);
                tree(cnt - 1) = None;
                heapify(0);
            }
            cnt -= 1;
            top;
        } else {
            None;
        }
    }
    
    def heapify(currPtr: Int): Unit = {
        if (currPtr < size && tree(currPtr) != None) {
            val leftPtr = currPtr * 2 + 1;
            val rightPtr = currPtr * 2 + 2;
            val curr = tree(currPtr);
            val left = if (leftPtr < size) tree(leftPtr) else None;
            val right = if (rightPtr < size) tree(rightPtr) else None;
            if (right != None) { // 両方の子ノードが存在する
                val swapPtr = if (compare(left.get, right.get) < 0) rightPtr else leftPtr;
                if (compare(curr.get, tree(swapPtr).get) < 0) {
                    swap(currPtr, swapPtr);
                    heapify(swapPtr);
                }
            } else if (left != None) { // 左の子ノードのみ存在する
                if (compare(curr.get, left.get) < 0) {
                    swap(currPtr, leftPtr);
                    heapify(leftPtr);
                }
            }
        }
    }
    
    def swap (ptrA: Int, ptrB: Int): Unit = {
        val tmp = tree(ptrA);
        tree(ptrA) = tree(ptrB);
        tree(ptrB) = tmp;
    }
    
}
object Heap {
    def apply[A](compare: (A, A) => Int): Heap[A] = {
        new Heap[A](2000000, compare);
    }
}



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

int main() {
  int n;
  cin >> n;
  if (n/1000 == n/100%10 && n/100%10 == n/10%10) {
    cout << "Yes" << endl;
  }
  else if (n/100%10 == n/10%10 && n/10%10 == n%10) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int digit_sum() {

	return 0;
}

int main() {
	string ans;
	int N;
	cin >> N;
	int digit_sum = 0;
	int number = N;
	while (number > 0) {
		digit_sum += number % 10;
		number = number / 10;
	}

	if (N%digit_sum == 0) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i,n;
	scanf("%d",&n);
	int num[n];
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",num[i]);
		if(i!=0){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += p[i];
    cout << ans;
}

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

char map[13][13];
int d[13][13];
int dy[4]={-1,0,1,0};
int dx[4]={0,-1,0,1};

void bfs(int y,int x);
int main(){
    char a[12];
    string str;
    while(1){
    int co=0;
    for(int i=0;i<12;i++){
        cin>>map[i];
    }
    if(cin.eof())break;
    for(int i=0;i<12;i++){
        for(int j=0;j<12;j++){
            d[i][j]=0;
        }
    }
    for(int i=0;i<12;i++){
        for(int j=0;j<12;j++){
          if(map[i][j]=='1' && d[i][j]==0){
	    co++;
            bfs(i,j);
          }
        }
    }
    cout<<co<<endl;
    }
}
void bfs(int y,int x){
    d[y][x]=1;
    for(int p=0;p<4;p++){
        int ny=y+dy[p];
        int nx=x+dx[p];
        if(ny>=0 && ny<12 && nx>=0  && nx<12  && d[ny][nx]==0 && map[ny][nx]=='1' ){
            bfs(ny,nx);
        }
    }
   return;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define REP(i, n) for(size_t i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

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

    int minOp = INF; 

    vector<char> charset;
    REP(i, s.size()) charset.push_back(s[i]);
    

    
    for (auto c : charset){
        // cout << "working on " << c<< endl;
        int ct = 0;
        string tmp = s;
        bool done = true;
        REP(i, tmp.size()){
            if (tmp[i] != c){
                done = false;
                break;
            }
        }
        if (done) minOp = 0;

        while (!done){
            string tmp2 = "";
            REP(i, tmp.size()-1){
                if (tmp[i] == c || tmp[i+1] == c){ 
                    tmp2.push_back(c);
                }
                else{
                    tmp2.push_back(tmp[i]);
                }
                
            }
            tmp = tmp2;
            // cout << tmp << endl;
            done = true;
            REP(i, tmp.size()){
                if (tmp[i] != c){
                    done = false;
                    break;
                }
            }
            ct++;
        }

        if (ct < minOp) minOp = ct;
    }

    cout << minOp << endl;
    
}

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

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

using namespace std;
int main(){
  long n,k,b,cycle,r,num;
  long ii,jj,cnt;
  cnt = 0;
  cin >> n >> k;
  
  for(b=1;b<=n;b++){
	cycle = n/b;
	r = n % b;

	num = b - k ;

	if(num < 0){
	  num = 0;
	}
	//cout << "b:" << b << endl;
	//cout << "num1:" << num << endl;
	//cout << "cycle:" << cycle << endl;
	//cout << "r:" << r << endl;
	cnt += num * cycle;

	if(k==0 && (num*cycle)>=1){
	  cnt -=1;
	}
	num = r - k +1;

	if(num < 0){
	  num = 0;
	}
	//cout << "num2:" << num << endl;
	cnt += num;

	//cout << endl;
  }


  cout << cnt << endl;

  return 0;
}


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

int func(int x){
    if(x<10) return x;
    return x%10 + func(x/10);
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int sum=0;
    
    for(int i=1; i<=N; i++){
        int disum = func(i);
        if(disum>=A && disum<=B) sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int N, T, c, t;
int ans;

int main(){
	ans = INF;
	cin >> N >> T;
	for (int i = 0; i < N; i++){
		cin >> c >> t;
		if (t <= T && c < ans){
			ans = c;
		}
	}
	
	if (ans == INF){
		cout << "TLE" << endl;
	}
	else{
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}
 
/*-------------------------------------------*/
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int n;
    int a[200009];
    ll k;
    cin >> n >> k;
 
    FOR(i, 1, n + 1) cin >> a[i];
 
    int now = 1;
 
    int d[200009];
    memset(d, -1, sizeof(d));
    d[now] = 0;
    while(!~d[a[now]]) {
        d[a[now]] = d[now] + 1;
        now = a[now];
    }
    int x = d[a[now]], y = d[now] + 1 - x;
    now = a[now];
 
    if(k < x) {
        FOR(i, 1, n + 1) if(d[i] == k) {
            cout << i << endl;
            return 0;
        }
    }
 
    FOR(i, 1, n + 1) d[i] -= x;
 
    (k -= x) %= y;
 
    FOR(i, 1, n + 1) if(d[i] == k) cout << i << endl;
 
    return 0;
}

Measured memory_bytes: 5176
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
sum = 0

for i in range(a+1):
	for j in range(b+1):
		for k in range(c+1):
			sum = (i*500)+(j*100)+(k*50)
			if x == sum:
				cnt += 1
				break
			elif sum > x:
				break
			sum = 0
print(cnt)


Measured memory_bytes: 3064
#191116 B

import math
import itertools

def calcdis(p1,p2):    
    return ((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)**0.5

if __name__ == "__main__":
    N = int(input())
    point = []
    for i in range(N):
        tmpx,tmpy = list(map(int,input().split()))
        point.append([tmpx,tmpy])
    sumlist = []
    for target in itertools.permutations(point):
        tmpsum = 0
        for i in range(1,len(target)):
            tmpsum = tmpsum + calcdis(target[i-1],target[i])
        sumlist.append(tmpsum)

    print(sum(sumlist) / math.factorial(N))


    


    

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;


void solve() {
	string s;
	cin>>s;
	ll a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
	for(int i=0;i<8;i++){
		ll ans=0;
		if((i>>0)&1)
			ans+=a+b;
		else 
			ans+=a-b;
		if((i>>1)&1)
			ans+=c;
		else 
			ans-=c;
		if((i>>2)&1)
			ans+=d;
		else 
			ans-=d;
		if(ans==7){
			cout<<s[0];

		if((i>>0)&1)
			cout<<"+";
		else 
			cout<<"-";
		
		cout<<s[1];
		
		if((i>>1)&1)
			cout<<"+";
		else 
			cout<<"-";

		cout<<s[2];
		
		if((i>>2)&1)
			cout<<"+";
		else 
			cout<<"-";

		cout<<s[3]<<"=7";
		return ;

		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
//#STAY_HOME
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  string N;
  in(N);
  rep(i,3){
    if(N[i]=='7'){
      out("Yes");
      return;
    }
  }
  out("No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3652
//Name: Doctor's Memorable Codes
//Level: 2
//Category: 文字列,やるだけ
//Note: コピペ可能な変換表はAOJ0088にある

/**
 * 最初の変換はやるだけ。
 * 二段目の変換は、他の符号語のprefixになっているような符号語が存在しないため、どれかの符号語にマッチするまで貪欲に取っていけば良い。
 *
 * オーダーは O(|S|)。
 */
#include <iostream>
#include <string>
#include <map>

using namespace std;

string conv(char c) {
    int ord = c - 'A';
    string res;
    for(int i = 4; i >= 0; --i) {
        if(ord & (1<<i)) res += "1";
        else res += "0";
    }
    return res;
}

bool solve() {
    string line;
    if(!getline(cin, line)) return false;

    string code;
    for(char c : line) {
        switch(c) {
        case ' ':
            code += "11010";
            break;
        case '.':
            code += "11011";
            break;
        case ',':
            code += "11100";
            break;
        case '-':
            code += "11101";
            break;
        case '\'':
            code += "11110";
            break;
        case '?':
            code += "11111";
            break;
        default:
            code += conv(c);
        }
    }

    map<string,char> dict;
    dict["101"] = ' ';
    dict["000000"] = '\'';
    dict["000011"] = ',';
    dict["10010001"] = '-';
    dict["010001"] = '.';
    dict["000001"] = '?';
    dict["100101"] = 'A';
    dict["10011010"] = 'B';
    dict["0101"] = 'C';
    dict["0001"] = 'D';
    dict["110"] = 'E';
    dict["01001"] = 'F';
    dict["10011011"] = 'G';
    dict["010000"] = 'H';
    dict["0111"] = 'I';
    dict["10011000"] = 'J';
    dict["0110"] = 'K';
    dict["00100"] = 'L';
    dict["10011001"] = 'M';
    dict["10011110"] = 'N';
    dict["00101"] = 'O';
    dict["111"] = 'P';
    dict["10011111"] = 'Q';
    dict["1000"] = 'R';
    dict["00110"] = 'S';
    dict["00111"] = 'T';
    dict["10011100"] = 'U';
    dict["10011101"] = 'V';
    dict["000010"] = 'W';
    dict["10010010"] = 'X';
    dict["10010011"] = 'Y';
    dict["10010000"] = 'Z';

    string ans, buf;
    for(char c : code) {
        buf += c;
        auto it = dict.find(buf);
        if(it != end(dict)) {
            ans += it->second;
            buf = "";
        }
    }
    cout << ans << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1204