akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define   MAX 100
#define   INFTY 5000000
#define   WHITE 0
#define   GRAY 1
#define   BLACK 2

int n, M[MAX][MAX];

void dijkstra()
{
   int minv;
   int d[MAX], color[MAX];
   int i, v;

   for (i=0; i<n; i++){
      d[i] = INFTY;
      color[i] = WHITE;
   }

   d[0] = 0;
   color[0] = GRAY;

   while (1){
      minv = INFTY;
      int u = -1;
      for (i=0; i<n; i++){
         if (minv>d[i] && color[i]!=BLACK){
            u = i;
            minv = d[i];
         }
      }
      if (u==-1)
         break;
      color[u] = BLACK;
      for (v=0; v<n; v++){
         if (color[v]!=BLACK && M[u][v]!=INFTY){
            if (d[v] > d[u]+M[u][v]){
               d[v] = d[u] + M[u][v];
               color[v] = GRAY;
            }
         }
      }
   }

   for (i=0; i<n; i++)
      printf("%d %d\n", i, d[i] == INFTY ? -1 : d[i]);
}

int main()
{
   int i, j;
   int k, c, u, v;

   scanf("%d", &n);
   for (i=0; i<n; i++){
      for (j=0; j<n; j++)
         M[i][j] = INFTY;
   }

   for (i=0; i<n; i++){
      scanf("%d %d", &u, &k);
      for (j=0; j<k; j++){
         scanf("%d %d", &v, &c);
         M[u][v] = c;
      }
   }

   dijkstra();

   return 0;
}

Measured memory_bytes: 1804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi  3.14159265358979323846
#define mod 1000000007
#define pf push_front
#define pb push_back
#define flush fflush(stdout);
#define null NULL
#define test cout<<"#";
 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(null);
    ll n, x, y;
    cin>>n>>x>>y;
    ll d = abs(x-y)-1;
    vector<ll> v(n, 0);
    for(ll a = 0; a < n-1; a++)
    {
        for(ll b = a+1; b < n; b++)
        {
            
            if((a+1)<=x && y<=(b+1))
            {
                v[(b-a)-d]++;
                //cout<<a<<" "<<b<<" "<<(b-a)-d<<"\n";
            }
            else
            {
                ll d = b-a;
                ll e = abs((x-1-a))+abs(y-1-b);
                
                v[min(d,e+1)]++;
                //cout<<a<<" "<<b<<" "<<(b-a)<<"\n";
            }
                
            
        }
    }
    for(ll a = 1; a < n; a++)
    {
        cout<<v[a]<<"\n";
    }
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
auto kak(vector<vector<llint>>ina,vector<vector<llint>>inb){
	int h,i,j,n=ina.size();
	vector<vector<llint>> ret(n,vector<llint>(n));
	for(h=0;h<n;h++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				ret[h][j]+=ina[h][i]*inb[i][j];
				ret[h][j]%=mod;
			}
		}
	}
	return ret;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	llint h,i,j,f,n,K,Q=0;cin>>n>>K;
	vector<vector<llint>>bgen(n,vector<llint>(n));
	for(i=0;i<n;i++){for(j=0;j<n;j++){cin>>bgen[i][j];}}
	vector<vector<llint>>ans(n,vector<llint>(n));
	for(i=0;i<n;i++){ans[i][i]=1;}
	for(h=0;h<60;h++){
		if(K&(1LL<<h)){ans=kak(ans,bgen);}
		bgen=kak(bgen,bgen);
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			Q+=ans[i][j];Q%=mod;
		}
	}
	cout<<Q<<endl;
	return 0;
}


Measured memory_bytes: 384
import itertools

MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]


def main():
    count_1 = [0] * 61
    for i in range(60):
        tmp = 0
        for j, a in enumerate(A):
            tmp += (a >> i) & 1
        count_1[i] += tmp
    ans = 0
    for i, c1 in enumerate(count_1):
        c0 = len(A) - c1
        ans += c0 * c1 * 2**i
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 122936
#include<iostream>
#include<algorithm>
#define mod 100000
using namespace std;
int main(){

        int w,h;
        while(cin>>w>>h,w||h){
            int dp[101][101][2][2]={{{{0}}}},sum=0;
            dp[0][0][0][1]=dp[0][0][1][1]=1;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    for(int k=0;k<2;k++)for(int l=0;l<2;l++)dp[i][j][k][l]%=mod;

                    dp[i+1][j][0][0]+=dp[i][j][0][1];
                    dp[i][j+1][1][0]+=dp[i][j][1][1];

                    dp[i+1][j][0][0]+=dp[i][j][0][0];
                    dp[i][j+1][1][0]+=dp[i][j][1][0];

                    dp[i+1][j][0][1]+=dp[i][j][1][0];
                    dp[i][j+1][1][1]+=dp[i][j][0][0];
                }
            }
            for(int i=0;i<2;i++)
                for(int j=0;j<2;j++)
                    sum+=dp[h-1][w-1][i][j];

            sum%=mod;
            cout<<sum<<endl;
        }
}

