akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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 (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    string N;
    cin >> N;
    if(N[0]=='7' or N[1]=='7' or N[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;   
    }

    return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


void go(int tc){



    ll n, m, k;    cin >> n >> m >> k;
    ll a[n + 1] = {0}, b[m + 1] = {0};
    for(int i = 1;i <= n;i++)    cin >> a[i];
    for(int i = 1;i <= m;i++)    cin >> b[i];

    partial_sum(a, a + n + 1, a);
    partial_sum(b, b + m + 1, b);

    int ans = 0;
    for(int i = 0;i <= n;i++){
        ll left = k - a[i];
        if(left < 0)    continue;

        int l = 0, r = m;
        while(l <= r){
            int mid = (l + r) >> 1;
            if(b[mid] <= left)
                l = mid + 1;
            else
                r = mid - 1;
        }

        ans = max(ans, i + r);
    }

    cout << ans;
}




int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

    int t = 1, tc = 1;//  cin >> t;
    while(t--)  go(tc++);

}

Measured memory_bytes: 6780
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	k := scanInt()

	arr := []int{}
	for i := 1; i*i <= n; i++ {
		arr = append(arr, i, n/i)
	}
	sort.Ints(arr)
	// debug(arr)
	dp := make([]map[int]int, k+1)
	dp[0] = map[int]int{}
	dp[0][1] = 1
	for i := 0; i < k; i++ {
		dp[i+1] = map[int]int{}
		pre := 0
		sum := 0
		for _, e := range arr {
			num := e - pre
			sum += (dp[i][e] * num) % MOD
			sum %= MOD
			dp[i+1][n/e] = sum
			pre = e
		}
		// debug(dp[i+1])
	}
	ans := 0
	pre := 0
	for i := 0; i < len(arr); i++ {
		num := arr[i] - pre
		ans += dp[k][arr[i]] * num
		ans %= MOD
		pre = arr[i]
	}

	fmt.Fprintln(wr, ans)

}

// MOD constant
const MOD = 1000000007


Measured memory_bytes: 445056
using System;
namespace Sample{
class Sample
  {
    static void Main(string[] args)
    {
      int N=int.Parse(Console.ReadLine());
    string[] str =Console.ReadLine().Split(' ');
      int[] input=new int[N];
      int flg =0;
      for(int i=0;i<=N-1;i++){
        input[i]=int.Parse(str[i]);
        if((input[i]%2)==0){
          if(((input[i]%3)!=0)&&((input[i]%5)!=0)){
            flg=1;
          }
        }
      }
      if (flg==1){
        Console.WriteLine("DENIED");
      }else{
        Console.WriteLine("APPROVED");
      }
     
      
    
  }
 
}
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <climits>
#include <string>
#include <string.h>
#include <algorithm>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<int, int> pii;
const ll MOD = (ll)1e9 + 7;
const int N = (int)1e5 + 7;
ll n,a,b,c,d, fac[N], invfac[N], dp[1001][1001];

ll mod_pow(ll base, ll e){
    ll ret =1;
    while(e){
        if(e%2) ret = (ret*base)%MOD;
        base = (base*base)%MOD;
        e /= 2;
    }
    return ret;
}

ll inv(ll x){
    return mod_pow(x, MOD-2);
}

ll solve(ll left, ll i){
    
    if(left == 0) return 1;
    
    if(i > b || left < 0) return 0;
    
    if(dp[left][i] != -1) return dp[left][i];
    
    ll ret = solve(left, i+1);
    for(ll j=c;j<=d;j++){
        ll s = i*j;
        if(s > left) break;
        ll tmp = mod_pow(invfac[i], j);
        tmp = (tmp*invfac[j])%MOD;
        tmp = (tmp*solve(left-s, i+1))%MOD;
        ret += tmp;
        ret %= MOD;
    }
    return dp[left][i] = ret;
}

int main() {
    cin >> n >> a >> b >> c >> d;
    
    fac[0] = 1;
    for1(i,1000) fac[i] = (fac[i-1]*i)%MOD;
    forn(i,1001) invfac[i] = inv(fac[i]);
    
    memset(dp,-1,sizeof dp);
    ll ret = solve(n, a)*fac[n];
    ret %= MOD;
    cout << ret <<endl;
    return 0;
}

Measured memory_bytes: 8192
import math

n, d = map(int, input().strip().split())

a = [[0 for i in range(d)] for j in range(n)]

score = 0

for i in range(n):
    a[i] = input().strip().split()
    
for i in range(n):
    for m in range(n-i-1):
        k=0
        if d >1:
            for l in range(d):
                k += (int(a[i][l])-int(a[i+m+1][l]))*(int(a[i][l])-int(a[i+m+1][l]))
            
            if math.sqrt(k).is_integer():
                score += 1
                
