akhauriyash/Code-Regression huggingface dataset:
using System; 
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    static void Main(string[] args) {
        
        var NAB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var A = NAB[0];
        var B = NAB[1];
        var C = NAB[2];
        
        Console.WriteLine(Math.Min(B/A,C));
     }
}
     
     
                   
public class PriorityQueue<T> : IEnumerable<T> { private readonly List<T> _data = new List<T>(); private readonly IComparer<T> _comparer; private readonly bool _isDescending; public PriorityQueue(IComparer<T> comparer, bool isDescending = true) { _comparer = comparer; _isDescending = isDescending; } public PriorityQueue(Comparison<T> comparison, bool isDescending = true) : this(Comparer<T>.Create(comparison), isDescending) { } public PriorityQueue(bool isDescending = true) : this(Comparer<T>.Default, isDescending) { } public void Enqueue(T item) { _data.Add(item); var childIndex = _data.Count - 1; while (childIndex > 0) { var parentIndex = (childIndex - 1) / 2; if (Compare(_data[childIndex], _data[parentIndex]) >= 0) break; Swap(childIndex, parentIndex); childIndex = parentIndex; } } public T Dequeue() { var lastIndex = _data.Count - 1; var firstItem = _data[0]; _data[0] = _data[lastIndex]; _data.RemoveAt(lastIndex--); var parentIndex = 0; while (true) { var childIndex = parentIndex * 2 + 1; if (childIndex > lastIndex) break; var rightChild = childIndex + 1; if (rightChild <= lastIndex && Compare(_data[rightChild], _data[childIndex]) < 0) childIndex = rightChild; if (Compare(_data[parentIndex], _data[childIndex]) <= 0) break; Swap(parentIndex, childIndex); parentIndex = childIndex; } return firstItem; } public T Peek() { return _data[0]; } private void Swap(int a, int b) { var tmp = _data[a]; _data[a] = _data[b]; _data[b] = tmp; } private int Compare(T a, T b) { return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b); } public int Count => _data.Count; public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); }


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int w[n], ruikei[n];
    cin >> w[0];
    ruikei[0] = w[0];
    for (int i=1; i<n; i++) {
        cin >> w[i];
        ruikei[i] = ruikei[i-1]+w[i];
    }
    int result = ruikei[n-1];
    for (int i=0; i<n-1; i++) {
        result = min(abs(ruikei[n-1]-2*ruikei[i]), result);
    }
    cout << result << endl;
}

Measured memory_bytes: 256
s,x=gets.split;l=s.size-1;a=[*?0..?9]-gets.split
(puts s;exit)if !j=(0..l).find{|i|!a.find{|e|e==s[i]}}
k=j.downto(0).find{|i|x=a.find{|e|e>s[i]}}||-1
puts (k<0?a[0]>?0?a[0]:a[1]:s[0...k]+x)+a[0]*(l-k)

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int n;
map<string,int>S;
main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int c;string s;cin>>c>>s;
    if(c==0)
    {
      int x;cin>>x;S[s]=x;
    }
    else if(c==1)cout<<S[s]<<endl;
    else S[s]=0;
  }
}



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

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

string s = "RGBY";

int main(){

  int h, w, d;
  cin >> h >> w >> d;

  rep(i, h){
    rep(j, w) cout << s[2 * (((i+j) / d) % 2) + ((i-j + d*1000)/ d) % 2];
    cout << endl;
  }

  return 0;
}


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

/*
a+b<L
a and b=0
*/

string l;
ll mod=1e9+7,n,ans=0,tmp=1;

ll modpow(__int128_t a, ll n,ll mo) {
	__int128_t r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void init(){
	cin>>l;
}

int main(void){
	init();
	n=l.size();
	rep(i,n){
		if(l[i]=='1'){
			//先頭が0
			ans+=(modpow(3,n-i-1,mod)*tmp)%mod;
			ans%=mod;
			tmp*=2;
			tmp%=mod;
		}else{
			//特に何もしない。
		}
	}
	ans=(ans+tmp)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int k = scanner.nextInt();

        int sum = 0;

        if(a <= k){
            sum += a;
            k = k - a;
            if(k == 0){
                System.out.println(sum);
                return;
            }
        }else{
            sum += k;
            System.out.println(sum);
            return;
        }

        if(b <= k){
            k = k - b;
            if(k == 0){
                System.out.println(sum);
                return;
            }
        }else{
            System.out.println(sum);
            return;
        }

        sum -= k;
        System.out.println(sum);

    }
}


