akhauriyash/Code-Regression huggingface dataset:
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val n = input.split(LINE_SEPARATOR).head.toInt
    val List(t, a) = input.split(LINE_SEPARATOR).tail.head.split(" ").map(_.toInt).toList
    val h = input.split(LINE_SEPARATOR).tail.tail.head.split(" ").map(_.toInt)

    case class Candidate(i: Int, diff: Double)

    ((0 until n).map { i =>
      Candidate(i, abs(t - h(i) * 0.006 - a))
    }.minBy(_.diff).i + 1).toString
  }


  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """2
      |12 5
      |1000 2000""".stripMargin -> """1
                                         |
                                   |""".stripMargin,
    """3
      |21 -11
      |81234 94124 52141""".stripMargin -> """3"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 25528
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
 
if(a==b&&a==c){
printf("1");
}
else if(a!=b&&b!=c&&c!=a){
printf("3");
}
else{
printf("2");
}
return 0;
}

Measured memory_bytes: 128
x,n = gets.chomp.split(' ').map(&:to_i)
if (n == 0)
  puts x
  exit
end
p = gets.chomp.split(' ').map(&:to_i)
hoge = nil
fuga = nil

x.upto(201) do |i|
  unless (p.include?(i))
    hoge = i
    break
  end
end
x.downto(-101) do |i|
  unless (p.include?(i))
    fuga = i
    break
  end
end

puts ((x-fuga).abs <= (x-hoge).abs) ? fuga : hoge

Measured memory_bytes: 14352
#!/usr/bin/env python3

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
T = [int(input())-1 for i in range(D)] #B

last = {}
for i in range(26):
    last[i] = -1

s = 0
for d in range(D):
    last[T[d]] = d
    s += S[d][T[d]]
    for i in range(26):
        #print(d-last[i])
        s -= C[i] * (d-last[i])
    print(s)


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

using namespace std;

int main() {
	int N, K;
	string S;
	cin >> N;
	cin >> S;
	cin >> K;

	char c = S[K-1];
	
	for (int i = 0; i < N; i++) {
		if (S[i] != c) {
			S[i] = '*';
		}
	}
	cout << S;
}

Measured memory_bytes: 256
a = [0]*5
m = [0]*5
def gobi(n):
    return int(str(n)[-1])
def wait(n):
    if n == 0:
        return 0
    else:
        return 10-n
for i in range(5):
    a[i] = int(input())
for i in range(5):
    m[i] = wait(gobi(a[i]))
print(sum(a)+sum(m)-max(m))

Measured memory_bytes: 38256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>s;
    if(n%2==1){
        return no,0;
    }
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i]){
            return no,0;
        }
    }
    yes;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int dp[55][3][3];
const int mod=1e9+7;

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    a="#"+a;
    b="#"+b;
    if(a[1]==b[1])
    {
        dp[1][0][0]=1;
        dp[1][1][1]=1;
        dp[1][2][2]=1;   
    }
    else
    {
        for(int j=0;j<3;j++)
            for(int k=0;k<3;k++)
                if(j!=k)
                    dp[1][j][k]=1;
    }

    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(a[i]==b[i])
                {
                    if(j==k)
                    {
                        for(int l=0;l<3;l++)
                            for(int m=0;m<3;m++)
                            {
                                if(l!=j&&m!=j)
                                dp[i][j][k]+=dp[i-1][l][m];
                            }
                    }
                }
                else
                {
                    if(j==k)
                        continue;
                    if(a[i-1]==a[i])
                    {
                        dp[i][j][k]=dp[i-1][j][k];
                    }
                    else
                    {
                        for(int l=0;l<3;l++)
                            for(int m=0;m<3;m++)
                            {
                                if(l!=j&&m!=k)
                                    dp[i][j][k]+=dp[i-1][l][m];
                            }
                    }
                }                    
                dp[i][j][k]%=mod;
            }
        }
    }
    int ans=0;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            ans+=dp[n][i][j];
            ans%=mod;
        }
    }
    cout<<ans;
    
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

bool piyo(pair<double, string> a,pair<double, string> b){
    if (a.first==b.first) {
        return a.second < b.second;
    }else{
        return a.first > b.first;
    }
}

int main(){
    for (; ;) {
        int n;
        cin >> n;
        if(n==0)break;
        vector<pair<double,string> > hoge;
        for (int i=0; i<n; i++) {
            string S;
            cin >>S;
            int p,a,b,c,d,e,f,s,m;
            cin >> p>>a>>b>>c>>d>>e>>f>>s>>m;
            double price=f*s*m-p;
            double time = a+b+c+(d+e)*m;
            hoge.push_back({price/time,S});
        }
        sort(hoge.begin(), hoge.end(),piyo);
        for (int i=0; i<hoge.size(); i++) {
            cout << hoge[i].second<<endl;
        }
        cout <<"#"<<endl;
    }
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
#define KOZYUN(a) SORT(a); REVERSE(a) 
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    INT(n);
    int ans = 0;
    VI cnt(n+1,0);
    rep(i,n){
        INT(a);
        if(a <= n) cnt[a]++;
        else ans++;
    }
    FOR(i,1,n+1) ans += cnt[i] - (cnt[i] < i? 0:i);
    ANS;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int n,c[200100][3];
long long dp[200100],s[200100];
struct node
{
	int p,v,l,r;
}a[200100];
struct edge
{
	int l;
	edge *next;
}*r[200100];
bool cmp1(node a,node b)
{
	return a.v<b.v;
} 
bool cmp2(node a,node b)
{
	return a.p<b.p;
} 
bool cmp3(node a,node b)
{
	return a.l>b.l;
}
int lowbit(int x)
{
	return (x&(-x));
}
void add(int x,int w,int b)
{
	//cout<<x<<endl;
	while(x<=n)
	{
		if(b==1) c[x][1]=min(c[x][1],w);
		if(b==2) c[x][2]=max(c[x][2],w);
		x=x+lowbit(x);
	}
}
int cmin(int x)
{
	int re=0x3f3f3f3f;
	while(x>0)
	{
		re=min(re,c[x][1]);
		x=x-lowbit(x);
	}
	return re;
}
int cmax(int x)
{
	int re=0;
	while(x>0)
	{
		re=max(re,c[x][2]);
		x=x-lowbit(x);
	}
	return re;
}
void ins(int x,int y)
{
	edge *p;
	p=new edge;
	p->l=x;
	p->next=r[y];
	r[y]=p;
}

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i].p,&a[i].v);
		sort(a+1,a+n+1,cmp2);
	for(int i=1;i<=n;i++) a[i].p=i;		
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<=n;i++) a[i].v=i;

	//for(int i=1;i<=n;i++)
	//	cout<<a[i].v<<' '<<a[i].p<<endl;
	for(int i=1;i<=n;i++)
	{
		c[i][2]=0;
		c[i][1]=0x3f3f3f3f;
	}
	for(int i=1;i<=n;i++)
	{
		a[i].l=min(i,cmin(n-a[i].p+1));
		add(n-a[i].p+1,i,1);	
	}
	for(int i=n;i>=1;i--)
	{
		a[i].r=max(i,cmax(a[i].p));
		add(a[i].p,i,2);
	}
//	for(int i=1;i<=n;i++)
//		cout<<a[i].l<<' '<<a[i].r<<endl;
	sort(a+1,a+n+1,cmp3);
	for(int i=1;i<=n;i++)
		ins(a[i].l,a[i].r);
	
	dp[0]=s[0]=1;
	for(int i=1;i<=n;i++)
	{
		s[i]=s[i-1];
		for(edge *p=r[i];p!=NULL;p=p->next)
		{
			//cout<<i<<' '<<p->l<<endl;
			if(p->l==1)dp[i]=(dp[i]+s[i])%mod;
			else dp[i]=(dp[i]+s[i]-s[p->l-2]+mod)%mod;
			//cout<<s[1]<<' '<<s[2]<<' '<<s[3]<<' '<<dp[i]<<endl;
			s[i]=(s[i-1]+dp[i])%mod;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}
/*3
2 5
6 1
3 7
4
3 7
2 9
8 16
10 8*/


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

int main()
{
 int n,t,a,ans;
  cin>>n>>t>>a;
  vector<int> v(n);
  for(int &i:v) cin>>i;
  float d=1000000.0;
  for(int i=0;i<n;i++)
  {
    float x = t - (0.006*1.0*v[i]);
    if(abs(x-(float)a)<d)
    {
      d = abs(x-(float)a);
      ans = i;
    }   
  }
  cout<<ans+1<<"\n";
  
  return 0;
}


Measured memory_bytes: 256
N = int(input())
words = []
s = input()
words.append(s)
ans = True
for i in range(N-1):
    t = input()
    if(t[0] == s[-1] and (t in words) == False):
        words.append(t)
        s = t
    else:
        ans = False
if(ans):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int n,k;
int a[N];

bool check(int len){
    int cnt=0;
    for(int i=1;i<=n;++i){
        int tmp=(a[i]-1)/len+1;
        cnt+=tmp-1;
        if(cnt>k) return false;
    }
    return true;
}

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);
    scanf("%d %d",&n,&k);

    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
    }

    int l=1,r=1e9;

    while(l<r){
        int mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }

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

    return 0;
}

Measured memory_bytes: 4608
N, K = map(int, input().split())
R, S, P = map(int, input().split())
te = str(input())
te = list(te)
point = 0

for i in range(1, N+1):
  flag = True
  if K < i:
    if te[i-1] == te[i-1-K]:
      te[i-1] = "a"
      flag = False
  if flag:
    if te[i-1] == "r":
      point += P
    elif te[i-1] == "s":
      point += R
    else:
      point += S
print(point)

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

#define mp make_pair
#define pb push_back

#define int int64_t

const int MOD = 1e9+7;
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k,x;
    cin>>k>>x;
    if(500*k>=x)
        cout<<"Yes";
    else
        cout<<"No";   

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
long long n,a,b,c;
int main()
{
	cin>>n;
	bool no=true;
	for(int i=1;i<=sqrt(n);i++)	
		if(n%i==0)
			a=i;
	cout<<a-1+(n/a)-1<<endl; 
} 

Measured memory_bytes: 256
package main

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

func main() {

	N := oneInt()
	M := oneInt()

	var sum int
	for i := 0; i < M; i++ {
		sum += oneInt()
	}

	if N-sum >= 0 {
		fmt.Print(N - sum)
	} else {
		fmt.Print(-1)
	}

}

func exp(val int) float64 {
	var temp float64
	for index := 1; index <= val; index++ {
		temp += float64(index)
	}
	return temp / float64(val)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


Measured memory_bytes: 2472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  string s;
  cin >> s;
  string ans;
  ans+=s[0];
  stringstream ss;
  ss << s.size()-2;
  ans+=ss.str();
  ans+=s[s.size()-1];
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(){

    int N;
    cin >> N;

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

    double ans = 0.0;

    for(i=0; i<N; i++) ans += 1.0/A.at(i);

    cout << 1.0 / ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

enum Station{A,B};

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

  Station station;
  if(s[0] == 'A'){
    station = A;
  }else{
    station = B;
  }

  for(int i = 1; i < 3; i++){
    switch(s[i]){
    case 'A':
      if(station == A){
        continue;
      }else{
        std::cout << "Yes" << std::endl;
        return 0;
      }
    case 'B':
      if(station == A){
        std::cout << "Yes" << std::endl;
        return 0;
      }else{
        continue;
      }
    }
  }

  std::cout << "No" << std::endl;

  return 0;
}


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

int main()
{
  int N;
  std::cin >> N;
  vector<pair<pair<string, int>, int>> A(N);
  rep(i,N)
  {
    std::string S;
    int a;
    std::cin >> S >> a;
    a *= -1;
    A[i] = make_pair(make_pair(S,a), i+1);
  }
  std::sort(A.begin(), A.end());
  rep(i,N)
  {
    std::cout << A[i].second << std::endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;

pair<long long, long long> dfs(vector<vector<int> >& adj, vector<bool>& used, int node){

    used[node] = true;
    long long f = 1LL;
    long long g = 1LL;
    for(int i = 0; i < (int)adj[node].size(); i++){
        if(!used[adj[node][i]]){
            pair<long long, long long> tmp = dfs(adj, used, adj[node][i]);
            f = f * tmp.second;
            g = g * tmp.first;
            f %= MOD;
            g %= MOD;
        }
    }

    f += g;
    f %= MOD;
    //cout << node + 1 << " " << f << " " << g << endl;
    return {f, g};
}

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


    vector<bool> used(n, false);
    pair<long long, long long> ans = dfs(adj, used, 0);
    cout << ans.first << endl;
    return 0;
}


Measured memory_bytes: 11264
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.numeric;   // gcd, fft

void main()
{
  auto rd = readln.split.to!(int[]), a = rd[0], b = rd[1], c = rd[2];
  writeln(c % gcd(a, b) == 0 ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    int x, a, b;
    scanf("%d%d%d", &x, &a, &b);

    if (abs(x-a)>abs(x-b)) printf("B\n");
    else printf("A\n");
    
    return 0;
}

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

int main(){
  int N; cin >> N;
  multiset<int> a;
  for(int i=0; i<N; i++){
    int tmp; cin >> tmp;
    a.insert(tmp);
  }
  int f=*(a.begin());
  int b=*(--a.end());
  if(f==b){
    if(f==N-1||f<=N/2) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if(f+1==b){
    int c=a.count(f);
    if(N-c>=2){
      if(b>=c+1&&b<=c+(N-c)/2){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
long long gcd(long long a,long long b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

long long lcm(long long a,long long b){
  long long g = gcd(a,b);
  return a/g*b;
}

int main(){
  
  long long int a,b,c,d;
  cin >>a >> b>>c>>d;
  
cout << (b-(b/c+b/d-b/lcm(c,d)))-(a-1-((a-1)/c+(a-1)/d-(a-1)/lcm(c,d))) << endl;
        }


Measured memory_bytes: 256
P = int(input())
A = [int(a) for a in input().split()]
X = [0] * P
fa = [1]
for i in range(1, P):
    fa.append(fa[-1] * i % P)
fainv = [pow(fa[-1], P-2, P)]
for i in range(1, P)[::-1]:
    fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]
def C(i):
    return fa[P-1] * fainv[i] * fainv[P-1-i] % P

for i in range(P):
    if A[i]:
        c = 1
        for j in range(P)[::-1]:
            X[j] = (X[j] - C(j) * c) % P
            c = -c * i % P
        X[0] = (X[0] + 1) % P
print(*X)


Measured memory_bytes: 44124
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日 10/22 21:00:20 2017

# Usage
#
"""
def checker(target):
    if len(target.split("AC")) > 1:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    target = input()
    checker(target)