Measured memory_bytes: 1324
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <vector>
#define MAX_N 200000
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int
main(void)
{
  int N, M;
  cin >> N >> M;
  vector<int> edge[MAX_N + 1];
  rep(i, M)
  {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  queue<int> que;
  for (auto iter = edge[1].begin(); iter != edge[1].end(); ++iter) {
    que.push(*iter);
  }
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (auto iter = edge[v].begin(); iter != edge[v].end(); ++iter) {
      if (*iter == N) {
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 12400
import sys
input = sys.stdin.readline

# C - Peaks
def get_index(s):
	return int(s) - 1
	

n, m = map(int, input().split())
h = list(map(int, input().split()))
rivals = [0] * n

for i in range(m):
	a, b = map(get_index, input().split())
	
	rivals[a] = max(rivals[a], h[b])
	rivals[b] = max(rivals[b], h[a])

ans = 0

for i in range(n):
	if h[i] > rivals[i]:
		ans += 1

print(ans)

Measured memory_bytes: 20180
import math
a,b,h,m=map(int,input().split())
c=min(abs(h/12+m/(60*12)-m/60)*2*math.pi,(1-abs(h/12+m/(60*12)-m/60))*2*math.pi)
ans=(a**2+b**2-2*a*b*math.cos(c))**0.5
print(ans)

Measured memory_bytes: 9436
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String line = br.readLine();
		char a = line.charAt(0);
		char b = line.charAt(1);
		char c = line.charAt(2);
		char d = line.charAt(3);
		String t = "No";

		if ((a==b&&b==c)|(b==c&&c==d)) {
		t="Yes";
		}
		System.out.println(t);
	}
}

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

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

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

int main(){
  int n,k;
  cin >> n >> k;
  vector<double> p;

  REP(i,n){
    double t;
    cin >> t;
    p.push_back((t+1)/2);
  }

  double ans=0;
  double tmp=0;
  REP(i,k){
    tmp += p[i];
  }
  ans=max(ans,tmp);
  FOR(i,k,n){
    tmp-=p[i-k];
    tmp+=p[i];
    ans=max(ans,tmp);
  }
  printf("%f\n",ans);
}



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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    
        String s = br.readLine();
        
        if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)){
            out.println("Yes");
        }else{
            out.println("No");
        }
        out.close();
        
    }
}

