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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

int n, one,two,three, p;
vec<vec<vd>> dp;
/*FUNCs=================================================*/
double func(int one, int two, int three) {
    if(dp[one][two][three] != -1) return dp[one][two][three];
    if(one==0&&two==0&&three==0) return 0;
    double ret = 0;
    if(one>0) ret += func(one-1, two, three) * one;
    if(two>0) ret += func(one+1, two-1, three) * two;
    if(three>0) ret += func(one, two+1, three-1) * three;
    ret += n;
    ret *= 1.0/(one+two+three);
    dp[one][two][three] = ret;
    return ret;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(15);

    cin >> n;
    rep(i,n) {
        cin >> p;
        if(p==1) ++one;
        else if(p==2) ++two;
        else ++three;
    }
    dp.resize(301, vec<vd>(301, vd(301, -1)));
    cout << func(one, two, three) << '\n';
}

Measured memory_bytes: 219008
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(200000)
N, M = map(int, input().split())
# d = [0] * (N + 1)
adj = [set() for _ in range(N + 1)]
for _ in range(M):
    x, y = map(int, input().split())
    adj[x].add(y)
    # d[y] += 1

dp = [-1] * (N + 1)


def lp(x: 'int') -> 'int':
    if dp[x] >= 0:
        return dp[x]
    else:
        dp[x] = 0
        for y in adj[x]:
            dp[x] = max(dp[x], lp(y) + 1)
        return dp[x]


print(max(lp(i) for i in range(1, N + 1)))