        else:
            score += 1
            
        
    
print(score)


Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
q=int(input())
num=[0]*(10**5+1)
ans=sum(a)
for i in a:
    num[i]+=1
for i in range(q):
    b,c=map(int,input().split())
    ans=ans+(c-b)*num[b]
    num[c]+=num[b]
    num[b]=0
    print(ans)
    
    

Measured memory_bytes: 20968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end, step) for (ll i = beg; i < end; i += step)

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> table;
    rep(i, 0, n, 1)
    {
        ll a;
        cin >> a;
        table.push_back({a, i + 1});
    }
    sort(table.rbegin(), table.rend());

    ll dp[n + 1][n + 1];
    dp[0][0] = 0;

    ll i = 0;
    for (pair<ll, ll> p : table)
    {
        i++;
        if (i == 1)
        {
            dp[1][0] = p.first * abs(p.second - n);
            dp[1][1] = p.first * abs(p.second - 1);
            continue;
        }
        rep(j, 0, i + 1, 1)
        {

            if (j == 0)
            {
                dp[i][j] = dp[i - 1][0] + p.first * abs(p.second - n + (i - 1));
            }
            else if (j == i)
            {
                dp[i][j] = dp[i - 1][j - 1] + p.first * abs(p.second - j);
            }
            else
            {
                ll m1, m2;
                m1 = dp[i - 1][j - 1] + p.first * abs(p.second - j);
                m2 = dp[i - 1][j] + p.first * abs(p.second - n + (i - 1 - j));
                dp[i][j] = max(m1, m2);
            }
        }
    }
    ll ans = dp[n][1];
    rep(i, 1, n + 1, 1)
    {
        if (dp[n][i] > ans)
        {
            ans = dp[n][i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  vector<int64_t> a(87);
  a.at(0)=2;
  a.at(1)=1;
  for(int i=2;i<N+1;i++){
    a.at(i)=a.at(i-1)+a.at(i-2);
  }
  
  cout << a.at(N) << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
N = int(input())
S = list(sorted(map(int,input().split())))
cnt = 0
for j in range(1,N-1):
  k=j+1
  for i in range(j):
    while True:
      
      if k == N or S[i]+S[j] <= S[k]:
        k-=1
        break
      k+=1
    #print(i,j,k)
    #print(S[i],S[j], S[j+1:k+1],k-j)
    cnt += k-j
print(cnt)


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

int main() {
  int n, d;
  cin >> n >> d;
  int sum = 2*d + 1;
  int cnt = 0;
  while(n > 0) {
    n -= sum;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);

  int R, N;
  while (cin >> R >> N && R + N ){
    vector<int> LS(N);
    vector<int> RS(N);
    vector<int> HS(N);
    
    map<int, int> C[30];
    
    REP(i, N){
      cin >> LS[i] >> RS[i] >> HS[i];
      
      REP2(j, LS[i], RS[i]){
        REP(k, HS[i]){
          C[k][j] = true;
        }
      }
    }

    // cout << C[3][0] << endl;
    
    vector<pair<int, int> > PS;
    
    REP2(x, -30, 30) REP(y, 25){
      if (abs(x) >= R) continue;

      bool ok = true;
      REP(j, N) if (LS[j] < x && x < RS[j] && HS[j] > y){
        ok = false;
      }
      
      if (ok && (!C[y][x - 1] ||!C[y][x])){
        // cout << x << " " << y << endl;
         PS.push_back(make_pair(x, y));  
      }
      
    }
    
    double res = 1e9;
    for (auto p : PS){
      res = min(res, R + p.second - sqrt(R * R - p.first * p.first));
      // cout << p.first << " " << p.second << " " << res << endl;
    }
    printf("%.4lf\n", res);
  }
  return 0;
}

Measured memory_bytes: 1304
while True:
    cnt = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break

    for i in range(1, n - 1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    cnt += 1
    print(cnt)


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

int main(){
  bool a[1000000];

  a[0]=a[1]=false;
  for(int i=2;i<1000000;i++){
    a[i]=true;
  }

  for(int i=2;i*i<1000000;i++){
    if(a[i]){
      for(int j=i*i;j<1000000;j+=i){
        a[j]=false;
      }
    }
  }

  int n[1000000];

  int tmp=0;
  for(int i=0;i<1000000;i++){
    if(a[i]){
      tmp++;
    }
    n[i]=tmp;
  }

  while(true){
    int m;
    cin>>m;

    if(cin.eof()){
      break;
    }

    cout<<n[m]<<endl;

  }

  return 0;
}



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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

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

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vi p(a),q(b),r(c);
	for(auto &i:p)cin >> i;
	for(auto &i:q)cin >> i;
	for(auto &i:r)cin >> i;
	sort(p.rbegin(),p.rend());
	sort(q.rbegin(),q.rend());
	for(int i=0; i<x; i++)r.eb(p[i]);
	for(int i=0; i<y; i++)r.eb(q[i]);
	sort(r.rbegin(),r.rend());
	ll ans = 0LL;
	for(int i=0; i<x+y; i++){
		ans += r[i];
	}
	cout << ans << endl;
}


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

int main(){
    int x, y, z;
    while(cin >> x >> y >> z, x+y+z){
        vector<int> v(x);
        for(int i = 0; i < x; i++)  cin >> v[i];
        vector<int> e(y+1, 0), a(y+1, 0);
        for(int i = 0; i < z; i++){
            int n;  cin >> n;
            cin >> e[n] >> a[n];
        }
        vector<vector<double>> dp(y+1, vector<double>(5001, 0));
        dp[0][0] = 1.0;
        for(int i = 0; i < y; i++){
            for(int j = 0; j < 5001; j++){
                if(dp[i][j] == 0.0) continue;
                for(int k = 0; k < x; k++){
                    int ni = i+v[k], nj = j;
                    if(ni > y)  ni = y;
                    if(e[ni] == 1)  ni = min(y, ni+a[ni]);
                    else if(e[ni] == 2) nj += a[ni];
                    else if(e[ni] == 3) nj = max(0, nj-a[ni]);
                    dp[ni][nj] += dp[i][j] / x;
                }
            }
        }
        double ans = 0;
        for(int i = 0; i < 5001; i++)   ans += dp[y][i]*i;
        cout << (int)ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4928
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    temp = a[i]
    j = i - 1
    while j >= 0 and a[j] > temp:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = temp
    a_str = [str(s) for s in a]
    print(' '.join(a_str))


Measured memory_bytes: 5608
#include<stdio.h>
int main(){
    int h,w;
    int i,j;
    while(1){
    scanf("%d%d",&h,&w);
    if(h==0 && w==0) break;
    for(i=0;i<h;i++){
        if(i==0 || i==h-1){
            for(j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        else{
            printf("#");
            for(j=0;j<w-2;j++){
                printf(".");
            }
            printf("#\n");
        }
    }
    printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
//桁
int kt(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
signed main(){
  string s;
  cin>>s;
  if(s=="Sunny")
    cout<<"Cloudy";
  if(s=="Cloudy")
    cout<<"Rainy";
  if(s=="Rainy")
    cout<<"Sunny";
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int count = 0;
    
    if (a == b && b == c) {
      count ++;
    }
    if (a != b) {
      count ++;
    }
    if (b != c) {
      count ++;
    }
    if (c != a) {
      count ++;
    }
    System.out.println(count);
  }
}

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

int main(void)
{
	int n, a, q, k;
	cin >> n;
	vector<int> A;
	rep(i, n)
	{
	    cin >> a;
		A.push_back(a);
	}

    cin >> q;
    rep(i, q)
    {
        cin >> k;
        cout << lower_bound(A.begin(), A.end(), k) - A.begin()  << " " << upper_bound(A.begin(), A.end(), k) - A.begin() << endl;
    }
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
 
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

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

    int X;
    cin >> X;

    for (int k=2;k<=360;k++) {
        if ((k*X) % 360 == 0) {
            cout << k << endl;
            return 0;
        }
    }

    
    

    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int key;
	struct node *left;
	struct node *right;
}node;

void insert(node **p,int x){
	node *new=malloc(sizeof(node));
	new->key=x;
	new->left=NULL;
	new->right=NULL;
	
	while((*p)!=NULL){
		if((*p)->key > x)
			p=&((*p)->left);
		else
			p=&((*p)->right);
	}
	(*p)=new;
	
	return;
}

int find(node *p,int x){

	while(p!=NULL){
		if(p->key == x)return 1;
		
		if(p->key > x)
			p=p->left;
		else
			p=p->right;
	}
	
	return 0;
	
}

void inorder(node *p){
	
	if(p->left!=NULL)
		inorder(p->left);
	
	printf(" %d",p->key);
	
	if(p->right!=NULL)
		inorder(p->right);
	
	return;
}

void preorder(node *p){
	
	printf(" %d",p->key);
	
	if(p->left!=NULL)
		preorder(p->left);
	
	if(p->right!=NULL)
		preorder(p->right);
	
	return;
}

void print(node *root){
	inorder(root);
	printf("\n");
	
	preorder(root);
	printf("\n");
	
	return;
}

node * Delete(node *p,int x){
	
	if(p->key == x){
	
		if(p->left==NULL && p->right==NULL)/*葉*/
			return NULL;
		
		if(p->left==NULL || p->right==NULL){/*子1つ*/
			if(p->left!=NULL)
				return p->left;
			else
				return p->right;
		}
		
		node **q=&(p->right);
		while((*q)->left!=NULL)
			q=&((*q)->left);
		p->key=(*q)->key;
		(*q)=Delete((*q),(*q)->key);
		return p;
	
	}
	
	if(p->key > x)
		p->left=Delete(p->left,x);
	else
		p->right=Delete(p->right,x);
	
	return p;
	
}

int main(){
	int n,i,x;
	node *root=NULL;
	char com[10];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%s",com);
		
		switch(com[0]){
			case 'i':scanf("%d",&x);
					 insert(&root,x);
					 break;
			
			case 'f':scanf("%d",&x);
					 if(find(root,x))
					 	printf("yes\n");
					 else
					 	printf("no\n");
					 break;
					 
			case 'd':scanf("%d",&x);
					 root=Delete(root,x);
					 break;
					 
			case 'p':print(root);
					 break;
		}
	}
	
	return 0;
	
}


Measured memory_bytes: 14268
from collections import deque
from sys import stdin
N = int(stdin.readline().rstrip())
d = deque()
for i in range(N):
    op_key = stdin.readline().rstrip().split()
    if op_key[0] == 'insert':
        d.appendleft(op_key[1])
    elif op_key[0] == 'delete':
        try:
            d.remove(op_key[1])
        except:
            pass
    elif op_key[0] == 'deleteFirst':
        d.popleft()
    elif op_key[0] == 'deleteLast':
        d.pop()
print(*d)


Measured memory_bytes: 69732
input = int(input())

FIVE_H_CONIN = 500
FIVE_COIN = 5

amari = input % FIVE_H_CONIN

five_result = (int(amari / FIVE_COIN)) * 5
five_h_result = ((input - amari) / FIVE_H_CONIN) * 1000

print(int(five_result + five_h_result))


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

int main() {
    int n,k;
    string s;
    cin>>n>>k>>s;
    s[k-1]+=32;
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long mypow(long long x,long long y){
    x %= mod;
    long long res = 1%mod;
    while (y)
    {
        if(y&1)
        res =(res*x) % mod;
        y >>= 1;
        x =(x*x)%mod;
    }
    return res;
}
int main()
{
    long long n;
    cin >> n;
    long long ans= (mypow(10, n) - 2 * mypow(9, n) + mypow(8, n))%mod;
    if(ans<0){
        ans += mod;
    }
    cout << ans;
}

Measured memory_bytes: 3644
n = int(input())

def recursive(s):
    if int(s) > n:
        return 0
    ret = 0
    if s.count('3')>0 and s.count('5')>0 and s.count('7')>0:
        ret = 1
    for c in '753':
        ret += recursive(s+c)
    return ret           

print(recursive('0'))

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

using namespace std;

int main() {
  int64_t N, x;
  cin >> N >> x;

  int64_t a[N+1] = {};
  for(int i=1;i<=N;i++)
    cin >> a[i];

  int64_t op = 0;
  for(int64_t i=1;i<=N;i++) {
    if(a[i-1] + a[i] > x) {
      int64_t _op = a[i-1] + a[i] - x;
      a[i] -= _op;
      op += _op;
    }
  }

  cout << op << endl;

  return 0;
}


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

#include <stdlib.h>

using namespace std;

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

  vector<int> h;
  vector<int> ans;
  for(int i=0;i<n;++i){
    int temp;
    cin >> temp;
    h.push_back(temp);
  }

  ans.push_back(0);
  int temp = abs(h[0] - h[1]);
  ans.push_back(temp);

  for(int i=2; i<n; i++){
    if(ans[i-2] + abs(h[i] - h[i-2]) > ans[i-1] + abs(h[i] - h[i-1])){
      ans.push_back(ans[i-1] + abs(h[i] - h[i-1]));
    }else{
      ans.push_back(ans[i-2] + abs(h[i] - h[i-2]));
    }
  }

  cout << ans[n-1] << endl;
        return 0;
}

Measured memory_bytes: 1400
import sys
sys.setrecursionlimit(10**6)
N = int(input())
P = [[] for _ in range(N + 1)]
AB = []
for _ in range(N - 1):
    a, b = [int(_) for _ in input().split()]
    P[a].append(b)
    P[b].append(a)
    AB.append((a,b))
C = 0

for p in P:
    if len(p) > C:
        C = len(p)


P2 = dict()
def f(n, pre, used):
    c = 1
    for i, next_n in enumerate(P[n]):
        if pre == next_n: continue
        if c == used: c += 1
        # P2[n][next_n] = c
        # P2[next_n][n] = c
        if n > next_n:
            a, b = next_n, n
        else:
            b,a = next_n, n
        P2[(a,b)] = c
        f(next_n, n, c)
        c += 1


print(C)
f(1, -1, 0)
for ab in AB:
    print(P2[ab])


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  long low, high;
  low = (a + x - 1) / x;
  high = b / x;
  cout << high - low + 1 << endl;
}


Measured memory_bytes: 3612
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(map(int,input().split()))
    BC = [list(map(int,input().split())) for _ in range(m)]

    BC = sorted(BC,key=lambda x:(x[1]),reverse=True)
    append_list = []
    for b,c in BC:
        if len(append_list)>=n:
            break
        append_list+=[c]*b
    A+=append_list
    A.sort(reverse=True)
    print(sum(A[:n]))

if __name__=='__main__':
    main()

Measured memory_bytes: 35376
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int h, w;
  cin >> h >> w;
  vector<string> c(2*h);
  REP(i, h) cin >> c[2*i], c[2*i+1] = c[2*i];
  REP(i, 2*h) cout << c[i] << endl;
  return 0;
}

Measured memory_bytes: 256
/*
ID: duttonl1
TASK: LCS.cpp 
LANG: C++
*/
#include <bits/stdc++.h>

#define pb push_back
#define fst first
#define snd second
#define DEBUGA(a, b) cout << "[ "; for (auto _x = (a); _x != (b); _x++) cout << *_x << " "; cout << "]"<< endl
#define DEBUG(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string>_it(_ss); err(_it, args); };cout << endl
#define fr(i,x) for (int i = 0; i < int(x); i++)
#define frab(i,a,b) for (int i = int(a); i < int(b); i++)
#define sz(x) ((int) (x).size())
void run();
int main() {
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}

using namespace std;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "; ";
    err(++it, args...);
}


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

#define TOP 0
#define LEFT 1
#define DIAG 2
void run() {
    string s, t;
    cin >> s >> t;
    int dp[sz(s)+1][sz(t)+1];

    fr(i,sz(s)+1) dp[i][0] = 0;
    fr(j,sz(t)+1) dp[0][j] = 0;
    for (int i = 1; i <= sz(s); i++)
        for (int j = 1; j <= sz(t); j++) {
            if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else {
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }

    string r;
    int i = sz(s), j = sz(t);
    while (i >= 0 && j >= 0) {
        if (dp[i-1][j] == dp[i][j]) i--;
        else if (dp[i][j-1] == dp[i][j]) j--;
        else {
            r.pb(s[i-1]);
            i--; j--;
        }

    }
    reverse(r.begin(),r.end());
    cout << r << endl;
}




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

int main()
{
    int s;
    vector<int> v;

    while (cin >> s) v.push_back(s);
    sort(v.begin(), v.begin() + 4);
    reverse(v.begin(), v.begin() + 4);
    cout << v[0] + v[1] + v[2] + max(v[4], v[5]) << endl;

    return 0;
}

Measured memory_bytes: 1216
#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,int(math.sqrt(g))+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False

    first = True

if g != 1:
    cnt += 1

print(cnt+1)

Measured memory_bytes: 5172
object Main extends App{
  var num = scala.io.StdIn.readLine()
  var a =  num.split(" ")(0).toInt
  var b =  num.split(" ")(1).toInt
  var c = num.split(" ")(2).toInt

  if (a==b){
    println(c)
  }else if (a==c){
    println(b)
  }else{
    println(a)
  }
}

Measured memory_bytes: 27212
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<vector>
#include<queue>

using namespace std;

/*
//1
int main(){
	int d, c;
	cin >> d >> c;

	cout << d*c << endl;

	return 0;
}
*/

/*
//2
int main(){
	int c1, c5, c10,c50,c100, c500;
	cin >> c1 >>  c5 >> c10 >> c50 >> c100 >> c500;
	int x = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
	if(x>=1000) cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}*/



//3
int main(){
	int N;
	cin >> N;
	for(int i=0; i<N; i++){
		int k, p;
		cin >> k >> p;
		int x = k%p;
		if(x == 0) x = p;
		cout << x << endl;

	}

	return 0;
}


/*
//4
int main(){


	return 0;
}
*/

//=====

/*
//5
int main(){
	int N,M,p;
	cin >> N >> M >> p;
	int left = -1;
	int right = N;
	int mini,ma;
	vector<int> all;
	for(int i=0; i<M; i++){
		int tmp;
		cin >> tmp;
		all.push_back(tmp);
	}
	sort(all.begin(), all.end());
	for(int i=0; i<M; i++){
		int tmp = all[i];
		if(tmp < p) left = tmp;
		if(tmp > p && tmp < right) right = tmp;
		if(i == 0) mini = tmp;
		if(i == M-1) ma = tmp;
	}

	if(left == -1) left = N-ma;
	if(right == N) right = N+mini;

	cout << (N-max(p-left,right-p))*100 << endl;

	return 0;
}
*/

/*
//6
int main(){


	return 0;
}
*/

/*
//7
int main(){


	return 0;
}
*/

/*
//8
int main(){


	return 0;
}
*/

/*
//9
int main(){


	return 0;
}
*/

/*
//10
int main(){


	return 0;
}
*/


Measured memory_bytes: 3116
import java.util.*;

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

        Map<String, Integer> test = new HashMap<>();
        test.put("A", 10);
        test.put("B", 11);
        test.put("C", 12);
        test.put("D", 13);
        test.put("E", 14);
        test.put("F", 15);

        if(test.get(x)>test.get(y)) {
            System.out.println(">");
        } else if (test.get(x)<test.get(y)) {
            System.out.println(("<"));
        } else {
            System.out.println("=");
        }
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <algorithm>

using namespace std;
 
template<class T>
T read()
{
    T value;
    std::cin >> value;
    return value;
}
 
template<class F>
void times_do(size_t n, F func)
{
    for(size_t i = 0; i < n; ++i) func();
}

int main()
{
    string s,t;
    cin >> s >> t;
    sort(begin(s),end(s));
    sort(begin(t),end(t),[](char a, char b){ return a > b;});
    cout << (s < t ? "Yes" : "No") << '\n';
    return 0;
}

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



void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
int A,B;
int ans=0;
void solve(){
	cin>>A>>B;
	if(B%A==0)cout<<A+B<<endl;
	else cout<<B-A<<endl;
}


int main(){

    solve();
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

_LL combination(_LL n, _LL r)
{
    _LL ret = 1;
    rep(i, r) ret = (ret * ( n - i )) / (i + 1); 
    return ret;
}

_LL getans(_LL *n, _LL k, int l)
{
    if( k > l ) return 0;
    if( l <= 0 ) return 1;
    if( k == 0 ) return 1;
    if( n[0] == 0 )  return getans( n + 1, k, l - 1);

    _LL k9m = 1;
    rep(i, k -1) k9m *= 9;
    _LL k9 = k9m * 9;
    return combination(l - 1, k) * k9 + (n[0] - 1) * combination(l - 1, k - 1) * k9m + getans(n + 1, k - 1, l - 1);
}

int main()
{
    string s;
    _LL k;
    cin >> s >> k;
   _LL *n = new _LL[s.length()];
    rep(i, s.length()) n[i] = s[i] - '0';
    cout << getans(n, k, s.length());
    delete n;
    return 0;    
}

Measured memory_bytes: 3628
t=int(input())
from functools import lru_cache
for _ in range(t):
    n,a,b,c,d=map(int,input().split())
    @lru_cache(maxsize=100000)
    def f(n):
        if n==0:
            return 0
        if n==1:
            return d
        ans=d*n
        q,r=divmod(n,2)
        if r==0:
            ans=min(ans,f(q)+a+d*r)
        else:
            ans=min(ans,f(q)+a+d*r,f(q+1)+a+d*(2-r))
        q,r=divmod(n,3)
        if r==0:
            ans=min(ans,f(q)+b+d*r)
        else:
            ans=min(ans,f(q)+b+d*r,f(q+1)+b+d*(3-r))
        q,r=divmod(n,5)
        if r==0:
            ans=min(ans,f(q)+c+d*r)
        else:
            ans=min(ans,f(q)+c+d*r,f(q+1)+c+d*(5-r))
        return ans
    print(f(n))

Measured memory_bytes: 12392
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    // #pragma GCC optimize("Ofast")
    using namespace std;
    //library
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double
    //scankar
    #define sz(x) (int)(x).size()
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    typedef map<int,int> mii;
    typedef map<int,bool> mib;
    typedef map<char,int> mci;
    typedef map<string,int> msi;
    
    const int INF = 1e18L + 5;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    //direction
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;
    //debugger

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    void solve()
    {
        cin>>n;
        if(n%1000==0)
            cout<<0<<endl;
        else
            cout<<(1000-(n-(n/1000)*1000))<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MAX_N 10001

//??±
struct TPile{
  int x; int y;
};

//?£?
struct TFence{
  double length;
  int a,b;
};
 
typedef struct TPile Pile;
typedef struct TFence Fence;

  
Pile *pile;
Fence *fence;

int par[MAX_N];
int rank[MAX_N];
 
//Union Find Tree?????????????????????
//????????¶?????§??????????????????????????§???
//?????¨??????????´???????????????????
void init(int n){
  int i;
  for(i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}


//x?????????????´?????±??????????????????£??¨????????????
int find(int x){
  if(par[x]==x){
    return x;
  }else {
    return par[x] = find(par[x]);
  }
}
 
//x,y????±?????????????????????¨??????
void unite(int x,int y){
  x =find(x);
  y =find(y);
  if(x==y){
    return ;
  }
  if(rank[x] < rank[y]){
    par[x] = y;
  }else {
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}
 
//x,y????±?????????????????????????????????????
int same(int x,int y){
  return find(x)==find(y);
}
 
//?????????????????????(Fence.length?????????)
void FenceSort(int s,int e,Fence* array){
  int i,j,k;
  i=s-1;
  j=e;
  while(i<j){
    while(++i<e&&array[i].length<array[e].length);
    while(--j>=s&&array[j].length>=array[e].length);
    if(i<j){
      //??¢??°????????¨??????????????????
      array[i].length+=array[j].length;
      array[j].length=array[i].length-array[j].length;
      array[i].length-=array[j].length;
 
      array[i].a+=array[j].a;
      array[j].a=array[i].a-array[j].a;
      array[i].a-=array[j].a;
 
      array[i].b+=array[j].b;
      array[j].b=array[i].b-array[j].b;
      array[i].b-=array[j].b;
 
    }
  }
  if(i<e){
    //?????????????????????
 
    array[e].length+=array[i].length;
    array[i].length=array[e].length-array[i].length;
    array[e].length-=array[i].length;
 
    array[e].a+=array[i].a;
    array[i].a=array[e].a-array[i].a;
    array[e].a-=array[i].a;
 
    array[e].b+=array[i].b;
    array[i].b=array[e].b-array[i].b;
    array[e].b-=array[i].b;
 
    i++;
  }
  if(s<j)FenceSort(s,j,array);
  if(e>i)FenceSort(i,e,array);
}
 
int main(){
  int n,m;
  char s[16];
  int i,j,a,b,d;
  double res;
  if(!fgets(s,16,stdin))return 1;
  sscanf(s,"%d %d",&n,&m);
  pile=(Pile*)malloc(sizeof(Pile)*(n+1));
  fence=(Fence*)malloc(sizeof(Fence)*m);
  for(i=1;i<=n;i++){
    fgets(s,16,stdin);
    sscanf(s,"%d %d",&a,&b);
    pile[i].x=a;
    pile[i].y=b;
  }

  for(i=0;i<m;i++){
    fgets(s,16,stdin);
    sscanf(s,"%d %d",&a,&b);
    fence[i].a=a;
    fence[i].b=b;
    fence[i].length=sqrt((pile[a].x-pile[b].x)*(pile[a].x-pile[b].x)+(pile[a].y-pile[b].y)*(pile[a].y-pile[b].y));
  }
  
  FenceSort(0,m-1,fence);
  res=0;
  init(n+1);
  for(j=m-1;j>=0;j--){
    if(!same(fence[j].a,fence[j].b)){
      unite(fence[j].a,fence[j].b);
    }else{
      res+=fence[j].length;
    }
  }
  free(pile);
  free(fence);
  printf("%lf\n",res);
  return 0;
}

Measured memory_bytes: 1944
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int start = 0;
        int end = s.length() -1;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                start = i;
                break;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == 'Z') {
                end = i;
                break;
            }
        }
        System.out.println(end - start + 1);
    }
}

Measured memory_bytes: 40296
N,A,B=map(int,input().split())
S=input()
passnumber=0
Bnumber=0

for i in range(N):
    if S[i]=="c":
        print("No")
    elif S[i]=="a" and passnumber<A+B:
        print("Yes")
        passnumber+=1
        #print("passnumber is "+str(passnumber))
        
    elif S[i]=="b" and passnumber<A+B and Bnumber<B:
        print("Yes")
        Bnumber+=1
        passnumber+=1
        #print("Bnumber is "+str(Bnumber))
    else:
        print("No")
        

Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

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


signed main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,n) cin>>a[i];

	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(a[j-1]>a[j]){
				swap(a[j-1],a[j]);
				ans++;
			}
		}
	}
	rep(i,n){
		if(i>0 ) cout<<' ';
		cout<<a[i];
	}
	cout<<endl;

	cout<<ans<<endl;
	return 0;
}




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

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

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

constexpr ll kMod = 1e9 + 7;

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

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

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

int main() {
  init();

  ll A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  const char* s = S.c_str();
  if (S.size() != A + B + 1) {
    cout << "No" << endl;
    return 0;
  }

  REP(i, 0, S.size()) {
    if (i == A) {
      if (s[i] != '-') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] != '0' && s[i] != '1' && s[i] != '2' && s[i] != '3' && s[i] != '4' && s[i] != '5' && s[i] != '6' && s[i] != '7' && s[i] != '8' && s[i] != '9') {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

int main(){
    int N, tmp, ans=0;
    cin >> N;
    map<int, int> mp;

    for(int i=0; i<N; i++){
	cin >> tmp;
	mp[tmp]^=1;
    }

    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
    	ans += itr->second;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s; i < n; i++)
ll n;
ll P;
vector<ll> p;
map<ll,ll> ex;

void factorize(ll x){
	if(x%2==0){
		p.push_back(2);
		while(x%2==0){
			x/=2; ex[2]++;
		}
	}
	for(ll i = 3; i < sqrt(x)+1; i+=2){
		if(x%i==0){
			p.push_back(i);
			while(x%i==0){x/=i; ex[i]++;}
		}
		
	}
	if(x!=1){
		p.push_back(x);
		ex[x]++;
	}
	
}

int main(){
	cin>>n>>P;
	factorize(P);
	ll ans = 1;
	for(ll prime : p){
		if(ex[prime]<n)continue;
		else{
			ll tmp = ex[prime]/n;
			rep(i,0,tmp){
				ans*=prime;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    # D = 365
    D = int(readline())
    C = list(map(int, readline().split()))
    S = list(list(map(int, readline().split())) for _ in range(D))
    last = [0]*26
    v = 0

    for d in range(1,D+1):
        t = int(readline())
        last[t-1] = d
        v += S[d-1][t-1]
        for c, l in zip(C,last):
            v -= c*(d-l)
        print(v)


if __name__ == '__main__':
    main()


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

using namespace std;
#define ll long long

int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    for (int i=0;i<m;i++)
    {
        ll a;
        cin>>a;
        sum+=a;
    }
    cout<<max((ll)-1,n-sum);
    return 0;
}


Measured memory_bytes: 3676
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
H, W = map(int, input().split())
#N = int(input())
#S = str(input())

Q = []
for _ in range(H) :
  Q.append(str(input()))
#print (Q)

s = "##"
for _ in range(W) :
  s += "#"

print (s)
for i in range(H) :
  print ("#" + Q[i] + "#")
print (s)


Measured memory_bytes: 38384
n=int(input())
l=[input() for i in range(n)]
if len(set(l))!=n:
  print("No")
else:
  f=True
  for i in range(1,n):
    if (l[i-1])[-1]!=(l[i])[0]:
      f=False
      break
  print("Yes" if f else "No")
  

Measured memory_bytes: 3060
#C - Half and Half
#いつもの
a,b,c,x,y = list(map(int,input().split()))
#共通部分の枚数入れ
common = 0
#回答
ans = 0
#共通する部分をABピザの分割にするかどうかを判定する
if(x < y):
    common = x
else:
    common = y
if(c*2 < a+b):
    ans += c*2*common
else:
    ans += (a+b)*common
#どちらか片方多い部分をABピザの分割で買うかAもしくはB単品で買うか判定する
if(x < y):
    if(b < c*2):
        ans += b * (y-common)
    else:
        ans += c*2 * (y-common)
else:
    if(a < c*2):
        ans += a * (x-common)
    else:
        ans += c*2 * (x-common)
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define REP(i,st,ed) for(int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(int i=st,i##end=ed;i>=i##end;--i)
int read(){
	int x=0,f=1;
	char c=getchar();
	while((c<'0')||(c>'9')){if(c=='-')f=-1;c=getchar();}
	while((c>='0')&&(c<='9'))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
const int maxn=200005,maxm=4005,mod=1e9+7;
int n,x[maxn],y[maxn];
int dp[maxm][maxm];
int fac[maxm<<1],ifac[maxm<<1];
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1)res=1ll*res*x%mod;
		x=1ll*x*x%mod,y>>=1;
	}return res;
}
void get_fac(){
	fac[0]=1;
	REP(i,1,8000)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[8000]=ksm(fac[8000],mod-2);
	DREP(i,8000,1)ifac[i-1]=1ll*ifac[i]*i%mod;
}
int C(int x,int y){
	return 1ll*fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}
int main(){
	get_fac();
	n=read();
	REP(i,1,n){
		x[i]=read(),y[i]=read();
		++dp[2000-x[i]][2000-y[i]];
	}
	REP(i,0,4000)
		REP(j,0,4000){
			if(i)(dp[i][j]+=dp[i-1][j])%=mod;
			if(j)(dp[i][j]+=dp[i][j-1])%=mod;
		}
	long long ans=0;
	REP(i,1,n)
		ans+=dp[2000+x[i]][2000+y[i]]-C(2*x[i]+2*y[i],2*x[i]);
	((ans%=mod)+=mod)%=mod;
	ans=ans*500000004%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 64512
#include <stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  int i;
  int v[n];
  for(i=0;i<n;i++){
    scanf("%d", &v[i]);
  }
  for(i=0;i<n;i++){
    int c;
    scanf("%d", &c);
    v[i] = v[i] - c;
  }
  int ans = 0;
  for(i=0;i<n;i++){
    if(v[i] > 0){
      ans += v[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int N;
	string s;
	cin >> N >> s;
	int r = 0, b = 0;
	for (auto i : s) {
		if (i == 'R')r++;
		else b++;
	}
	if (r > b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int x;
    cin >> x;
    if(x<1200)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
}


Measured memory_bytes: 256
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(n, W):
    # oxoxoxoxoxoxox
    mini = sys.maxsize
    #print(n, W)
    for i in range(len(W)):
        #print(i)
        mini = min(abs(sum(W[0:i]) - sum(W[i:len(W)])), mini)
    #print("end")
    return mini


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    #print(parsed_lines)
    n = int(parsed_lines[0][0])
    W = [int(x) for x in parsed_lines[1]]
    # k = int(parsed_lines[0][1])
    # S = parsed_lines[1][0]
    # return n, k, S
    return n, W


if not do_submit:
    n, W = input_parse("""
    3
    1 2 3
    """)
    print(sol(n, W))

    n, W = input_parse("""
    4
    1 3 1 1
    """)
    print(sol(n, W))

else:
    n = int(input())
    W = list(map(int, input().split()))
    # print(sol(n, k, S))
    #S = input().strip()
    # S = input().strip()
    print(sol(n, W))



Measured memory_bytes: 3816