Measured memory_bytes: 32648
#include<iostream>
using namespace std;
int main(){
    int n,b,f,r,v,A[4][3][10];
    cin >> n;
    for(int i = 0;i < 4; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 10; k ++){
                A[i][j][k] = 0;
            }
        }
    }
    for(int a = 0; a<n; a++){
        cin >>b>>f>>r>>v;
        A[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 << " " << A[i][j][k];
            }
            cout << endl;
        }
        if(i != 3){
            for(int c = 0; c < 20; c++){
                cout <<"#";
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>
 
int main(void) {
    int n, i;
    int ayaneru = 0, asumisu = 0;
    char tomatu[128], sumipe[128];
    if (scanf("%d", &n) != 1) return 1;
    for (i = 0; i < n; i++) {
        int mareitaso;
        if (scanf("%127s%127s", tomatu, sumipe) != 2) return 1;
        mareitaso = strcmp(tomatu, sumipe);
        if (mareitaso > 0) ayaneru += 3;
        else if (mareitaso < 0) asumisu += 3;
        else ayaneru++, asumisu++;
    }
    printf("%d %d\n", ayaneru, asumisu);
    return 0;
}


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

from collections import Counter

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

d = Counter(a)

a_odd  = sum(v for k,v in d.items() if k % 2 == 1)
a_quad = sum(v for k,v in d.items() if k % 4 == 0)


if a_odd + a_quad == N and a_quad == a_odd - 1:
  print("Yes")
elif a_quad >= a_odd:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 22272
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let H = read![[i64]];

    let mut m = 0;
    let mut k = 0;

    for i in 0..N - 1 {
        if H[i] >= H[i + 1] {
            k += 1;
        } else {
            k = 0;
        }

        m = max(m, k);
    }

    println!("{}", m)
}


Measured memory_bytes: 8444
#pragma GCC optimize("Ofast")
#include <cstdio>

const int cm = 1 << 4;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1596
#include <stdio.h>
int arr[3][3];
int row[3],col[3],diag[2];
int main(){
	for(int i=0;i<3;i++) for(int j=0;j<3;j++) scanf("%d",&arr[i][j]);
	int N;scanf("%d",&N);
	while(N--){
		int t;scanf("%d",&t);
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(arr[i][j]==t){
					row[i]++;
					col[j]++;
					if(i==j) diag[0]++;
					if(i+j==2) diag[1]++;
				}
			}
		}
	}
	bool isok=false;
	for(int i=0;i<3;i++) isok|=row[i]==3||col[i]==3;
	isok|=diag[0]==3||diag[1]==3;
	printf("%s",isok?"Yes":"No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007.0l

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

map<pii, int> m;
int ct = 0, c1= 0, c2 = 0;

int powmod(int a, int b, int c){
    int ans = 1;
    while(b){
        if(b&1){
            ans = (ans*a)%c;
        }
        a = (a*a)%c;
        b >>= 1;
    }
    return ans;
}

void solve(){
    int n; cin>>n;
    int a, b;
    For(i, 0, n){
        cin>>a>>b;
        if(a!=0 && b!=0){
            int g = __gcd(a, b);
            a /= g;
            b /= g;
            if(a<0 && b<0){
                m[{abs(a), abs(b)}]++;
            }
            else if(a>0 && b>0){
                m[{a, b}]++;
            }
            else if(a<0 && b>0){
                m[{a, b}]++;
            }
            else{
                m[{-a, -b}]++;
            }
        }
        else if(a==0 && b==0){
            ct++;
        }
        else if(a==0){
            c1++;
        }
        else if(b==0){
            c2++;
        }
    }

    int ans = 1;
    while(m.begin()!=m.end()){
        auto pp = *m.begin();
        pii p = pp.F;
        pii p2;
        p2.S = abs(p.F);
        p2.F = abs(p.S);
        if(p.F > 0){
            p2.F = -p2.F;
        }
        int x1 = pp.S;
        int x2 = 0;
        m.erase(p);
        if(m.find(p2)!=m.end()){
            x2 = m[p2];
            m.erase(p2);
        }
        int v = powmod(2, x1, MOD) + powmod(2, x2, MOD) - 1 + MOD;;
        v %= MOD;
        ans *= v;
        ans %= MOD;
    }
    int v = powmod(2, c1, MOD) + powmod(2, c2, MOD) - 1 + MOD;
    v %= MOD;
    ans *= v;
    ans %= MOD;
    ans = (ans-1+MOD)%MOD;
    ans += (ct);
    ans%=MOD;
    cout<<ans;
}

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 15996
#n = int(input())
a,b,c,x,y = map(int,input().split())
#a_L = list(map(int,input().split()))
price = 10**16
for i in range(10**7):
    price = min(price,i*2*c + max(0,x-i)*a +  max(0,y-i)*b)

print(price)


Measured memory_bytes: 41196
package main

import (
    "fmt"
)

var n int
var as []int
var dp []int

func main() {
    fmt.Scan(&n)
    as = make([]int, n)
    dp = make([]int, n*n)
    for i := range as {
        var a int
        fmt.Scan(&a)
        as[i] = a
    }
    res := calc(0, n-1)
    fmt.Println(res)
}

// calc returns max score
func calc(i, j int) int {
    if j < i {
        return 0
    }
    if dp[i*n+j] != 0 {
        return dp[i*n+j]
    }

    s1 := as[i] - calc(i+1, j)
    s2 := as[j] - calc(i, j-1)

    if s1 > s2 {
        dp[i*n+j] = s1
    } else {
        dp[i*n+j] = s2
    }
    return dp[i*n+j]
}


Measured memory_bytes: 72704
#include<iostream>

using namespace std;

int main()
{
	char num[48]={' '};
	
	for(int i=0;i<28;i++)
	{
		int a;
		cin >> a ;
		num[a]='1';
	}
	for(int i=1;i<31;i++)
	{
		if(num[i]!='1')
		{
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 0
import collections

n = int(input())
a = list(map(int, input().split()))

b = collections.deque()
for i in range(n):
    if i % 2 == (n-1) % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])

for i in b:
    print(i, end=' ')


Measured memory_bytes: 25412
import java.io.*;
class Main{
	public static int height[]=new int[10];
	public static void liner(){
		int num;
		for(int i=0;i<=9;i++){
			for(int j=i+1;j<=9;j++){
				if(height[i]<=height[j]){
					num=height[i];
					height[i]=height[j];
					height[j]=num;
				}
			}
		}
		for(int i=0;i<=2;i++)
			System.out.println(height[i]);
	}

	public static void main(String[] a) throws IOException{
		BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
		for(int i=0;i<=9;i++){
			height[i]=Integer.parseInt(in.readLine());
		}
				
		liner();
	}
}

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

int main()
{
    int h,n;
    cin >> h >> n;
    int a[n] = {};
    int b[n] = {};
    for(int i=0; i<n; i++)  cin >> a[i] >> b[i];
    vector<int> dp(h+1, 1e9);
    dp[0] = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=h; j++){
            int t = min(h, j+a[i]);
            dp[t] = min(dp[t], dp[j] + b[i]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int main()
{
    int n, m;
    int a[10000];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cin >> m;
    int t;
    int cnt = 0;
    for(int i = 0; i < m; i++){
        cin >> t;
        for(int j = 0; j < n; j++){
            if(t == a[j]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1196
MOD = 10**9+7
s = input()
n = len(s)
dp = [[0]*13 for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    digit = n-1-i
    x = s[digit]
    X = []
    if x != '?':
        X.append(int(x)*pow(10, i, 13) % 13)
    else:
        for num in range(10):
            X.append(num*pow(10, i, 13) % 13)
    for j in range(13):
        for x in X:
            dp[i+1][(j+x) % 13] += dp[i][j]
            dp[i+1][(j+x) % 13] %= MOD

print(dp[-1][5])


Measured memory_bytes: 62428
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}







  


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





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

int main(){
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	int ans(100000), t;
	t = abs(a[0]-a[1]) + abs(a[1]-a[2]);
	if(t < ans) ans = t;
	t = abs(a[0]-a[2]) + abs(a[2]-a[1]);
	if(t < ans) ans = t;
	t = abs(a[1]-a[0]) + abs(a[0]-a[2]);
	if(t < ans) ans = t;
	t = abs(a[1]-a[2]) + abs(a[2]-a[0]);
	if(t < ans) ans = t;
	t = abs(a[2]-a[0]) + abs(a[0]-a[1]);
	if(t < ans) ans = t;
	t = abs(a[2]-a[1]) + abs(a[1]-a[0]);
	if(t < ans) ans = t;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env Python3

#import
#import math
#import numpy as np
#= int(input())
#= input()
modnum = 998244353

N, K = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(K)]

def mod(num):
    return num % modnum

dp = [0] * (N + 1)
sdp = [0] * (N + 1)

dp[1] = 1
sdp[1] = 1

for i in range(2, N + 1):
    for l, r in LR:
        ri = max(0, i - l)
        li = max(0, i - r - 1)

        dp[i] += sdp[ri] - sdp[li]
        dp[i] = mod(dp[i])

    sdp[i] = sdp[i - 1] + dp[i]

print(dp[N])


Measured memory_bytes: 27828
#include<bits/stdc++.h>
using namespace std;
#define int long long

int dp[3001][3001]; //[i,j)のX-Yの値

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

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  //元の数列から連続する区間a[i~j]を抜き出した局面を考えていく
  for(int len = 1; len <= n; len++){
    for(int i = 0; i+len <= n; i++){
      int j = i + len;
      if((n-len)%2 == 0){
        dp[i][j] = max(dp[i+1][j] + a[i],dp[i][j-1] + a[j-1]);
      }
      else {
        dp[i][j] = min(dp[i+1][j] - a[i],dp[i][j-1] - a[j-1]);
      }
    }
  }
  cout << dp[0][n] << endl;

  return 0;
}


Measured memory_bytes: 70016
#include<iostream>
using namespace std;
int main(){
	int H,W;
	long ans[1001][1001]={0};
	char A;
	cin>>H>>W;
	ans[1][0]=1;
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++){
		cin>>A;
		if(A=='.')ans[i][j] = ans[i-1][j] + ans[i][j-1];
		ans[i][j]%=1000000007;
	}
	cout<<ans[H][W];
	return 0;
}

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

int main() {
  int N;
  string A;  
  cin >> N;
  int a = 0;
  int w = 0;
  int t = 0;
  int r = 0;
  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A == "AC") {
      a++;
    }
    else if (A == "WA") {
      w++;
    }
    else if (A == "TLE") {
      t++;
    }
    else if (A == "RE") {
      r++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << w << endl;
  cout << "TLE x " << t << endl;
  cout << "RE x " << r << endl;
}


Measured memory_bytes: 3628
using System;

namespace _0101
{
    class Program
    {
        static void Main(string[] args)
        {
            int j = int.Parse(Console.ReadLine());
            for (int i = 0; i < j; i++)
            {
                string s = Console.ReadLine();
                Console.WriteLine(s.Replace("Hoshino", "Hoshina"));
            }
            Console.ReadLine();
        }
    }
}

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

int main(){
  string s; cin >> s;
  int yes=0;
  int no=0;
  for(int i=0;i<s.size();i=i+2){
    if(s.at(i)=='L'){
      no++;
    }
    else{
      yes++;
    }
  }
  for(int i=1;i<s.size();i=i+2){
    if(s.at(i)=='R'){
      no++;
    }
    else{
      yes++;
    }
  }
  if(no>=1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int m   = 0;
  for (int i = 0; i < N; i++) {
	  int p;
	  cin >> p;
	  sum += p;
	  m    = max(m, p);
	}
  cout << sum - m / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int c[3];
	
	while (scanf("%d %d %d", &c[0], &c[1], &c[2]) != EOF){
		char card[10] = {0};
		int i;
		int count = 0;
		int sum = c[0] + c[1];
		
		for (i = 0; i < 3; i++){
			card[c[i] - 1] = 1;
		}
		for (i = 0; i < 10; i++){
			if (card[i] == 0 && sum + i + 1 <= 20){
				count++;
			}
		}
		if (count >= 4){
			puts("YES");
		}
		else {
			puts("NO");
		}
	}
	
	return 0;
}

Measured memory_bytes: 576
import math

# inputList=[]
# for i in range(6):
#     inputNum = input()
#     inputList.append(inputNum)
inputa = input().split()
# inputb = input().split()

inputa = [int(n) for n in inputa]
inputa.sort()

a = int(inputa[0])
b = int(inputa[1])
c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

print(c * 10 + a + b)




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

int main(){
  int N;
  cin >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  bool check = true;
  rep(i, N){
    if (A[i] % 2 == 0){
      if ((A[i] % 3 == 0) || (A[i] % 5 == 0)) check *= true;
      else check *= false;
    }
  }
  if (check) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::max;
#[allow(unused_imports)]
use std::cmp::min;
#[allow(unused_imports)]
use std::fmt;
#[allow(unused_imports)]
use std::fmt::Debug;
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
    let input = get_vec_input();
    let x: usize = input[0];
    let y: usize = input[1];

    if (y - 2 * x) % 2 == 0 && (y - 2 * x) / 2 <= x {
        println!("Yes");
    } else {
        println!("No");
    }
}

#[allow(dead_code)]
fn get_digit(value: i64) -> i64 {
    let mut digit = 0i64;
    let mut value = value;
    while value != 0 {
        value /= 10;
        digit += 1;
    }
    digit
}

#[allow(dead_code)]
fn sum_digit2(value: String) -> u32 {
    return value.chars().fold(0u32, |a, b| a + b.to_digit(10).unwrap());
}

#[allow(dead_code)]
fn sum_digit(value: i64) -> i64 {
    if value < 10 {
        return value;
    }
    return sum_digit(value / 10) + value % 10;
}

#[allow(dead_code)]
fn update_max<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left < right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn update_min<T>(left: &mut T, right: T)
where
    T: std::cmp::Ord + std::clone::Clone,
{
    if *left > right {
        *left = right.clone();
    }
}

#[allow(dead_code)]
fn get_vec_input<T>() -> Vec<T>
where
    T: FromStr,
    T::Err: Debug,
{
    let mut input = String::new();
    io::stdin()
        .read_line(&mut input)
        .expect("Failed to read line");
    let vec: Vec<T> = input
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    vec
}

#[allow(dead_code)]
fn get_tuple_input() -> (u64, f32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let c: u64 = iter.next().unwrap().parse().unwrap();
    let n: f32 = iter.next().unwrap().parse().unwrap();
    (c, n)
}

#[allow(dead_code)]
fn get_string_input() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    s.trim().to_string()
}


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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int N;
    cin >> N;
    int A[N];
    int cnt = 0;
    int now = 1;
    Rep(i,N)cin >> A[i];
    Rep(i,N){
        if(A[i] == now){
            now++;
        }else{
            cnt++;
        }
    }
    if(cnt == N)cout << -1 << endl;
    else cout << cnt << endl;
    cin >> N;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> v(n, k - q);
  rep(i,q) {
    int a;
    cin >> a;
    a--;
    v[a]++;
  }
  rep(i,n) {
    if (v[i] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3772
def f(a,m):
	ans =0
	for x in a:
		ans += abs(m- x)**2
	return ans
		
input()
a =list(map(int, input().split()))
a.sort()
m = (a[0] + a[-1]) //2
ans = f(a,m)
for x in range(a[0],a[-1]+1):
	ans = min(ans,f(a,x))
print(ans)

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

#define p(x) cout << x << endl;
#define el cout << endl;

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

    string s;
    cin >> s;

    sort(s.begin(), s.end());
    if(s[0] == 'a' && s[1] == 'b' && s[2] == 'c'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int n,a;
vector<int> E[100009];

int dfs(int x){
    vector<int> vec;
    rep(i,E[x].size()){
        vec.push_back(dfs(E[x][i]));
    }
    sort(vec.begin(),vec.end(),greater<int>());
    int re=0;
    rep(i,vec.size())re=max(re,vec[i]+i+1);
    return re;
}

int main(){
    cin>>n;
    for(int i=2;i<=n;i++){
        cin>>a;
        E[a].push_back(i);
    }
    cout<<dfs(1)<<endl;
}

Measured memory_bytes: 13568
from collections import Counter
N = int(input())
S = set()
cnt = 0

def createStr(intput_str):
    ret = ""
    intput_str = sorted(intput_str)
    for s in intput_str:
        ret += s
    return ret

ret = {}
for i in range(N):
    s = createStr(input())
    if s in ret.keys():
        ret[s] += 1
    else:
        ret[s] = 1

for i in ret.values():
    cnt += i*(i-1)//2

print(cnt)


Measured memory_bytes: 18184
#include <stdio.h>
#define N 100
int main(){
  int i,n,min,j,count=0,a[N],change,flag;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  
  for(i=0;i<n;i++){
    min=i;
    flag=0;
    for(j=i;j<n;j++){
      if(a[j]<a[min]){
	min=j;
	flag=1;
      }
    }
    change=a[i];
    a[i]=a[min];
    a[min]=change;
    if(flag==1) count++;
  }
  
  for(i=0;i<n;i++){
    if(i<n-1) printf("%d ",a[i]);
    else printf("%d\n",a[i]); 
  }
  printf("%d\n",count);
  return 0;
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	vector<ll> cumsum(n + 1, 0);
	rep(i, n){
		cumsum[i + 1] = cumsum[i] + a[i];
	}
	
	map<ll, ll> mp;
	rep(i, n + 1){
		mp[cumsum[i]]++;
	}
	
	ll ans = 0;
	for(auto itr : mp){
		ans += itr.second * (itr.second - 1) / 2;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15104
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int[,] path = new int[m,2];
        List<int>[] pa = new List<int>[n];
        for(int i=0; i<n; i++){
          	pa[i] = new List<int>();
        }
        for(int i=0; i<m; i++){
            string[] input2 = Console.ReadLine().Split(' ');
            path[i,0] = int.Parse(input2[0]);
            path[i,1] = int.Parse(input2[1]);
            pa[path[i,0]-1].Add(path[i,1]);
            pa[path[i,1]-1].Add(path[i,0]);
        }

        int[] dist = new int[n];
        int[] prev = new int[n];
        /*for(int i=0; i<n; i++){
            dist[i] = -1;
        }*/
        //dist[0] = 0;
        var que = new Queue<int>();
        que.Enqueue(1);
        while(que.Count > 0){
            int current = que.Peek();
            que.Dequeue();

            /*for(int i=0; i<m; i++){
                if(path[i,0] == current && (dist[path[i,1]-1] == 0)) {
                    que.Enqueue(path[i,1]);
                    dist[path[i,1]-1] = dist[path[i,0]-1] + 1; 
                    prev[path[i,1]-1] = current;
                }
                else if(path[i,1] == current && (dist[path[i,0]-1] == 0)) {
                    que.Enqueue(path[i,0]);
                    dist[path[i,0]-1] = dist[path[i,1]-1] + 1;
                    prev[path[i,0]-1] = current;
                }
            }*/
            foreach (int item in pa[current-1])
            {
                if(dist[item-1] == 0) {
                    que.Enqueue(item);
                    dist[item-1] = dist[current-1] + 1;
                    prev[item-1] = current;
                }
            }
        }
        for(int i=1; i<n; i++){
            if(prev[i] == 0) {
              Console.WriteLine("No");
              return;
            }
        }
        Console.WriteLine("Yes");
        for(int i=1; i<n; i++){
            Console.WriteLine(prev[i]);
        }
	}   
}

Measured memory_bytes: 36944
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int day = scan.nextInt();
    switch(day){
      case 25:
        System.out.println("Christmas");
        break;
      case 24:
        System.out.println("Christmas Eve");
        break;
      case 23:
        System.out.println("Christmas Eve Eve");
        break;
      case 22:
        System.out.println("Christmas Eve Eve Eve");
        break;
    }
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

const int maxn = 100002;

int n, start;

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

	return gcd(b, a%b);
}

int main()
{
	int pos, res = -1;
	cin >> n >> start;

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

		if (pos == start)
			continue;
		
		int dist = abs(pos-start);

		if (res == -1) {
			res = dist;
		} else {
			res = gcd(res, dist);
		}

		if (res == 1) {
			break;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

int inv_mod(int a, int m){
	assert(0<a);
	assert(a<m);
	return a==1 ? 1 : m-m*int64_t(inv_mod(m%a, a))/a;
}

const int mod = 1e9+7 ;
struct mint {
	int x;
	mint(): x(0) {}
	mint(const auto &val): x(val%mod) { if(x<0) x+=mod; }
};

void operator+=(mint &a, const mint &b){ a.x+=b.x; if(a.x>=mod) a.x-=mod; }
mint operator+(mint a, const mint &b){ a+=b; return a; }
void operator-=(mint &a, const mint &b){ a.x-=b.x; if(a.x<0) a.x+=mod; }
mint operator-(mint a, const mint &b){ a-=b; return a; }
void operator*=(mint &a, mint b){ a.x = int64_t(a.x)*b.x %mod; }
mint operator*(mint a, const mint &b){ a*=b; return a; }
void operator/=(mint &a, const mint &b){ a.x = int64_t(a.x)*inv_mod(b.x,mod) %mod; }
mint operator/(mint a, const mint &b){ a/=b; return a; }
mint operator-(mint a){ if(a.x) a.x = mod - a.x; return a; }
mint operator""m(unsigned long long x){ return mint(x); }
ostream& operator<<(ostream &o, const mint &m){ return o<<m.x; }



int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	cin>>n;
	
	vector<vector<mint>> dp(n+1, vector<mint>(4));
	
	dp[0][0] = 1;
	
	for(int i=0;i<n;i++)
	for(int ms=0;ms<4;++ms){
		for(int x=0;x<10;++x){
			int m0 = (x==0);
			int m9 = (x==9)<<1;
			dp[i+1][ms|m0|m9]+=dp[i][ms];
		}
	}
	
	cout<<dp[n][3]<<endl;
	
	return 0;
}


Measured memory_bytes: 57828
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int dp[2][30010];

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

  int H, N, A[1000], B[1000]; cin >> H >> N;
  H += 20000;
  REP(i, N){
    cin >> A[i] >> B[i];
  }
  REP(i, 2) REP(j, 30010) dp[i][j] = BIG;
  REP(i, 2) dp[i][H] = 0;
  REP(i, N) for(int j = H; j >= 0; j--){
    int pre = i&1, cur = (i+1)&1;
    if(j + A[i] > H) dp[cur][j] = dp[pre][j];
    else dp[cur][j] = min(dp[pre][j], dp[cur][j+A[i]] + B[i]);
  }
  int ans = BIG;
  REP(j, 20001) chmin(ans, dp[N&1][j]);
  cout << ans << endl;
}


Measured memory_bytes: 768
import numpy as np
from math import sqrt

def sieve(n):
    S = [True] * (n+1)
    S[0] = S[1] = False
    i = 2
    while i * i <= n:
        if S[i]:
            k = i * i
            while k <= n:
                S[k] = False
                k += i
        i += 1
    return S

  
def arrayF(n): 
    F=[0]*(n+1) 
    i=2 
    while i*i<=n:
        if F[i] == 0: 
            k=i*i
            while k <= n:
                if F[k] == 0:
                    F[k] = i
                k += i
        i += 1 
    return F


def factorization(x, F): 
    primeFactors = [] 
    while (F[x] > 0):
        primeFactors.append(F[x])
        x //= F[x] 
    primeFactors.append(x) 
    return primeFactors


n = int(input())
if n == 1:
    print(0)
    exit(0)

rt = int(sqrt(n)+1)
S = sieve(rt)
primes = np.arange(rt+1)[S]

for i in primes:
    if n % i == 0:
        break
else:
    print(1)  # n is prime
    exit(0)

m = n
facts = {}
for i in primes:
    if m % i == 0:
        facts[i] = 0
        while m % i == 0:
            m //= i
            facts[i] += 1
if m != 1:
    facts[m] = 1

for k in facts:
    v = facts[k]
    if v < 3:
        facts[k] = 1
    elif v < 6:
        facts[k] = 2
    elif v < 10:
        facts[k] = 3
    elif v < 15:
        facts[k] = 4
    elif v < 21:
        facts[k] = 5
    elif v < 28:
        facts[k] = 6
    elif v < 36:
        facts[k] = 7
    elif v < 45:
        facts[k] = 8
    elif v < 55:
        facts[k] = 9
    elif v < 66:
        facts[k] = 10
print(sum(facts.values()))

Measured memory_bytes: 43884
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,N_copy;
  int fx=0;
  cin>>N;
  N_copy=N;
  while(N>0){
    fx+=N%10;
    N/=10;
  }
  if(N_copy%fx==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <math.h>

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i ++){
    double t = (double) k / (double) i; // 10/
    if(t <= 1){
      ans += 1 / (double) n;
    //  printf("%0.9lf\n",ans);
    }
    else{
      double tt = log2(t); // 3.??
      int ttt = tt; // 3 ?
      if( double(ttt) != tt) ttt++;
      ans += 1 / (n * pow(2,ttt));
      //printf("%d %lf %lf %d %0.9lf %d\n",i,t,tt,ttt,ans,n * (int)pow(2,ttt));
    }
  }
  printf("%0.12lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const ll INF = 1e18;
map<ll,int> mp;
ll c[52][52];
int main(){
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 1; i <= 51; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0) {
        c[i][j] = 1LL;
      } else {
        c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    ll v;
    cin >> v;
    mp[v]++;
  }
  stack<pair<ll,int>> stk;
  for (auto p: mp) {
    stk.push(make_pair(p.first,p.second));
  }
  if (stk.top().second >= a) {
    cout << stk.top().first << endl;
    ll cc = 0;
    for (int i = a; i <= min(b, stk.top().second); i++) {
      cc += c[stk.top().second + 1][i];
    }
    cout << cc << endl;
    return 0;
  }
  int cnt = 0;
  ll sum = 0;
  while (cnt + stk.top().second <= a) {
    cnt += stk.top().second;
    sum += stk.top().first * stk.top().second;
    stk.pop();
  }
  int k = a - cnt;
  cout << setprecision(20) << (k == 0 ? (double) sum / cnt : (double)(sum + k * stk.top().first) / (cnt + k)) << endl;
  cout << c[stk.top().second + 1][k] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		HashMap<Character, String> map = new HashMap<Character, String>();
		map.put(' ', "101");
		map.put('\'', "000000");
		map.put(',', "000011");
		map.put('-', "10010001");
		map.put('.', "010001");
		map.put('?', "000001");
		map.put('A', "100101");
		map.put('B', "10011010");
		map.put('C', "0101");
		map.put('D', "0001");
		map.put('E', "110");
		map.put('F', "01001");
		map.put('G', "10011011");
		map.put('H', "010000");
		map.put('I', "0111");
		map.put('J', "10011000");
		map.put('K', "0110");
		map.put('L', "00100");
		map.put('M', "10011001");
		map.put('N', "10011110");
		map.put('O', "00101");
		map.put('P', "111");
		map.put('Q', "10011111");
		map.put('R', "1000");
		map.put('S', "00110");
		map.put('T', "00111");
		map.put('U', "10011100");
		map.put('V', "10011101");
		map.put('W', "000010");
		map.put('X', "10010010");
		map.put('Y', "10010011");
		map.put('Z', "10010000");
		HashMap<String, Character> map2 = new HashMap<String, Character>();

		map2.put("00000", 'A');
		map2.put("00001", 'B');
		map2.put("00010", 'C');
		map2.put("00011", 'D');
		map2.put("00100", 'E');
		map2.put("00101", 'F');
		map2.put("00110", 'G');
		map2.put("00111", 'H');
		map2.put("01000", 'I');
		map2.put("01001", 'J');
		map2.put("01010", 'K');
		map2.put("01011", 'L');
		map2.put("01100", 'M');
		map2.put("01101", 'N');
		map2.put("01110", 'O');
		map2.put("01111", 'P');
		map2.put("10000", 'Q');
		map2.put("10001", 'R');
		map2.put("10010", 'S');
		map2.put("10011", 'T');
		map2.put("10100", 'U');
		map2.put("10101", 'V');
		map2.put("10110", 'W');
		map2.put("10111", 'X');
		map2.put("11000", 'Y');
		map2.put("11001", 'Z');
		map2.put("11010", ' ');
		map2.put("11011", '.');
		map2.put("11100", ',');
		map2.put("11101", '-');
		map2.put("11110", '\'');
		map2.put("11111", '?');
		StringBuilder sb = new StringBuilder();
		for (Scanner in = new Scanner(System.in); in.hasNextLine();) {
			sb.setLength(0);
			char[] cs = in.nextLine().toCharArray();
			for (char c : cs) {
				sb.append(map.get(c));
			}
			while (sb.length() % 5 != 0) {
				sb.append('0');
			}
			String s = sb.toString();
			for (int i = 0; i < s.length(); i += 5) {
				System.out.print(map2.get(s.subSequence(i, i + 5)));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 13000
#include <stdio.h>
 
int main(void)
{
    int input=0;
    long int number[105]={};
    long int a=0;
    long int b=0;
    long int c=0;
    int count=0;
    
    scanf("%d",&input);
    for(int i = 0; i < input; i++){
        scanf("%ld",&number[i]);
    }
    if(input < 3){
        printf("0");
        return 0;
    }
 
    for(int i = 0; i <input; i++){
        for(int j = i + 1; j < input ;j++){
            if(number[i] != number[j]){
                for(int k = j + 1; k < input; k++){
                    if(number[i] != number[k] && number[j] != number[k]){
                        a = number[i]+number[j]-number[k];
                        b = number[j]+number[k]-number[i];
                        c = number[k]+number[i]-number[j];
                        if(a > 0 && b> 0 && c > 0){
                            count+=1;

                        }
                    }
                }
            }
        }
    }
 
    printf("%d",count);
    return 0;
}

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

int main() {
long long n,k,c=0;
cin>>n>>k;
if(k==0){
    cout<<n*n<<endl;
    return 0;
}
for(int i=k+1;i<=n;i++){
//cout<<c<<endl;
    c+=(n/i)*(i-k);
    if((n%i-k+1>0)){
        c+=(n%i)-k+1;
    }
}
cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
import math

ABC = input().split()

a = int(ABC[0])
b = int(ABC[1])
c = int(ABC[2])
#a = b = c = pow(10,9)

l2  = 4 * a * b
r = c - a - b
r2 = r * r

# if l2 < r2:
#     print("Yes")
# else:
#     print("No")

if r > 0 :
    if l2 < r2:
        print("Yes")
    else:
        print("No")
else:
    print("No")




Measured memory_bytes: 3060