Measured memory_bytes: 127600
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int cnt = 0;
        for (int i = 0 ; i < s.length() ; i++) {
            if (s.charAt(i) == '+') cnt++;
            else cnt--;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21716
package main

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

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func scanIntArray() []int {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	result := []int{}
	for i := 0; i < n; i++ {
		result = append(result, nextInt(sc))
	}

	return result
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	inputs := []Input{}
	for i := 0; i < n; i++ {
		id := nextInt(sc)
		childrenIds := []int{}
		childNum := nextInt(sc)
		for j := 0; j < childNum; j++ {
			childrenIds = append(childrenIds, nextInt(sc))
		}
		inputs = append(inputs, Input{id, childrenIds})
	}

	assemble(inputs)
}

type Input struct {
	key      int
	children []int
}

type Element struct {
	key      int
	parent   int
	depth    int
	children []Element
}

func assemble(in []Input) {
	// find root
	// if id exists but it doesn't appear as child, it's root
	children := make([]Input, 200000)
	for _, v := range in {
		for _, child := range v.children {
			children[child] = v
		}
	}
	var rootInput Input
	for _, v := range in {
		if children[v.key].children == nil {
			rootInput = v
			break
		}
	}

	sortedInput := make([]Input, 200000)
	for _, v := range in {
		sortedInput[v.key] = v
	}

	root := assembleRoot(rootInput)
	assembleChildren(&root, sortedInput)

	flat(root)
	sort.Slice(elems, func(i, j int) bool {
		return elems[i].key < elems[j].key
	})

	for _, elem := range elems {
		t := "root"
		if len(elem.children) == 0 && elem.depth != 0 {
			t = "leaf"
		} else if elem.depth != 0 {
			t = "internal node"
		}

		children := []string{}
		for _, child := range elem.children {
			children = append(children, strconv.Itoa(child.key))
		}

		fmt.Printf("node %v: parent = %v, depth = %v, %v, [%v]\n", elem.key, elem.parent, elem.depth, t, strings.Join(children, ", "))
	}
}

var elems []Element

func flat(elem Element) {
	elems = append(elems, elem)
	for _, v := range elem.children {
		flat(v)
	}
}

func assembleRoot(rootInput Input) Element {
	rc := []Element{}
	for _, child := range rootInput.children {
		rc = append(rc, Element{child, rootInput.key, 1, nil})
	}

	root := Element{rootInput.key, -1, 0, rc}

	return root
}

// recursive assenble children
func assembleChildren(elem *Element, sortedInput []Input) {
	if elem.children == nil {
		return
	}
	for i := range elem.children {
		elem.children[i].parent = elem.key
		newChildren := []Element{}
		for j := range sortedInput[elem.children[i].key].children {
			v3 := sortedInput[elem.children[i].key].children[j]
			child := Element{v3, elem.children[i].parent, elem.children[i].depth + 1, nil}
			newChildren = append(newChildren, child)
		}
		elem.children[i].children = newChildren
		elem.children[i].parent = elem.key
		assembleChildren(&elem.children[i], sortedInput)
	}
}



Measured memory_bytes: 37428
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath> 
#include <tuple>
#include <bitset>
//pair sort firstに揃う

#define int long long
#define double long double
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define incin2(n,m) int (n),(m); cin >> (n)>>(m);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
namespace Mathf
{
    const int INF = 1000000000000;
    const double PI = 3.14159274;
    const double Rad2Deg = 57.29578;
    const double log2(double a,double b);
    const double log2(double a,double b){
        return log(b)/log(a);
    }
} // namespace Mathf

using namespace std;

int MD(pair<int,int> a,pair<int,int> b){//ManhattanDisRance
    return abs(a.first-b.first) + abs(a.second-b.second);
}
int MOD(int a,int b){
    return abs(a%b);
}
template <typename T1,typename T2> bool Comp (pair<T1,T2> a,pair<T1,T2> b){
    if(a.first!=b.first){
        return a.first<b.first;//first昇順
    }
    if(a.second!=b.second){
        return a.second > b.second;//second降順
    }else{
        return  true;
    }
}
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    incin2(a,b);
    int sum=0;
    for(int i=1;i<=(b-a);i++){
        sum+=i;
    }
    cout<<sum-b<<endl;
    return 0;
}
 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String s;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.s = sc.next();
    }
    
    //解答処理
    private String solve() {
        String answer = s.replace(",", " ");
        
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


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

#define int 		long long
#define vi 			vector <int>
#define si 			set <int>
#define pii 		pair<int,int>
#define fr(n) 		for(__typeof(n) i=0;i<n;i++)
#define rep(i,a,b) 	for(__typeof(b) i=a;i<b;i++)
#define repi(i,b,a) for(__typeof(a) i=b;i>=a;i--)
#define tr(a) 		for(auto it=a.begin();it!=a.end();it++)
#define pb 			push_back
#define mp 			make_pair
#define F 			first
#define S 			second
#define FAST 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define time_passed	1.0 * clock() / CLOCKS_PER_SEC

void solve()
{
	int n;
	cin>>n;
	int a[n];
	int ans=0;
	fr(n)
	{
		cin>>a[i];
		if((i+1)%2 == 1){
		 if(a[i]%2 == 1)
			ans++;
	}
	}
	cout<<ans;
}

signed main()
{
	FAST
	int test=1;
	//cin>>test;
	while(test--)
	{
		solve();
	}
	cerr<<endl<<"Time elapsed : "<<time_passed<<endl;
	return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <stdio.h>
#include <string.h>
//#include <bits/stdc++.h>
using namespace std;
int s[101];
int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}

int main()
{
        int a,b,k;
        while(cin>>a>>b>>k)
        {
              int ans=gcd(a,b);
              int j=1;
              for(int i=1;i<=ans;i++)
              {
                  if(ans%i==0)
                      s[j++]=i;
              }
              cout<<s[j-k]<<endl;
        }
        return 0;
}

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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll N,X,aa,bb; cin >> N >> X;
    vector<int>a(N+1);
    vector<int>b(N);
    rep(i,N) cin >> a.at(i);
    a.at(N)=X;
    sort(a.begin(),a.end());
    for(int i=0;i<N;i++){
        b.at(i)=a.at(i+1)-a.at(i);
    }
    aa=b.at(0);
    for (int i = 1; i < N; i++) {
    bb=b.at(i);
    aa = gcd(aa, bb);
  }
  cout << aa << endl;
  }


Measured memory_bytes: 1024
def tetra(x):
    ret = ""
    for _ in range(3):
        ret = str(x%4) + ret
        x = (x-x%4)//4
    return ret
n = int(input())
mod = 10**9+7
if n<=2:
    print(4**n)
    exit()
DP = [[0]*64 for i in range(n+1)]
for i in range(64):
    if tetra(i) not in ["023","032","203"]:
        DP[0][i] = 1