Measured memory_bytes: 2940
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    if s[i]=="AC":
        ac += 1
    elif s[i]=="WA":
        wa += 1
    elif s[i]=="TLE":
        tle += 1
    elif s[i]=="RE":
        re += 1

print("AC"+" x "+str(ac))
print("WA"+" x "+str(wa))
print("TLE"+" x "+str(tle))
print("RE"+" x "+str(re))

Measured memory_bytes: 79176
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      
      // 判定
      int kyu = 0;
      if(X <= 599){
        kyu = 8;
      }else if(X <= 799){
        kyu = 7;
      }else if(X <= 999){
        kyu = 6;
      }else if(X <= 1199){
        kyu = 5;
      }else if(X <= 1399){
        kyu = 4;
      }else if(X <= 1599){
        kyu = 3;
      }else if(X <= 1799){
        kyu = 2;
      }else if(X <= 1999){
        kyu = 1;
      }
      
      // 出力
      System.out.println(kyu);
    }

}

Measured memory_bytes: 35540
N=int(input())
S=input()
MOD=10**9+7

p = [0 if c=='W' else 1 for c in S]
c = [p[i] ^ (0 if i&1 else 1) for i in range(len(p))]

if sum(c) != N:
    print(0)
    exit()

ans = 1
l = 0
for r in c:
    if r:
        if l < 1:
            print(0)
            exit()
        ans = ans * l % MOD
        l -= 1
    else: l += 1