Measured memory_bytes: 35656
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int a,b;  cin >> a >> b;
  if(a <= b*2){
    cout << 0;
  }else{
    cout << a - b*2;
  }
}

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

constexpr long mod = 1000000007;
int N;
char bd[2][60];
long total = 1;

int main() {
    scanf("%d", &N);
    scanf("%s%s", bd[0], bd[1]);
    int prev = -1;
    for (int i = 0; i != N; ++i) {
        if (bd[0][i] == bd[1][i]) {
            switch (prev) {
                case -1:
                    total = 3;
                    break;
                case 0:
                    (total <<= 1) %= mod;
                    break;
            }
            prev = 0;
        } else {
            switch (prev) {
                case -1: total = 6; break;
                case 0: (total <<= 1) %= mod; break;
                case 1: (total *= 3) %= mod; break;
            }
            prev = 1;
            ++i;
        }
    }
    printf("%ld\n", total);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"reflect"
	"strings"
)

func echo(n int, s string) bool {
	if n == 1 {
		return false
	}
	sa := strings.Split(s, "")

	if reflect.DeepEqual(sa[:n/2], sa[n/2:]) {
		return true
	}

	return false
}

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	if echo(n, s) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
	int n,m,ma,mi;
	cin>>n;
	rep(i,n){
		ma=0;mi=0;		
		cin>>m;
		vector<int> a(m);
		rep(j,m){
			cin>> a[j];
		}
		rep(j,m-1){
			if(ma<a[j]-a[j+1])ma=a[j]-a[j+1];
			if(mi<a[j+1]-a[j])mi=a[j+1]-a[j];
		}
		cout << mi << " " << ma << endl;
	}
}

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


int main(){
    int n,A[110],v,j;
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
            for(int k=0;k<n;k++){
            if(k==n-1)cout<<A[k]<<endl;
            else cout<<A[k]<<" ";
            
        }
    for(int i=1;i<n;i++){
        v=A[i];
        j=i-1;
        while(j>=0&&A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(int k=0;k<n;k++){
            if(k==n-1)cout<<A[k]<<endl;
            else cout<<A[k]<<" ";
            
        }
    }

    return 0;
}






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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    ll ans = 0;
    for(ll i = 1; i < N;i++)
    {
        ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())

iki=[]
kae=[]

c=0
flag=-1

for i in range(m):
    a,b = map(int,input().split())
    if a==1:
        iki.append(b)
    elif b==n:
        iki.append(a)

l=len(iki)
iki2=set(iki)
l2=len(iki2)

#print(iki)
                
if l>l2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
    
                

Measured memory_bytes: 23292
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll>a;
    for(ll i=0;i<n;i++)
    {
        ll x;
        cin>>x;
        a.push_back(x);
    }
    ll res=0;
    for(ll i=0;i<n;i++)
    {
        while(i+1<n&&a[i+1]==a[i])
            i++;
        if(a[i+1]>a[i])
        {
            while(i+1<n&&a[i+1]>=a[i])
                i++;
        }
        else
        {
            while(i+1<n&&a[i+1]<=a[i])
                i++;
        }
        res++;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4264
char s[51],t[26],u[26];b;j;main(i){for(gets(s);gets(s);b++){for(i=0;s[i];)t[s[i++]-97]++;for(i=0;i<26;t[i]=0,++i)u[i]=b?fmin(u[i],t[i]):t[i];}for(;j<26;)u[j]--?putchar(97+j):j++;puts("");}

Measured memory_bytes: 128
input()
A=[0]+input().split()
H=len(A)
for i in range(1,H):
 print(f'node {i}: key = {A[i]}, {f"parent key = {A[i//2]}, "if i//2>0 else""}{f"left key = {A[2*i]}, "if 2*i<H else""}{f"right key = {A[2*i+1]}, "if 2*i+1<H else""}')


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

bool is_prime (ll n) {
    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<ll> divisor (ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) res.push_back(n / i);
        }
    }
    return res;
}

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    ll a, b;
    cin >> a >> b;
    vector<ll> v = divisor(a), t = divisor(b), k;
    sort(ALL(v));
    sort(ALL(t));
    for(auto i : v){
        if(binary_search(ALL(t),i))
            k.push_back(i);
    }

    ll ans = 0;
    for (auto i : k)
    {
        if (is_prime(i) || i == 1)
            ans++;
    }
    cout << ans << endl;
}

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