for i in range(1,n+1):
    for j in range(64):
        tj = tetra(j)
        jprelist = [j//4+l*16 for l in range(4)]
        for jprev in jprelist:
            tjp = tetra(jprev)
            if ((tjp[1:]  in ["02","20"] or tjp[:2] == "02" or tjp == "012")
                and (tj[2] == "3")) or (tjp[1:]  == "03" and tj[2] == "2"):
                continue
            else:            
                DP[i][j] = (DP[i][j]+DP[i-1][jprev])%mod
print(sum(DP[n-3])%mod)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i);
  for (ll i = 0; i < N; i++) cin >> B.at(i);

  ll ans = 0;
  for (ll k = 0; k <= 62; k++) {
    vector<ll> C(N), D(N);
    for (ll i = 0; i < N; i++) {
      C.at(i) = A.at(i) & ((1 << (k+1)) - 1);
      D.at(i) = B.at(i) & ((1 << (k+1)) - 1);
    }
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
    ll p = 0; 
    ll q = 0; 
    ll r = 0; 
    for (ll i = N-1; i >= 0; i--) {
      function<ll(ll,ll)> upd = [&](ll j0, ll t) {
	for (ll j = j0; j < N; j++) {
	  if (C.at(i) + D.at(j) >= (t << k)) return j;
	}
	return N;
      };
      p = upd(p, 1);
      q = upd(q, 2);
      r = upd(r, 3);
      ll x = ((q - p) + (N - r)) % 2;
      ans = ans ^ (x << k);
    }
    DLOG("ans = %lld", ans);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 8516
#include <iostream>
#define REP(i,n) for (int i=0;i<(n);i++)

using namespace std;

int gcd (int a, int b) {
  int tmp,r;
  if ( a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }

  while((r = a % b) != 0) {
    a = b;
    b = r;
  }
  return b;
}

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

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

    REP(i, n-1) {
      cin >> b;
      a = lcm(a, b);
    }

    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3088
a,b,c,d=map(int,input().split())
if a<=c and b<=d:
    print(max(b-c,0))
elif a>c and b<=d:
    print(max(b-a,0))
elif a<=c and b>d:
    print(max(d-c,0))
elif a>c and b>d:
    print(max(d-a,0))

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin>>n;
    ll a[200010],sum[200010];
    rep(i,n){
        cin>>a[i];
        sum[i+1]=sum[i]+a[i];
    }
    ll m=sum[n];
    ll ans=LLINF;
    rep2(i,1,n){
        ans=min(ans,abs(sum[i]-(m-sum[i])));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000009;
const double pi = acos(-1);

int main() {
    string S;
    cin >> S;
    ll total = 0;
    REP(i,S.size()) {
        total += S[i]-'0';
    }
    cout << (total%9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3696
import java.util.Scanner;
class Main{
    int H,W,i,r;
    boolean x = true;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        if(H == 0 && W == 0){
            x = false;
        }
        while(x == true){
            for(i = 0; i < H; i++){
                for(r = 0; r < W; r++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
            H = sc.nextInt();
            W = sc.nextInt();
            if(H == 0 && W == 0){
                x = false;
            }
        }
    }
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 26832
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> Ans = new ArrayList<Integer>();
		String line;
		
		int[] prime = Eratos();
		
		while((line = in.readLine()) != null){
			int size = Integer.parseInt(line);
			if(size==0) break;
			
			int pay = 0;
			for(int n=0; n<size; n++){
				line = in.readLine();
				String[] dst = line.split(" ");
				int center = Integer.parseInt(dst[0]);
				int range = Integer.parseInt(dst[1]);
				
				
				int min = Math.max(2, center-range);
				int max = Math.min(center+range, 999983);
				
				if(prime[min] != prime[min-1]){
					pay += prime[max] - prime[min];
				}
				else{
					pay += prime[max] - prime[min] - 1;
				}
			}
			
			Ans.add(Math.max(0, pay));
		}
		
		for(int n=0; n<Ans.size(); n++){
			System.out.println(Ans.get(n));
		}		
	}
	
	public int[] Eratos(){
		int[] prime = new int[1000000];
		int c = 0;
		for(int i=2; i<1000000; i++){
			if(prime[i]==0){
				c++;
				prime[i] = c;
				long big = i*i;
				if(big > 1000000){
					for(int j=i; j<1000000; j++){
						if(prime[j]==0){
							c++;
							prime[j] = c;
						}
						else{
							prime[j] = c;
						}
					}
					break;
				}
				for(int j=i*i; j<1000000; j+=i){
					prime[j] = -1;
				}
			}
			if(prime[i]==-1){
				prime[i] = c;
			}
		}
		
		return prime;
	}
}

Measured memory_bytes: 15000
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,s,d;
char str[50][20];
int check();
int main(){
    for(;;){
        cin>>n;
        if(n==0)exit(0);
        cin>>m>>s>>d;
        m--,s--;
        for(int i=0;i<d;i++)cin>>str[i];
        if(check()==0){
            cout<<0<<endl;
            goto end;
        }
            for(int i=0;i<d;i++){
                for(int j=0;j<n-1;j++){
                    if(str[i][j]=='0'){
                        str[i][j]='1';
                        if(check()==0){
                            cout<<i+1<<" "<<j+1<<endl;
                            goto end;
                        }
                        str[i][j]='0';
                    }
                }
            }
            cout<<1<<endl;
        end:;
        for(int i=0;i<50;i++)for(int j=0;j<20;j++)str[i][j]=0;
    }
    return 0;
}
int check(){
    int x=m;
    for(int i=0;i<d;i++){
        for(int j=1;j<n-1;j++){
            if(str[i][j-1]=='1'&&str[i][j]=='1')return -1;
        }
    }
    for(int i=0;i<d;i++){
        if(x<n-1&&str[i][x]=='1')x++;
        else if(x>=1&&str[i][x-1]=='1')x--;
    }
    if(x==s)return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
        int a,b,c,n;
        scanf("%d %d %d",&a,&b,&c);
        n=0;
        if(a>b){
                n=a;
                a=b;
                b=n;
}
        if(a>c){
                n=a;
                a=c;
                c=n;
}
        if(b>c){
                n=b;
                b=c;
                c=n;
}
        printf("%d %d %d\n",a,b,c);
        return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n+1),b(n);
  rep(i,n+1){
    cin >> a.at(i);
  }
  rep(i,n){
    cin >> b.at(i);
  }
  ll count = 0;
  rep(i,n){
    int num = min(a.at(i),b.at(i));
    count+=num;
    b.at(i)-=num;
    num = min(a.at(i+1),b.at(i));
    count+=num;
    a.at(i+1)-=num;
  }
  cout << count << endl;
}


Measured memory_bytes: 1024
input = gets
input = input.split(' ').map(&:to_i)
n = input[0]
a = 4
b = 7

x_max = 25
y_max = 14
x = 0
y = 0
result = false
while true
  y = 0
  while true
    break if n < a * x + b * y
    if n == a * x + b * y
      result = true
      break;
    end
    y += 1
    break if y_max < y
  end
  break if x_max < x
  x += 1
end

puts "Yes" if result
puts "No" unless result

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

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

const ll mod =  1000000007;  //ansを出力する時は (ans % mod + mod) % mod とする(負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    int n,m; cin >> n >> m;
    int sx[n],sy[n],cx[m],cy[m];
    rep(i,n) cin >> sx[i] >> sy[i];
    rep(i,m) cin >> cx[i] >> cy[i];
    rep(i,n){
        int tmp_p = 1;
        int tmp_dis = inf;
        rep(j,m){
            int dis = abs(sx[i]-cx[j]) + abs(sy[i]-cy[j]);
            if(dis < tmp_dis){
                tmp_p = j+1;
                tmp_dis = dis;
            }
        }
        cout << tmp_p << endl;
    }
}



Measured memory_bytes: 256
s = input()
dif = abs(int(s[0]+s[1]+s[2])-753)
for i in range(len(s)-2):
    num=int(s[i]+s[i+1]+s[i+2])
    dif_num = abs(num-753)
    if dif_num < dif:
        dif = dif_num
print(dif)


Measured memory_bytes: 3060
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 28, 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 


    int n , m;
    cin>>n>>m;

    vector<vector<int>> bulb(m+1);

    for(int i=1; i<=m; ++i){
        int ki;
        cin>>ki;
        for(int j=0; j<ki; ++j){
            int temp;
            cin>>temp;
            bulb[i].pb(temp);
        }
    }


    vector<int> pi(m+1);

    for(int i=1; i<pi.size(); ++i){

        cin>>pi[i];

    }
    int ans = 0;

    for(int i = 0; i<(1<<n) ; ++i){
        bool ok = true;

        for(int j=1; j<bulb.size() && ok ;++j){
            int counter =0;
            for(int e:bulb[j]){

                if((i>>(e-1))&1){
                    counter++;
                }
            }

            counter%=2;

            if(counter!=pi[j]){
                ok = false;
            }
        }
        ans+=ok;
    }

    cout<<ans<<endl;





    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


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

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

	int c, a, n;
	for (int i = 0; i < Q; i++) {
		cin >> c >> a >> n;

		int team = 0;

		team += min({ c, a, n });
		c -= team;
		a -= team;
		n -= team;

		while (c >= 2 && a >= 1) {
			c -= 2;
			a--;
			team++;
		}
		while (c >= 3) {
			c -= 3;
			team++;
		}
		cout << team << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import java.util.*;
 
public class Main{
 
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    ArrayList<Double> nums = new ArrayList<>();
    double a = 0;
    int i = 0;
    
    while(sc.hasNext()){
    	nums.add(sc.nextDouble());
    }
    
    for(double num : nums){
      if(i == 0){
        i = 1;
      }else{
    	a += 1/num;
      }
    }
    
    System.out.println(1/a);
    
  }
}

Measured memory_bytes: 23252
S=input()
bb=S[0]
b=S[1]
flag=False
if bb==b:
    flag=True
    print("1 2")
if len(S)>2:
    for i in range(2,len(S)):
        if flag:
            break
        if S[i]==b or S[i]==bb:
            flag=True
            print(str(i-1)+" "+str(i+1))
            break
        bb,b=b,S[i]
if not flag:
    print("-1 -1")

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
int n;
int k;
string s;

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
double EPS = 1e-10;
double INF = 1LL << 55;
double PI = acos(-1);
#define equals(a, b) (fabs(a - b) < EPS)
#define lt(a, b) (a - b < -EPS)
#define le(a, b) (lt(a, b) || equals(a, b))
struct Point3D {
    double x, y, z;
    Point3D(){}
    Point3D(double x, double y, double z) : x{x}, y{y}, z{z} {}
  
    Point3D operator + (const Point3D& p) const{
        return Point3D(x + p.x, y + p.y, z + p.z);
    }
    
    Point3D operator - (const Point3D& p) const{
        return Point3D(x - p.x, y - p.y, z - p.z);
    }
    
    Point3D operator * (double k) const{
        return Point3D(x * k, y * k, z * k);
    }
    
    Point3D operator / (double k) const{
        return Point3D(x / k, y / k, z / k);
    }
};

double dot(const Point3D& a, const Point3D& b){
    return a.x * b.x + a.y * b.y + a.z * b.z;
}

double norm(const Point3D& p){
    return dot(p, p);
}

double norm(const Point3D& a, const Point3D& b){
    return (a.x - b.x) * (a.x - b.x) +
           (a.y - b.y) * (a.y - b.y) +
           (a.z - b.z) * (a.z - b.z);
}

double abs(const Point3D& p){
    return sqrt(norm(p));
}

double dist(const Point3D& a, const Point3D& b){
    return abs(a - b);
}
struct Segment {
    Point3D s, t;
    Segment() {}
    Segment(Point3D s, Point3D t) : s{s}, t{t} {}
};
double distance_SP(const Segment& s, const Point3D& p)
{
    double a = dot(s.t - s.s, s.t - s.s);
    double b = dot(s.t - s.s, s.s - p);
    double c = dot(s.s - p, s.s - p);
    double t = -b / a;
    if (t < 0) return abs(s.s - p);
    if (t > 1) return abs(s.t - p);
    return sqrt(a * t * t + 2 * b * t + c);
}
double x,y,z,r[2001],po[15],ans,num[15];
int n,m,p,o=0;
Point3D X;
vector<Point3D>v,c;
vector<int>t[15];
bool used[15];
void calc(){
  double score=0;
  set<int>res;
  r(i,m)if(used[i])score+=num[i];
  if(score<ans)return;
  r(i,m)if(used[i]){
    r(j,t[i].size())res.insert(t[i][j]);
  }
  if(res.size()<=p)ans=score;
}
void dfs(int d){
  if(d==m)calc();
  else{
    used[d]=0;
    dfs(d+1);
    used[d]=1;
    dfs(d+1);
  }
}
int main(){
  while(cin>>n>>m>>p,n){
    v.clear();
    c.clear();
    r(i,15)t[i].clear();
    r(i,n){
      cin>>x>>y>>z>>r[i];
      v.push_back(Point3D(x,y,z));
    }
    r(i,m){
      cin>>x>>y>>z>>po[i];
      c.push_back(Point3D(x,y,z));
    }
    cin>>x>>y>>z;
    X=Point3D(x,y,z);
    r(i,m)r(j,n){
      if(dist(c[i],v[j])<=r[j]&&dist(X,v[j])<=r[j])continue;
      if(distance_SP(Segment(c[i],X),v[j])<=r[j])t[i].push_back(j);
    }
    r(i,m)num[i]=po[i]/((c[i].x-X.x)*(c[i].x-X.x)+(c[i].y-X.y)*(c[i].y-X.y)+(c[i].z-X.z)*(c[i].z-X.z));
    ans=0;
    dfs(0);
    printf("%.4f\n",ans);
  }
}

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

int main() {

    ll N, K;
    cin >> N >> K;

    vl P(N), C(N);
    ll tmp;
    rep(i, N) {
        cin >> tmp;
        P[i] = tmp-1;
    }
    rep(i, N) {
        cin >> C[i];
    }

    vector<vl> S(N, vl(N));
    vl lp(N);
    rep(i, N) {
        ll score = 0;
        ll cnt = 0;
        ll x = i;
        while(i != P[x]) {
            x = P[x];
            score += C[x];
            S[i][cnt] = score;
            cnt++;

        }
        S[i][cnt] = score + C[i];
        lp[i] = cnt+1;
    }

    // rep(i, N) {
    //     cout << "i : " << i << "  ";
    //     rep(j, lp[i]) {
    //         cout << S[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    ll ans = -1e18;
    rep(i, N) {
        if (K < lp[i]) {
            rep(j, K) {
                ans = max(ans, S[i][j]);
            }
        }
        else {
            if (S[i][lp[i]-1] > 0) {
                ll loop = K / lp[i];
                ll n = K % lp[i];
                ll score = loop * S[i][lp[i]-1];
                ll t_ans = 0;
                rep(j, n) {
                    t_ans = max(t_ans, S[i][j]);
                }
                ans = max(ans, score + t_ans);
                if (loop > 0) {
                    score = (loop-1) * S[i][lp[i]-1];
                    t_ans = 0;
                    rep(j, lp[i]) {
                        t_ans = max(t_ans, S[i][j]);
                    }
                    ans = max(ans, score + t_ans);
                }
            }
            rep(j, lp[i]) {
                ans = max(ans, S[i][j]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

public class Main {

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

	class UF{
		int p[];
		int rank[];
		int cnt[];
		public UF(int n) {
			p = new int[n];
			rank = new int[n];
			cnt = new int[n];

			for(int i=0; i<n; i++) {
				p[i] = i;
				rank[i]=1;
				cnt[i]=1;
			}
		}

		public boolean same(int x, int y) {
			return find(x) == find(y);
		}

		private int find(int x) {
			if(p[x] == x) return x;
			p[x] = find(p[x]);
			return p[x];
		}

		public void unite(int x, int y) {
			link(find(x), find(y));
		}

		private void link(int x, int y) {
			if(x==y) return;
			if(rank[x] > rank[y]) {
				p[y] = x;
				cnt[x] += cnt[y];
			}else {
				p[x] = y;
				cnt[y] += cnt[x];
				if(rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}

		public int size(int x) {
			return cnt[find(x)];
		}
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();

		UF uf = new UF(n);
		int f[] = new int[n];
		for(int i=0; i<m; i++) {
			int a = sc.nextInt(); a--;
			int b = sc.nextInt(); b--;
			uf.unite(a,b);
			f[a]++;
			f[b]++;
		}
		ArrayList<ArrayList<Integer>> blk = new ArrayList<ArrayList<Integer>>();
		for(int i=0; i<n; i++) {
			blk.add(new ArrayList<Integer>());
		}
		for(int i=0; i<k; i++) {
			int c = sc.nextInt(); c--;
			int d = sc.nextInt(); d--;
			blk.get(c).add(d);
			blk.get(d).add(c);
		}

		for(int i=0; i<n; i++) {
			int ans = uf.size(i) - f[i] - 1;
			for(int b : blk.get(i)) {
				if(uf.same(i, b)) {
					ans--;
				}
			}
			System.out.print(ans + (i==n-1 ? "\n" : " "));
		}
		sc.close();
	}

}


Measured memory_bytes: 130448
#include <iostream>
#include <vector>
#include <deque>
#include <utility>

bool process_node(int h, int w, int currentCount, std::vector<std::vector<int>>& board, std::vector<std::vector<int>>& visited, std::deque<std::pair<int, int>>& q) {
    if (h < 0 || h >= board.size() || w < 0 || w >= board[0].size()) return false;

    if (board[h][w] == 1 && visited[h][w] == 0) {
        q.push_back(std::make_pair(h, w));
        visited[h][w] = currentCount + 1;
        
        if (h == board.size() - 1 && w == board[0].size() - 1) return true;
    }

    return false;
}

int main() {
    int h, w, white = 0;
    std::cin >> h >> w;
    std::vector<std::vector<int>> v(h, std::vector<int>(w));
    std::string s;

    for (int i = 0; i < h; i++) {
        std::cin >> s;
        for (int j = 0; j < w; j++) {
            v[i][j] = ((s[j] == '.') ? (white++, 1) : 0);
        }
    }

    std::vector<std::vector<int>> visited(h, std::vector<int>(w, 0));
    std::deque<std::pair<int, int>> q;
    q.push_back(std::make_pair(0,0));
    visited[0][0] = 1;

    bool flg = false;

    while(!q.empty()) {
        auto& next = q.front();
        auto currentCount = visited[next.first][next.second];
        process_node(next.first - 1, next.second, currentCount, v, visited, q);
        process_node(next.first, next.second - 1, currentCount, v, visited, q);

        if (process_node(next.first + 1, next.second, currentCount, v, visited, q) || process_node(next.first, next.second + 1, currentCount, v, visited, q)) {
            flg = true;
            break;
        }
        q.pop_front();
    }

    std::cout << (flg ? white - visited[h-1][w-1] : -1) << std::endl;

    return 0;
}

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b, c = MAP()
l = sorted([a, b, c])

# 全部奇数ならきれいに半分にはできない
if a % 2 and b % 2 and c % 2:
    print(l[0] * l[1])
else:
    print(0)


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

int main(){
  int N, A, B; cin >> N >> A >> B;
  for(int i=0; i<10000; i++){
    if(i%2==0){
      //Aの番
      if(B==2){
        cout << "Borys" << endl;
        return 0;
      }else{
        if(B-A==1){
          A--;
        }else{
          A++;
        }
      }
    }else{
      //Bの番
      if(A==N-1){
        cout << "Alice" << endl;
        return 0;
      }else{
        if(B-A==1){
          B++;
        }else{
          B--;
        }
      }
    }
  }
  cout << "Draw" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    string s,t;
    cin >> s >> t;
    if (s.size()<t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for (ll i=s.size()-t.size();i>=0;i--){
        for (ll j=i;j-i<t.size() and j<s.size();j++){
            if (s[j]!=t[j-i] and s[j]!='?'){
                break;
            }
            if (j-i==t.size()-1){
                for (ll k=0;k<i;k++){
                    if (s[k]=='?'){
                        cout << "a";
                    }else{
                        cout << s[k];
                    }
                }
                cout << t;
                for (ll k=i+t.size();k<s.size();k++){
                    if (s[k]=='?'){
                        cout << "a";
                    }else{
                        cout << s[k];
                    }
                }
                cout << endl;
                return 0;
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll arr[4];
    cin>>arr[0]>>arr[1]>>arr[2];
    ll product=arr[0]*arr[1]*arr[2];
    if(product%2==0)
        cout<<"0"<<endl;
    else
    {
        sort(arr,arr+3);
        cout<<arr[0]*arr[1]<<endl;
    }
    return 0;
}


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

using namespace std;

#define SZ(a) int((a).size())
#define mp make_pair
#define pb push_back
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt rt<<1
#define rrt rt<<1|1
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double EPS=1e-6;
inline void read(LL& x){int f=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(f=-1,x=0):(x=c-'0');while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=f;}
inline void read(int& x){LL t;read(t);x=t;}




int main(){//ios_base::sync_with_stdio(0);cin.tie(0);
    int x;read(x);
    int t1=x%10;
    int t2=(x%100)/10;
    int t3=(x%1000)/100;
    int t4=(x%10000)/1000;
    if(t1==t2&&t2==t3) printf("Yes\n");
    else if(t4==t2&&t2==t3) printf("Yes\n");
    else printf("No\n");
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

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

    vector<long long> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
        cin >> B[i];
    for (int i = 0; i < N; i++)
        cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int left = 0;
    vector<long long> BtoA(N);
    for (int i = 0; i < N; i++) {
        if (i != 0)BtoA[i] = BtoA[i - 1];
        for (int j = left; j < N; j++) {
            if (B[i] > A[j]) {
                BtoA[i]++;
            }
            else {
                left = j ;
                break;
            }
            if (j == N - 1)left = N ;
        }
    }
    left = 0;
    vector<long long> CtoB(N);
    for (int i = 0; i < N; i++) {
        if (i != 0)CtoB[i] = CtoB[i - 1];
        for (int j = left; j < N; j++) {
            if (C[i] > B[j]) {
                CtoB[i] += BtoA[j];
            }
            else {
                left = j;
                break;
            }
            if (j == N - 1)left = N;
        }
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += CtoB[i];
    }

    cout << ans << endl;
     
}

Measured memory_bytes: 4224
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [list(map(int, input().split())) for i in range(N)]
List = [A, B, C, D, E]
Time = []
Cost = []
answer = 0

for i in range(5):
    Time.append(List[i]%10)
    Cost.append(math.ceil(List[i]/10)*10)

for i in range(5):
    answer += Cost[i]

if Time.count(0)==5:
    print(answer)

else:
    Time = list(set(Time))
    if Time[0] == 0:
        Time.remove(0)

    answer = answer - (10-min(Time))

    print(answer)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int n, k;
  cin >> n >> k;

  int ans = k;
  rep (i, n - 1) ans *= (k - 1);

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

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

using namespace std;

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

	int num = 1;
	for (int i = 0; i < N; ++i) {
		if (a[i] == num) { ++num; }
	}
	cout << (num == 1 ? -1 : N - (num - 1)) << endl;

	return 0;
}


Measured memory_bytes: 1024
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;


int main(){
    FAST() ;
    int N , A , B ; cin >> N >> A >> B ;
    string str ; cin >> str ;
    int qualified = 0 , currB = 0 ;
    for( int i = 0 ; i < N ; i++ ){
        if( str[i] == 'a' ){
            if( qualified < A + B ){
                qualified++ ;
                cout << "Yes" << endl ;
            }
            else
                cout << "No" << endl ;
        }
        else if( str[i] == 'b' ){
            if( currB < B && qualified < A + B ){
                qualified ++ ; currB ++ ;
                cout << "Yes" << endl ;
            }
            else
                cout << "No" << endl ;
        }
        else
            cout << "No" << endl ;
    }
    return 0 ;
}


Measured memory_bytes: 848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <functional>
using namespace std;

typedef long long ll;

int n, m;
bool f[200001], l[200001];

int main() {
	cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n, d = map(int, input().split())
x = []
for i in range(n):
    l = list(map(int, input().split()))
    x.append(l)

cnt  = 0
for k in range(n-1):
    for i in range(k+1, n):
        sum = 0
        for j in range(d):
            sum += pow((x[k][j] - x[i][j]), 2)
        if math.sqrt(sum) %1 == 0:
            cnt += 1

print(cnt)

Measured memory_bytes: 38768
# -*- coding: utf-8 -*-
import sys
from itertools import product
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
S = readline().decode().rstrip()
x,y = map(int,readline().split())
L = [len(i) for i in S.split('T')]
x -= L[0]
X = L[2::2]
Y = L[1::2]

dx = {0}
dy = {0}

for i in X:
    dx = {x+j for x,j in product(dx,[i,-i])}
for i in Y:
    dy = {y+j for y,j in product(dy,[i,-i])}

if x in dx and y in dy:
    print('Yes')
else:
    print('No')

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a,b,c, x;
    cin>>a>>b>>c>>x;
    ll ans = 0;
    REP(i,a+1) REP(j,b+1){
        ll ab = (500*i)+(100*j);
        int temp = x-ab;
        if(temp < 0) continue;
        else if(temp/50 <= c) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()

max_c = 0
for i in range(1, N-1):
    S_f = S[:i]
    S_l = S[i:]
    count = 0
    memo = []
    for f in S_f:
        if f not in memo and f in S_l:
            count += 1
            memo.append(f)
    if count > max_c:
        max_c = count
print(max_c)

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}
const MODULO: usize = 1_000_000_000 + 7;
fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();

    let mut ans = 0;

    for i in 0..60 {
        let mut count = 0;
        for j in 0..n {
            if a[j]>>i & 1 == 1 {
                count += 1;
            }
        }
        let mut a = (count * (n - count)) % MODULO;
        a *= 2usize.pow(i) % MODULO;
        ans += a % MODULO;
    }
    
    println!("{}", ans % MODULO);
}

Measured memory_bytes: 15608