for i in range(1,N+1):
    ans = ans * i % MOD

print(ans)

Measured memory_bytes: 55676
a, b, k = gets.chomp.split.map(&:to_i)
if a - 1 + k >= b + 1 - k || b + 1 - k <= a - 1 + k
  puts (a..b).to_a
else
  puts (a..(a - 1 + k)).to_a
  puts ((b + 1 - k)..b).to_a
end


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

N = int(input())
P = list(map(float, input().split()))

dp = [[1 if k == 0 else 0 for k in range(N+1)] for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(1, i+1):
        dp[i][j] = dp[i-1][j-1] * P[i-1] + dp[i-1][j] * (1-P[i-1])

print(dp[N][(N+1)//2])


Measured memory_bytes: 261436
#include <iostream>

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

//aとbの最大公約数を返す
long long gcd(long long a, long long b){
    while (a != 0 && b != 0){
        if (a >= b) a %= b;
        else b %= a;
    }
    return a + b;
}

signed main(){
    ll K, ans = 0;
    cin >> K;
    for(ll a = 1; a <= K; a++){
        for(ll b = 1; b <= K; b++){
            for(ll c = 1; c <= K; c++){
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
	int h,w;
	cin >> h >> w;
	char c[100][100];
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin >> c[i][j];
	for(int i=0;i<h*2;i++){
		for(int j=0;j<w;j++){
			cout << c[i/2][j];
		}
		cout << endl;
	}
	return 0;
}


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

string N;
int sum,len;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>N;
	len = N.length();
	for(int i = 0;i < len;i++){
		sum += N[i] - '0';
	}
	if(sum % 9 == 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int64_t gcd(int64_t a, int64_t b)
{
    if (a < b)
    {
        return gcd(b, a);
    }
    else if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, a % b);
    }
}

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

int main()
{
    int64_t n, m;
    cin >> n >> m;

    string s, t;
    cin >> s >> t;

    const auto g = gcd(n, m);

    bool success = true;
    for (int i = 0; i < g; i++)
    {
        if (s[n * i / g] != t[m * i / g])
        {
            success = false;
        }
    }
    cout << (success ? lcm(n, m) : -1) << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main(){

string st1,st2;
int n;
cin>>n;
for(int iii=0;iii<n;iii++){
cin>>st1>>st2;
int d=1,a=0,s1=0,s2=0;
int S=0;
for(int i=0;i<st1.size();i++){
if(st1[i]=='m'){s1+=d*1000;d=1;}
else if(st1[i]=='c'){s1+=d*100;d=1;}
else if(st1[i]=='x'){s1+=d*10;d=1;}
else if(st1[i]=='i'){s1+=d*1;d=1;}
else d=st1[i]-'0';

}
for(int i=0;i<st2.size();i++){
if(st2[i]=='m'){s2+=d*1000;d=1;}
else if(st2[i]=='c'){s2+=d*100;d=1;}
else if(st2[i]=='x'){s2+=d*10;d=1;}
else if(st2[i]=='i'){s2+=d*1;d=1;}
else d=st2[i]-'0';

}
S=s1+s2;
int r=S/1000;S=S%1000;
if(r>0){if(r>1)cout<<r;cout<<'m';}
r=S/100;S=S%100;
if(r>0){if(r>1)cout<<r;cout<<'c';}
r=S/10;S=S%10;
if(r>0){if(r>1)cout<<r;cout<<'x';}
r=S;
if(r>0){if(r>1)cout<<r;cout<<'i';}



cout<<endl;
}
return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

#define MAX 1000
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;


int main(){
  int n,a,s,g;
  while(cin>>n>>a>>s>>g, n+a+s+g){
    vector<vector<pair<int,string> > > l(n);
    vector<vector<bool> > canGo(n, vector<bool>(n));
    vector<bool> reach(n);
    REP(i,a){
      int x,y;
      string s;
      cin>>x>>y>>s;
      l[x].push_back(mp(y,s));
      canGo[x][y] = true;
    }

    REP(i,n){
      if(l[i].size() != 0){
        sort(l[i].begin(), l[i].end());
        vector<pair<int,string> >::iterator it = l[i].begin();
        string s1;
        while(it != l[i].end()){
          if(it != l[i].begin() && it->f == (it-1)->f){
            string s2 = it->s;
            if(s1.length() > s2.length() || s1 != s2.substr(0, s1.length())){
              it = l[i].erase(it);
            }else{
              it++;
            }
          }else{
            s1 = it->s;
            it++;
          }
        }
      }
    }


    REP(k,n) REP(i,n) REP(j,n)
      canGo[i][j] = (canGo[i][j] | (canGo[i][k] & canGo[k][j]));

    REP(i,n) reach[i] = canGo[i][g];
    reach[g] = true;

    string ans;
    typedef pair<string,int> pp;
    priority_queue<pp,vector<pp>,greater<pp> > pq;
    vector<set<string> > memo(n);

    if(!reach[s]){ ans = "NO"; goto end; }

    pq.push(mp("",s));
    while(true){
      pp p = pq.top();
      int now = p.s;
      string sp = p.f;
      pq.pop();

      if(now == g){
        ans = sp;
        goto end;
      }

      if(sp.length() >= 6*n){
        ans = "NO";
        goto end;
      }

      FOR(it,l[now]){
        int dist = it->f;
        string s = it->s;

        if(reach[dist]){
          if(memo[dist].find(sp + s) == memo[dist].end()){
            memo[dist].insert(sp + s);
            pq.push(mp(sp + s, dist));
          }
        }
      }
    }

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

Measured memory_bytes: 2836
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <tuple>
#include <cmath>
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,vector<int64_t>,int,vector<int64_t>> T; //sum,L,M,R;

int64_t rec(int l, int r, vector<int> &A){
    if(r<=l) return 0;
    if(r-l==1){
        if(A[l]>=0) return 1;
        else return 0;
    }else{
        int d = (l+r)/2;
        int64_t cnt = 0;
        int64_t sum=0;
        vector<int64_t> V;
        for(int i=d-1;i>=l;i--){
            sum+=A[i];
            V.push_back(sum);
        }
        sort(V.begin(), V.end());
        sum=0;
        for(int i=d;i<r;i++){
            sum+=A[i];
            cnt+=(V.end()-lower_bound(V.begin(), V.end(),-sum));
        }
        return cnt+rec(l,d,A)+rec(d,r,A);
    }
}

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        A[i]-=K;
    }
    cout<<rec(0,N,A)<<endl;

    return 0;
}

Measured memory_bytes: 2676
import java.util.Scanner;

public class Main {

	static int output[] = new int[10000];
	
	public static void main(String[] args) {
		int key=0, num, a, b;
		Scanner scan = new Scanner(System.in);
		
		//int in;
		while(true){
			num = scan.nextInt();
			if(num==0)break;
			
			for(int i=0;i<num;i++){
				a = Integer.parseInt(scan.next());
				b = Integer.parseInt(scan.next());
				if(a>b)
					output[key]+=(a+b);
				else if(a<b)
					output[key+1]+=(a+b);
				else{
					output[key] += a;
					output[key+1] += b;
				}
			}
			key+=2;
		}
		
		for(int i=0;i<key;i+=2)
			System.out.println(output[i]+" "+output[i+1]);
	}

}

Measured memory_bytes: 12000
#include <set>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    vi ans(n);
    rep(i, n){
        ans[a[i]-1] = i+1;
    }
    rep(i, n){
        cout << ans[i] << " ";
    }
    puts("");

    return 0;
}

Measured memory_bytes: 1536
from functools import lru_cache
h,w= map(int, input().split())
maze = [[-1 for i in range(w)] for j in range(h)]

ans = 0
for i in range(h):
    maze[i] = input()

INF = 10000

@lru_cache(None)
def dfs(y,x,flg,cnt):
    if y == h-1 and x ==w-1:
        if flg ==1:
            cnt+=1
        return cnt
    ans = [INF]
    for (ny, nx) in [(y+1, x), (y, x+1)]:
        if 0 <= nx < w and 0 <= ny < h:
            if maze[ny][nx] != maze[y][x]:
                if flg == 0: ans.append(dfs(ny,nx,1,cnt))
                else: ans.append(dfs(ny,nx,0,cnt+1))
            else:
                ans.append(dfs(ny,nx,flg,cnt))
    return(min(ans))

print(dfs(0,0,(0 if maze[0][0]=='.' else 1),0))


Measured memory_bytes: 139352
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def BinarySearch(num, List):
    if len(List) == 0:
        print("Erorr : list has no element")
        return
    left,right = 0,len(List)
    while left < right:
        mid  = (left+right)//2
        if num < List[mid]:#
            right = mid
        else:
            left = mid + 1
    return right


def main():
    n = ni()
    a = sorted(na())
    asub = [i for i in a]

    for i in range(n):
        ai = a[i]
        right = BinarySearch(ai, a)
        if right-1 != i:
            asub[right-1] = -1
            asub[i] = -1
            continue
        cnt = 2
        while right != n:
            right = BinarySearch(ai*cnt, a)
            if asub[right-1] == ai*cnt:
                asub[right-1] = -1
            cnt += 1
    
    ans = 0
    for i in range(n):
        if asub[i] != -1:
            ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()

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

using namespace std;
int n,i,a,c,nr,ok,v[100005],b[100005];
long long sum;
int main()
{
    cin>>n;
    for (i=1;i<=n+1;i++)
    {
        cin>>v[i];
    }
    for (i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    for (i=1;i<=n;i++)
    {
        if (b[i]>=v[i])
        {
            sum=sum+v[i];
            b[i]-=v[i];
            v[i]=0;
            if (v[i+1]>=b[i])
            {
                sum=sum+b[i];
                v[i+1]-=b[i];
            }
            else
            {
                sum=sum+v[i+1];
                v[i+1]=0;
            }
        }
        else
        {
            sum=sum+b[i];
            v[i]-=b[i];
        }
    }
    cout<<sum;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve(N: int):
    return N * N * N


def main():
    N = int(input())
    print(solve(N))


if __name__ == '__main__':
    main()


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

using namespace std;

const string AIZU = "AIZUNYAN";
string s;

bool check(int& n){
  int A=0, I=0, D=0, U=0, N=0, Y=0;
  for(int i=n; i<n+8; ++i){
    if(s[i] == 'A') ++A;
    if(s[i] == 'I') ++I;
    if(s[i] == 'D') ++D;
    if(s[i] == 'U') ++U;
    if(s[i] == 'N') ++N;
    if(s[i] == 'Y') ++Y;
  }
  return (A==2 && I==1 && D==1 && U==1 && N==2 && Y==1);
}

void solve(){
  if(s.size()<8) return;
  for(int i=0; i<s.size()-7; ){
    if(check(i)){
      s.replace(i, 8, AIZU);
      i+=8;
    }else{
      ++i;
    }
  }
}

int main(){
  cin >> s;
  solve();
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1192
a = int(input())
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = []
su  = 0
kk = 0
for i in range(a):
	d.append(b[i]-c[i])
	if b[i]-c[i] < 0:
		su += b[i]-c[i]
		kk += 1

d.sort()
d.reverse()
k = 0

j = 1

for i in range(a):
	if d[i] > 0:
		su += d[i]
		while kk:
			if d[-j] < 0:
				if abs(d[-j]) <= d[i]:
					d[i] +=  d[-j]
					d[-j] = 0
					j += 1
					k += 1
					kk -= 1
					if d[i] == 0 or d[-j] > 0:
						k += 1
						break
					if i == a - j:
						k += 1
						break
				else:
					d[-j] += d[i]
					d[i] = 0
					k += 1
					break
			else:
				break
	if su >= 0:
		break

if su < 0:
	print(-1)
else:
	print(k)



Measured memory_bytes: 85168
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

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

    int n,q; string s; 
    cin>>n>>s>>q;

    rep(i,q){
        int k; cin>>k;
        int ans=0,dcnt=0,mcnt=0,cur=0;
        rep(j,n){
            if(j>=k){
                if(s[j-k]=='D'){dcnt--; cur-=mcnt;}
                if(s[j-k]=='M'){mcnt--;}
            }
            if(s[j]=='D')dcnt++;
            if(s[j]=='M'){mcnt++; cur+=dcnt;}
            if(s[j]=='C')ans+=cur;
        }
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    int WA[N] = {0};
    bool AC[N] = {false};
    int correct = 0, wrong = 0;
    while (M--)
    {
        int p;
        string s;
        cin >> p >> s;
        if (AC[p - 1])
            continue;
        if (s == "AC")
        {
            AC[p - 1] = true;
            correct++;
            wrong += WA[p - 1];
        }
        else if (s == "WA")
        {
            WA[p - 1]++;
        }
    }

    cout << correct << ' ' << wrong << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
    int n;
    unsigned long long wa=0;
    cin >> n;

    for(int i = 1 ; i <= n; i++){
        if(i%3 != 0 && i%5 != 0){
            wa =wa+ i;
        }
    }
    cout << wa;
    return 0;
}

Measured memory_bytes: 3632
n = int(input())
a, b = map(int, input().split())
p =  list(map(int, input().split()))

x = len([i for i in p if i <= a])
y = len([i for i in p if a < i <= b])
z = len([i for i in p if b < i])

print(min(x,y,z))

Measured memory_bytes: 3064
/*---------------------------------------------
				Author:TanYz
---------------------------------------------*/
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <stack>
#include <ctime>
#include <set>
#include <vector>
#include <cstdlib>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mpii(a,b) make_pair(a,b)
const int INF=1<<30;
const int maxn=2333333;
const int mod=1000000007;

ll x;

int main()
{
	//freopen("tan_in.txt","r",stdin);
	//freopen("tan_out.txt","w",stdout);
	scanf("%lld",&x);
	ll ans=(x/11)*2;
	ll rem=x%11;
	if(0<rem && rem<=6)ans++;
	else if(rem>6)ans+=2;
	printf("%lld\n",ans);
	return 0;
}





Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		int X=sc.nextInt();
		int cnt=0;
		for(int i=0;i<=A;i++) {
			for(int j=0;j<=B;j++) {
				for(int k=0;k<=C;k++) {
					if(500*i+100*j+50*k==X)cnt++;
				}
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      count++;
    }
  }
  if (count == 0) {
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int building[4][3][10] = {0};

    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        building[b - 1][f - 1][r - 1] += v;
    }

    for(int i = 0; i < 4; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 10; k++) {
                cout << " " << building[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) cout << "####################" << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
num,a,b = map(int,input().split())

if(b-a) %2 ==0:
    print((b-a)//2)

    #間隔が奇数の時
else:
    #aと右端の差
    p=num-a
    #bと左端の差
    q=b-1
    #aと左端の差
    r=a-1
    #bと右端の差
    s=num-b
    
    #もしbとaの差が3未満のとき
    if b-a <3:
        p = min(b-1,num-a)
        print(p)
    
    else:
        z=r+1+(b-(r+1)-1)//2
        y=s+1+(num-(a+(s+1)))//2
        print(min(y,z))


Measured memory_bytes: 38384
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>() - 1;
    let mut csf = vec![(0, 0, 0); n];

    for i in 0..n {
        csf[i] = (read::<i64>(), read::<i64>(), read::<i64>());
    }

    for i in 0..n {
        let mut a = csf[i].0 + csf[i].1;
        for j in i+1..n {
            if a - csf[j].1 > 0 {
                let b = (a - csf[j].1) % csf[j].2;
                a += csf[j].0;
                if b != 0 {
                    a += csf[j].2 - b;
                }
            } else {
                a = csf[j].0 + csf[j].1;
            }
        }
        println!("{}", a);
    }
    println!("0")
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 2005
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}



int main()
{
	IOS;
	prep_fac();
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n/3;i++){
		ans=(ans+C(n-2*i-1,i-1))%md;
	}
	cout<<ans;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
const int maxn = 5e5 + 50;
typedef pair<int, int> P;

int arr[maxn];
int a, b, c, d, e, f, g;
void solve();
int main()
{
	int t = 1;
//	cin >> t;
	for(int i=0; i<t; i++)
	{
		solve();
	}
	return 0;
}

// type below

void solve()
{
	string str; cin >> str;
	if(str[2] == str[3] && str[4] == str[5]) cout << "Yes";
	else	cout << "No";
	return;	
}

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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  if(a[1] == a[2]){
    cout << a[0] << endl;
  }
  else if(a[0] == a[2]){
    cout << a[1] << endl;
  }
  else{
    cout << a[2] << endl;
  }
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new FastScanner(System.in)
  val n, k = sc.nextInt()
  val xyc = List.fill(n)((sc.nextInt(), sc.nextInt(), sc.next() == "B"))

  def compose(x1: Int, x2: Int): Int = {
    x1 * (k+1) + x2
  }

  var b = Array.fill((k+1) * (k+1))(0)
  var w = Array.fill((k+1) * (k+1))(0)

  for ((x, y, c) <- xyc) {
    val qx = x / k
    val qy = y / k
    if (c ^ ((qx + qy) % 2 == 1)) {
      b(compose(x % k + 1, y % k + 1)) += 1
    } else {
      w(compose(x % k + 1, y % k + 1)) += 1
    }
  }

  for {
    i <- 1 to k
    j <- 1 to k
  } {
    b(compose(i, j)) += b(compose(i, j-1))
    w(compose(i, j)) += w(compose(i, j-1))
  }

  for {
    j <- 1 to k
    i <- 1 to k
  } {
    b(compose(i, j)) += b(compose(i-1, j))
    w(compose(i, j)) += w(compose(i-1, j))
  }

  var ans = 0
  for {
    i <- 0 to k
    j <- 0 to k
  } {
    val bc1 = b(compose(k, k)) - b(compose(i, k)) - b(compose(k, j)) + 2 * b(compose(i, j))
    val wc1 = w(compose(i, k)) + w(compose(k, j)) - 2 * w(compose(i, j))
    ans = ans.max(bc1 + wc1)

    val bc2 = b(compose(i, k)) + b(compose(k, j)) - 2 * b(compose(i, j))
    val wc2 = w(compose(k, k)) - w(compose(i, k)) - w(compose(k, j)) + 2 * w(compose(i, j))
    ans = ans.max(bc2 + wc2)
  }
  println(ans)
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 73128
#include <iostream>
using namespace std;
int main()
{
    int n,prec,sum=0;
    cin >> n;
    int a[25],b[25],c[25];
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for (int i=1;i<=n;i++)
    {
        cin >> b[i];
    }
    for (int i=1;i<n;i++)
    {
        cin >> c[i];
    }
    prec=a[1];
    sum+=b[a[1]];
    for (int i=2;i<=n;i++)
    {
        sum+=b[a[i]];
        if (a[i]==prec+1) sum+=c[prec];
        prec=a[i];
    }
    cout << sum;
}

Measured memory_bytes: 256
import std.stdio, std.string,std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.bigint;

void main() {
  auto S = readln.chomp;

  //
  ulong func(string[] strs, int count) {
    if (count == S.length) {
      return strs.to!(ulong[]).sum;
    }
    auto res = func(strs ~ S[count].to!string, count+1);
    if (strs.length > 0) {
      strs[$-1] ~= S[count];
      return res + func(strs, count + 1);
    }
    return res;
  }

  writeln(func(null, 0));
}


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

int main(){
  map<int, int>m;
  for(int i=0; i<6; i++){
    int a;
    cin >> a;
    m[a]++;
  }
  for(int i=1; i<=4; i++){
    if(m[i]==3){
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 384