int main()
{
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    if(a+b > c+d){
        cout << "Left" << endl;
    }
    else if(a+b == c+d){
        cout << "Balanced" << endl;
    }
    else cout << "Right" << endl;
    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
cards = [num for num in range(2, 14)]
cards.append(1)

for i in reversed(cards):
    if i == A and i == B:
        print("Draw")
    elif i == A and i != B:
        print("Alice")
        break
    elif i == B and i != A:
        print("Bob")
        break

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
    ll N;
    cin>>N;
    vector<ll> a(3*N);
    REP(i,3*N)cin>>a[i];

    ll res = 0;
    sort(a.begin(),a.end(),greater<ll>());
    REP(i,N)res+=a[i*2+1];
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(){
int a,b,c,i;
while(1){
scanf("%d %d\n",&a,&b);
if(a==0 && b==0){
break;
}
else{
if(a<b){
c=a;
a=b;
b=c;
}
for(i=0;b!=0;i++){
a=a%b;
c=a;
a=b;
b=c;
}
printf("%d %d\n",a,i);
}
}
return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
//========================
#define gc getchar_unlocked
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long int
#define ull unsigned long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x), greater<int>())
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ss second
#define setbits(x) _builtin_popcount(x)
#define parity(x) _builtin_parity(x)
#define leadzero(x) __builtin_clz(x)
#define trailzero(x) __builtin_ctz(x)
#define endl "\n"
#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define CHRONO srand(chrono::high_resolution_clock::now().time_since_epoch().count())

// =======================
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef map<int, int> mii;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
    uniform_int_distribution<int> uid(0, lim - 1);
    return uid(rang);
}
int mpow(int base, int exp);
void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
// =======================
int n;
void input()
{
    cin >> n;
}
void solve()
{
    ll ans = 0;
    for (int a = 1; a <= n - 1; a++)
    {
        ans += (n-1)/a;
    }
    cout << ans;
}

int main()
{
    FAST;
    CHRONO;
    int t = 1;
    //cin >> t;
    while (t--)
    {
        input();
        solve();
    }
    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}


Measured memory_bytes: 3536
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int p[100],s[100],i=0,swap,j,k,l,rank[100],r=1;
    int q;
    
    while(1){
        scanf("%d,%d",&p[i],&s[i]);
        if(p[i]==0&&s[i]==0)
            break;
        i++;
    }
    for(j=0;j<i;j++){
        for(k=j+1;k<i;k++){
            if(s[j]<s[k]){
                swap=s[j];
                s[j]=s[k];
                s[k]=swap;
                swap=p[j];
                p[j]=p[k];
                p[k]=swap;
            }
        }
    }
    rank[0]=r;
    for(l=1;l<i;l++){
        if(s[l]<s[l-1])
            r++;
        rank[l]=r;
    }
    /*
    for(l=0;l<i;l++){
        printf("%d %d %d\n",p[l],s[l],rank[l]);
    }
    */
    while(scanf("%d",&q)!=EOF){
        for(l=0;l<i;l++){
            if(p[l]==q)
        printf("%d\n",rank[l]);
        }
    }
    
    return 0;
}

Measured memory_bytes: 1760
N = int(input())
L = list(map(int, input().split()))
count = 0
count2 = 0
for i in range(0, N):
  if L[i]%2==0:
    count = count + 1
    if L[i]%3==0 or L[i]%5==0:
      count2 = count2 + 1

if count == count2:
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 3060
n,t=map(int,input().split())
ar=list(map(int,input().split()))
mn=float('inf')
mdif,mxc=-float('inf'),0
for e in ar:
    if(e-mn>mdif):
        mdif=e-mn
        mxc=1
    elif(e-mn==mdif):
        mxc+=1
    mn=min(mn,e)
print(mxc)


Measured memory_bytes: 20384
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>
#include<queue>

int main()
{
	int n, d, x, a;
	scanf("%d%d%d", &n, &d, &x);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a);
		x += (d - 1) / a + 1;
	}
	printf("%d\n", x);

	return 0;
}

Measured memory_bytes: 256
x,k,d=map(int, input().split())
x=abs(x)

if x+d >=k*d:
    print(abs(x-k*d))
    exit()

if k%2==1:
    x=x-d

kaisu=int(x/(2*d))
ans=abs(x-kaisu*d*2)
if ans >=d:
    ans=2*d-ans

print(ans)

Measured memory_bytes: 61696
def count_dict(mystring):
    d = {}
# count occurances of character
    for w in mystring: 
        d[w] = mystring.count(w)
    return d
    
w = str(input())

values = count_dict(w).values()

valmod2 = [int(i%2) for i in values]

if all(val ==0 for val in valmod2):
    print('Yes')
    
else:
    print('No')

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int A,B; cin >> A >> B;
    cout << A*B << ln;
}

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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/

int main(){
    int H,N;
    cin>>H>>N;
    vector<int> A(N);
    vector<int> B(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i)>>B.at(i);
    }
    vector<int> dp(H+1,2000000000);
    dp.at(0)=0;
    for(int i=1;i<H+1;i++){
        for(int j=0;j<N;j++){
            dp.at(i)=min(dp.at(i),dp.at(max(i-A.at(j),0))+B.at(j));
        }
    }
    cout<<dp.at(H)<<endl;
}

Measured memory_bytes: 256
main(){
  int a[100][100],h,i,j,w,x,y;
  char s[128][128];
  for(;;){
    scanf("%d %d",&h,&w);
    if(w==0&&h==0)
      break;
    x=0;
    y=0;
    for(i=0;i<h;i++)
      for(j=0;j<w;j++)
	a[j][i]=0;
    for(i=0;i<h;i++)
      scanf(" %s",s[i]);
    for(;;)
      if(a[x][y]++){
	puts("LOOP");
	break;
      }else
	if(s[y][x]=='>')
	  x++;
	else if(s[y][x]=='<')
	  x--;
	else if(s[y][x]=='^')
	  y--;
	else if(s[y][x]=='v')
	  y++;
	else{
	  printf("%d %d\n",x,y);
	  break;
	}
  }
  return 0;
}

Measured memory_bytes: 0
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#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 mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
int N;
int datas[1145141]={0};
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
vector<ll> A,B;
ll dp1[5050]={0};
ll dp2[25000005]={0};
ll ga,sa,ba,gb,sb,bb;
int main(){
	cin>>N;
	cin>>ga>>sa>>ba;
	cin>>gb>>sb>>bb;
	rep(i,N+1){
		dp1[i]=i;
		if(i>=ga){
			dp1[i]=max(dp1[i-ga]+gb,dp1[i]);
		}
		if(i>=sa){
			dp1[i]=max(dp1[i-sa]+sb,dp1[i]);
		}
		if(i>=ba){
			dp1[i]=max(dp1[i-ba]+bb,dp1[i]);
		}
	}
	rep(i,N*5000+1){
		dp2[i]=i;
		if(i>=gb){
			dp2[i]=max(dp2[i-gb]+ga,dp2[i]);
		}
		if(i>=sb){
			dp2[i]=max(dp2[i-sb]+sa,dp2[i]);
		}
		if(i>=bb){
			dp2[i]=max(dp2[i-bb]+ba,dp2[i]);
		}
	}
	int hoge=dp1[N];
	cout<<dp2[hoge]<<endl;

}





Measured memory_bytes: 196864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<class U, class V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

class MaxMinQueue {
    public:
        queue<int> Q;
        deque<int> maxQ, minQ;
    
        void push(int element) {
            Q.push(element);
            while(!maxQ.empty() && maxQ.back() < element) maxQ.pop_back();
            maxQ.push_back(element);
            while(!minQ.empty() && minQ.back() > element) minQ.pop_back();
            minQ.push_back(element);
        }
        void pop() {
            int element = Q.front(); Q.pop();
            if(maxQ.front() == element) maxQ.pop_front();
            if(minQ.front() == element) minQ.pop_front();
        }
        int getMax() {
            return maxQ.front();
        }
        int getMin() {
            return minQ.front();
        }
        int front() {
            return Q.front();
        }
};

int main() {
    FAST_IO();
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    // int ans = N - K + 1;
    // MIN(i) : minimum value in A[i...i+K-1]
    // MAX(i) : maximum value in A[i...i+K-1]
    MaxMinQueue maxMinQueue;
    vector<int> MIN(N - K + 1), MAX(N - K + 1);
    rep(i, N) {
        if(i <= K - 1) {
            maxMinQueue.push(A[i]);   
        }
        else {
            maxMinQueue.push(A[i]);
            maxMinQueue.pop();
        }
        if(i >= K - 1) {
            MIN[i - K + 1] = maxMinQueue.getMin();
            MAX[i - K + 1] = maxMinQueue.getMax();
        }
    }
    vector<bool> increasing(N - K + 1);
    int inc = 1;
    for(int i = 1; i < N; ++i) {
        if(A[i - 1] < A[i]) {
            ++inc;
            if(inc >= K) increasing[i - K + 1] = true;
        } else {
            inc = 1;
        }
    }
    int ans = N - K + 1;
    vector<bool> duplicated(N - K + 1);
    for(int i = 1; i <= N - K; ++i) {
        if(MIN[i - 1] == A[i - 1] && MAX[i] == A[i + K - 1]) {
            duplicated[i] = true;
            --ans;
        }
    }
    int cnt = 0;
    for(int i = 0; i <= N - K; ++i) {
        if(duplicated[i] == false && increasing[i] == true) ++cnt;
    }
    if(cnt == 0) cout << ans << "\n";
    else cout << ans - cnt + 1 << "\n";
}


Measured memory_bytes: 2688
S = input()
zenzitsu = False

ans = 0
for i in range(len(S)):
    if S[i] == "R":
        if zenzitsu:
            ans += 1
            zenzitsu = True
        else:
            ans = 1
            zenzitsu = True
    else:
        zenzitsu = False
print(ans)

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;  cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << '\n';

    return 0;
}


Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

constexpr int64_t MOD = 2019;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int l,r;
	cin >> l >> r;
	if(r / MOD - l / MOD > 0) cout << 0 << '\n';
	else{
		int minv = INF;
		for(int i = l;i < r;++i){
			for(int j = i+1;j <= r;++j){
				minv = min(minv,i * j % MOD);
			}
		}
		cout << minv << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;
using ull = unsigned long long;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n; cin >> n;
	ll sum = 0, mi = TEN(10);
	REP(i, n) {
		ll x; cin >> x;
		sum += x;
		if (x % 10) mi = min(mi, x);
	}
	if (sum % 10) {
		cout << sum << endl;
	} else {
		if (mi == TEN(10)) {
			cout << 0 << endl;
		} else {
			cout << sum - mi << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
n,K=map(int,input().split())
lists=list(map(int,input().split()))
mod=10**9+7
dp=[[["inf" for i in range(256)] for j in range(n+1)] for k in range(n+1)]
#dp[i][j][k]=カードのi番目までからjこまでを取ってxorの値をkにする方法
#dp[i][j]=="inf" (i<jの時)
for i in range(n+1):
    dp[i][0][0]=1
for i in range(1,n+1):
    num=lists[i-1]
    for j in range(1,i+1):
        for k in range(256):
            if dp[i-1][j-1][k^num]!="inf" or dp[i-1][j][k]!="inf": 
                s=0
                if dp[i-1][j][k]!="inf":
                    s+=dp[i-1][j][k]
                if dp[i-1][j-1][k^num]!="inf":
                    s+=dp[i-1][j-1][k^num]
                dp[i][j][k]=s%mod
            else:
                pass
ans=0
def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
A=find_power(100,mod)

for i in range(n+1):
    if dp[n][i][K]!="inf":
        ans+=dp[n][i][K]*A[i]
        ans=ans%mod
print(ans)

Measured memory_bytes: 98268
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll a[100005], b[100005], c[100005];
int main(void) {
    int n;
    cin >> 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, a + n);
    sort(b, b + n);
    sort(c, c + n);
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        ll x = lower_bound(a, a + n, b[i]) - a;
        ll y = c+n - upper_bound(c, c + n, b[i]);
        ans += x * y;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 5944
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <sstream>

#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long
#define bl bool
#define nn printf("\n");
#define mod 1000000007

using namespace std;

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

	int n = 0;
	while (cin >> n)
	{
		int a = 0, b = 0, c = 0, d = 0;
		int num = 0;

		rep(i, 10)
		{
			rep(j, 10)
			{
				rep(k, 10)
				{
					rep(l, 10)
					{
						if(i + j + k + l == n)
						{
							num += 1;
						}
					}
				}
			}
		}
		printf("%d\n", num);
	}

	return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>
#include<string.h>
int n,m,i,j,k;
int num,id,cnt;

char A[10];
char B[10];
char tmp;

int flg[1001];

int main(){
  while(1){
    scanf("%d %d",&m,&n);
    if(m==0&&n==0)break;
    
    for(i=1;i<=m;i++)flg[i]=0;
    id=1;
    cnt=m;
    
    for(i=1;i<=n;i++){

      if(i%15==0){
        strcpy(A,"FizzBuzz");
      }else if(i%5==0){
        strcpy(A,"Buzz");
      }else if(i%3==0){
        strcpy(A,"Fizz");
      }else{
        
        sprintf(A,"%d",i);
        
        /*
          j=0;
          while(num>0){
          A[j]=num%10+'0';
          j++;
          num/=10;
          }
          for(k=0;k<j/2;k++){
          tmp=A[k];
          A[k]=A[j-1-k];
          A[j-1-k]=tmp;
          }
          A[j]='\0';
        */
        
      }
      
      scanf("%s",B);
      
      if(cnt==1)continue;

      if(strcmp(A,B)!=0){
        flg[id]=1;
        cnt--;
      }
      
      while(1){
        id++;
        if(id==m+1)id=1;
        if(flg[id]==0)break;
      }
      
    }
    
    j=0;
    for(i=1;i<=m;i++){
      if(flg[i]==0){
        if(j!=0)printf(" ");
        j=1;
        printf("%d",i);
      }
    }
    printf("\n");
    
  }
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <stdlib.h>
int main (){
int a,b,c,d,e,f;
 scanf ("%d%d%d",&a,&b,&c);
d=abs(b-a)+abs(c-b);
e=abs(a-b)+abs(c-a);
f=abs(b-c)+abs(c-a);
if (d>e || d>f){
  if (e>f){
printf ("%d",f);
  }
  else{
  printf ("%d",e);
  }
}
  else{
  printf ("%d",d);
  }
return 0;
}

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

int main(){
	ll T[2], A[2], B[2];
	cin >> T[0] >> T[1] >> A[0] >> A[1] >> B[0] >> B[1];
	if(T[0]*A[0]+T[1]*A[1] == T[0]*B[0]+T[1]*B[1]){
		cout << "infinity" << endl;
		return 0;
	}else if(T[0]*A[0]+T[1]*A[1] < T[0]*B[0]+T[1]*B[1]){
		ll d =  T[0]*B[0]+T[1]*B[1] - T[0]*A[0]-T[1]*A[1];
		if(A[0] < B[0]) cout << 0 << endl;
		else{
			if(A[0] == B[0]) cout << 1 << endl;
			else{
				ll ans = 2*((T[0]*A[0] - T[0]*B[0])/d + 1) - 1;
				if((T[0]*A[0] - T[0]*B[0]) % d == 0) ans--;
				cout << ans << endl;
			}
		}
	}else{
		ll d =  T[0]*A[0]+T[1]*A[1] - T[0]*B[0]-T[1]*B[1];
		if(A[0] > B[0]) cout << 0 << endl;
		else{
			if(A[0] == B[0]) cout << 1 << endl;
			else{
				ll ans = 2*((T[0]*B[0] - T[0]*A[0])/d + 1) - 1;
				if((T[0]*B[0] - T[0]*A[0])%d == 0) ans--;
				cout << ans << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)

using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> A(n);
    vector<int> ans(n);
    FOR (i, 0, n) {
        scanf("%d\n", &A[i]);
    }
    int cur_max = 0;
    int cur_max_next = 0;
    for (int a : A) {
        if (a>=cur_max) {
            cur_max_next = cur_max;
            cur_max = a;
        } else if (a>cur_max_next) {
            cur_max_next = a;
        }
    }
    FOR (i, 0, n) {
        if (A[i]==cur_max) {
            ans[i] = cur_max_next;
        }else{
            ans[i] = cur_max;
        }
        printf("%d\n", ans[i]);
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<string>S(N);
    vector<int>P(N),a(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i)>>P.at(i);
        a.at(i)=i+1;
    }
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            if(S.at(i)>S.at(j)){
                swap(S.at(i),S.at(j));
                swap(a.at(i),a.at(j));
                swap(P.at(i),P.at(j));
            }else if(S.at(i)==S.at(j)&&P.at(i)<P.at(j)){
                swap(S.at(i),S.at(j));
                swap(a.at(i),a.at(j));
                swap(P.at(i),P.at(j));
            }
        }
    }
    for(int i=0;i<N;i++){
        cout<<a.at(i)<<endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int inputNum = Integer.parseInt(br.readLine());

		System.out.println(inputNum * inputNum * inputNum);


	}

}

Measured memory_bytes: 17000
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
  int f[N2];
  int space;
  string path;

  bool operator < (const Puzzle &p) const{
    for(int i = 0;i<N2;i++){
      if(f[i] == p.f[i])continue;
      return f[i] > p.f[i];
    }
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p){
  for(int  i = 0; i < N2; i++)
    if(p.f[i] != (i+1))return false;
    return true;
}

string bfs(Puzzle s){
  queue<Puzzle> Q;
  map<Puzzle, bool> V;
  Puzzle u,v;
  s.path  = "";
  Q.push(s);
  V[s] = true;

  while (!Q.empty()){
    u = Q.front();
    Q.pop();
    if(isTarget(u))return u.path;
    int sx = u.space/N;
    int sy = u.space%N;
    for(int r = 0; r <4;r++){
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if(tx < 0||ty<0||tx>=N||ty >= N)continue;
      v =u;
      swap(v.f[u.space],v.f[tx * N +ty]);
      v.space = tx * N + ty;
      if(!V[v]){
        V[v] = true;
        v.path += dir[r];
        Q.push(v);
      }
    }
  }
  return "unsolvable";
}

int main(){
  Puzzle in;

  for(int i =0;i<N2;i++){
    cin >> in.f[i];
    if(in.f[i] == 0){
      in.f[i] = N2;
      in.space = i;
    }
  }

  string ans = bfs(in);
  cout << ans.size() << endl;

  return 0;
}



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

int main() {

    int n,d,x;

    cin >> n >> d >> x;

    int ans = x;

    for(int i=0; i<n; i++){

        int a;
        cin >> a;

        for(int j=1; j<=d; j+=a){
            ans += 1;
        }

    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def p_e():
    N, W = map(int, input().split())
    max_value = 10 ** 3 * N + 1
    dp = [W + 1] * max_value
    dp[0] = 0
    for _ in range(1, N + 1):
        w, v = map(int, input().split())
        NEXT = [W + 1] * max_value
        NEXT[0] = 0
        for i in range(1, max_value):
            if i - v >= 0:
                NEXT[i] = min(dp[i - v] + w, dp[i])
            else:
                NEXT[i] = dp[i]
        dp = NEXT

    ans = 0
    for i, w in enumerate(dp):
        if w <= W:
            ans = i
    print(ans)


if __name__ == '__main__':
    p_e()


Measured memory_bytes: 115904
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {
    int f[N2], space, MD;
};

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz) {
    int sum = 0;
    for (int i = 0; i < N2; i++) {
        if (pz.f[i] == N2) continue;
        sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}

bool isSolved() {
    for (int i = 0; i < N2; i++) if (state.f[i] != i + 1) return false;
    return true;
}

bool dfs(int depth, int prev) {
    if ( state.MD == 0) return true;
    if (depth + state.MD > limit) return false;
    
    int sx = state.space / N;
    int sy = state.space % N;
    Puzzle tmp;
    
    for (int r = 0; r < 4; r++) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
        if (max(prev, r)-min(prev, r) == 2 ) continue;
        tmp = state;
        state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
        state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
        swap(state.f[tx * N + ty], state.f[sx * N + sy]);
        state.space = tx * N + ty;
        if (dfs(depth + 1, r)) {
            path[depth] = r;
            return true;
        }
        state = tmp;
    }
    
    return false;
}

string iterative_deepening(Puzzle in) {
    in.MD = getAllMD(in);
    
    for (limit = in.MD; limit <= LIMIT; limit++ ) {
        state = in;
        if (dfs(0, -100)) {
            string ans ="";
            for (int i = 0; i < limit; i++) ans += dir[path[i]]; 
            return ans;
        }
    }
    
    return "unsolvable";
}

int main() {
    for (int i = 0; i < N2; i++) 
      for(int j = 0; j < N2; j++)
        MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
        Puzzle in;
        
        for(int i = 0; i < N2; i++) {
            cin >> in.f[i];
            if (in.f[i] == 0) {
                in.f[i] = N2;
                in.space = i;
            }
        }
        string ans = iterative_deepening(in);
        cout << ans.size() << endl;
        
        return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <ll>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(ll i=0;i<n;i++)
#define pb      push_back
const ll mod=1e9+7;
void fast();
int main()
{
    fast();
    int n,m;
    cin>>n>>m;
    vii v(n);
    loop(n){
        cin>>v[i].second>>v[i].first,v[i].second*=-1;
    }
    sort(v.rbegin(),v.rend());
    set<int>s;
    int cnt=0;
    ll res=0;
    int a[m+1]={};
    for(int i=1;i<=m;i++)
        s.insert(i);
    for(int i=0;i<n;i++){
        auto it=s.lower_bound(v[i].second*-1);
        if(v[i].second*-1<=m&&cnt<m&&it!=s.end())
            res+=v[i].first,cnt++,s.erase(it);
    }
    cout<<res;
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*
3 3
2 500
2 200
3 201

4 4
2 500
2 100
2 300
4 200
*/


Measured memory_bytes: 6144
#include <bits/stdc++.h>
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 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
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;
}

bool f(ll x){
    ll keta = 0;
    while(x){
        keta ++;
        x /= 10;
    }
    return keta%2 == 1;
}


int main(){
    ll n;
    cin>>n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++){
        if(f(i))ans++;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
H,W = map(int,input().split())
DP_1 = ["."*(W+1)]
for _ in range(H):
    A = "."+input()
    DP_1.append(A)
dp = [[0 for j in range(W+1)] for i in range(H+1)]
dp[0][1]=1
for i in range(1,H+1):
    for j in range(1,W+1):
        if DP_1[i][j]=="#":
            dp[i][j]=0
        else:
            dp[i][j] = dp[i][j-1] + dp[i-1][j]

print(dp[H][W]%(10**9+7))

Measured memory_bytes: 158444
#include<bits/stdc++.h> 
#define rep(i,l,r) for (ll i=l;i<=r;i++)
#define per(i,l,r) for (ll i=l;i>=r;i--)
using namespace std;
typedef long long ll;
const ll mm=998244353;
const int N=300000;
ll fac[N+10],inv[N+10],ans,a,b,k,n;
ll Pow(ll x,ll y){
	ll ans=1;
	while (y){
		if (y&1) ans=ans*x%mm;
		x=x*x%mm;
		y/=2;
	}
	return ans;
}
ll C(ll n,ll m){
	if (n<m) return 0;
	return fac[n]*inv[m]%mm*inv[n-m]%mm;
}
int main(){
	fac[0]=1;
	rep(i,1,N) fac[i]=fac[i-1]*i%mm;
	inv[N]=Pow(fac[N],mm-2);
	per(i,N,1) inv[i-1]=inv[i]*i%mm;
	scanf("%lld",&n);
	scanf("%lld%lld%lld",&a,&b,&k);
	rep(y,0,n){
		ll res=b*y;
		if (k-res>=0&&(k-res)%a==0) {
			ll x=(k-res)/a;
			(ans+=C(n,x)*C(n,y)%mm)%=mm;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(){
  int a, b, c, d, e, k;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);
  scanf("%d", &k);

  if(e - a <= k) printf("Yay!\n");
  else printf(":(\n");

  return 0;
}


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

int main() {
	int n, m, k, x, sum = 0;
	cin >> n >> k;
	m = k / 2;
	for(int i = 0; i < n; i++) {
		cin >> x;
		if(x <= m) {
			sum += 2 * x;
		}
		else {
			sum += 2 * (k - x);
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
for ($i = 0; $i < $m; $i++) {
	fscanf(STDIN, "%d %d %d", $x, $y, $z);
	$e[$x][$y] = $e[$y][$x] = 1;
}
$x = 0;
for ($i = 1; $i <= $n; $i++) {
	if (isset($f[$i]) || !isset($e[$i])) continue;
	$f[$i] = 1;
	$t = [$i];
	while ($t) {
		$j = array_pop($t);
		foreach ($e[$j] as $k => $v) {
			if (!isset($f[$k])) {
				$f[$k] = 1;
				$t[] = $k;
			}
		}
	}
	$x++;
}
echo $x + $n - count($f);

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

long FizzBuzz(int N){
    long sum=0;
    for(int i=1;i<=N;i++){
        if(i%15==0){
            continue;
        }
        else if(i%3==0){
            continue;
        }
        else if(i%5==0){
            continue;
        }
        else{
            sum+=i;
        }
    }
    return sum;
}

int main(){
     int N; cin >> N;
    cout << FizzBuzz(N) << endl;
    return 0;
}

Measured memory_bytes: 3568
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let a=sin()
  if(a == "Sunny") {
    out("Cloudy");
  }else if(a == "Cloudy") {
    out("Rainy");
  }else if(a == "Rainy") {
    out("Sunny");
  }
}
main()

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

int main(){
    int X;
    cin>>X;
    int N=X/100;
    bool flag=false;
    rep(i,N+1){
        int rest=X-i*100;
        if(rest>=0&&rest<=5*i){
            flag=true;
            break;
        }
    }
    if(flag==true){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }
    
    
    }
    
    
  
 
 




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

int main() {
    int n, d, x; cin >> n >> d >> x;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    int sum = 0;
    for (int i = 0; i < n; i++) {
        //sum += d + a[i] * (d-1);
        sum += (d-1) / a[i] + 1;
    }
    cout << sum + x << endl;

    return 0;
    
}

Measured memory_bytes: 256