akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a[3];
   rep(i,3) cin >> a[i];

   sort(a,a+3,greater<int>());

   int ans = (a[0] - a[1]) + (a[1] - a[2]);

   cout << ans << endl;  


   return 0;
}

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

if k == 1:
    print(n**3)
elif k == 2:
    odd = (n+1)//2
    even = n//2
    print(odd**3+even**3)
else:
    m = n//k
    if k%2 == 0:
        half = n//(k//2)-m
    else:
        half = 0
    print(m**3+half**3)


Measured memory_bytes: 3060
N, M, K = [int(_) for _ in input().split()]
AB = [[int(_) - 1 for _ in input().split()] for _ in range(M)]
CD = [[int(_) - 1 for _ in input().split()] for _ in range(K)]
friends = [0 for _ in range(N)]


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.root[self.find(x)]


uf = UnionFind(N)
for a, b in AB:
    uf.unite(a, b)
    friends[a] += 1
    friends[b] += 1
ans = [uf.size(i) - friends[i] - 1 for i in range(N)]
for c, d in CD:
    if uf.is_same(c, d):
        ans[c] -= 1
        ans[d] -= 1
print(*ans)


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int d, n;
  cin >> d >> n;
  if (n == 100) n++;
  int ans = pow(100, d) * n;
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int a[200][200];
int main(){
  int n,m;
  cin>>n>>m;
  char ch;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      cin>>ch;
      if(ch=='o')
	for(int k=j-1;k<j+2;k++)
	  a[i][k]++;
      if(ch=='x')
	for(int k=i-1;k<i+2;k++)
	  for(int l=j-1;l<j+2;l++)
	    a[k][l]++;
    }
  }
    int ans=0;
    for(int i=2;i<=n;i++)
      for(int j=1;j<=m;j++)
	if(a[i][j]==0)ans++;
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
using namespace std;
int main() {
	int a[12];
	for (int i = 0; i < 12; i++) cin >> a[i];
	sort(a, a + 12);
	bool l = true;
	int b[12][2], c = 0;
	for (int i = 0; i < 12; i++) {
		if (i == 0) {
			b[c][0] = a[i];
			b[c][1] = 1;
			c++;
		}
		else {
			if (b[c - 1][0] == a[i]) {
				b[c - 1][1]++;
			}
			else {
				b[c][0] = a[i];
				b[c][1] = 1;
				c++;
			}
		}
	}
	if (c == 3) {
		for (int i = 0; i < c; i++) {
			if (b[i][1] != 4) {
				l = false;
			}
		}
	}
	else if (c == 2) {
		if ((b[0][1] == 8 && b[1][1] == 4) ||
			(b[0][1] == 4 && b[1][1] == 8)) {
			l = true;
		}
		else l = false;
	}
	else if (c == 1) {
		if (b[0][1] == 12) l = true;
		else l = false;
	}
	else {
		l = false;
	}
	if (l) cout << "yes" << endl;
	else cout << "no" << endl;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi v;
vp dp;
P dfs(int i){
    if(dp[i]!=P(-1,-1))return dp[i];
    if(i==0)return P(0,-1);
    ll k=0;
    vp t;
    while(i-k!=0){
        int j=i-k;
        ll nk=(j&~(j-1));
        j=i-nk;
        P a=dfs(j);
        t.eb(v[a.fi],a.fi);if(a.se!=-1)t.eb(v[a.se],a.se);
        k+=nk;
    }
    t.eb(v[i],i);
    sort(all(t));reverse(all(t));
    dp[i].fi=t[0].se;
    int w=1;
    while(t[w].se==t[0].se)w++;
    dp[i].se=t[w].se;
    return dp[i];
}
int main(){
    ll n;cin>>n;
    ll m=1<<n;
    v=vi(m);dp=vp(m,P(-1,-1));
    rep(i,m)cin>>v[i];
    vi res(m);
    for(int i=m-1;i>=1;i--)res[i]=v[dfs(i).fi]+v[dfs(i).se];
    REP(i,1,m-1)chmax(res[i+1],res[i]);
    REP(i,1,m)out(res[i]);
}

Measured memory_bytes: 11264
import sys


def getmin(i, j, mlist, memo={}):
    if i == j:
        return 0
    elif (i, j) in memo:
        return memo[(i, j)]
    else:
        ret = sys.maxsize
        for k in range(i, j):
            p = mlist[i][0]
            n = mlist[k][1]
            q = mlist[j][1]
            tmp = getmin(i, k, mlist, memo) + \
                getmin(k+1, j, mlist, memo) + p*n*q

            if tmp < ret:
                ret = tmp

        memo[(i, j)] = ret
        return memo[(i, j)]


def main():
    n = int(input())
    M = [[0, 0] for i in range(n)]
    for i in range(n):
        M[i] = list(map(int, input().split()))

    print(getmin(0, n-1, M))


if __name__ == '__main__':
    main()



Measured memory_bytes: 6348
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	int n;
	cin >> n;
	vector<vector<pair<int,int>>> v(n);
	REP(i,n-1){
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,c));
	}
	int q,k;
	cin >> q >> k;
	k--;
	vector<vector<int>> a(q,vector<int>(2));
	REP(i,q){
		cin >> a[i][0] >> a[i][1];
		a[i][0]--;
		a[i][1]--;
	}
	
	queue<int> que;
	vector<ll> cost(n,-1);
	que.push(k);
	cost[k] = 0;
	while(!que.empty()){
		int now = que.front();
		que.pop();
		
		for(auto x: v[now]){
			int child = x.first;
			int c = x.second;
			if(cost[child]==-1){
				cost[child] = cost[now] + c;
				que.push(child);
			}
		}
	}
	
	REP(i,q){
		cout << cost[a[i][0]]+cost[a[i][1]] << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 16228
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
using namespace std;
typedef long long ll;
int main(){
	int N;
	cin >> N;
	vector<ll>H(N);
	for (int i = 0;i < N;++i) {
		cin >> H[i];
	}
	int ans = 0, cnt = 0;

	for (int i = 0;i < N;++i) {
		if (i == N - 1)break;
		if (H[i] >= H[i + 1]) {
			++cnt;
			ans = max(ans, cnt);
		}
		else {
			cnt = 0;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include "iostream"
#include "vector"
#include "algorithm"
#include "functional"
using namespace std;

using lint = long long;

template<typename T>
T meguru_search(T ok, T ng, function<bool(T)> check){
    while(max(ok, ng) - min(ok, ng) > 1){
        T mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

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

    vector<lint> h(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> h[i];
    }

    auto check = [&](lint mid){
        lint cnt = 0;
        for(int i = 0 ; i < n ; ++i){
            lint t = h[i] - mid * b;
            if(t < 0){
                continue;
            }
            cnt += (t + a - b - 1) / (a - b);
        }
        return cnt <= mid;
    };
    
    lint ans = meguru_search<lint>(1LL << 30, -1, check);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

int N;
int M[110000];
vector<int> lis[110000];

int Depth(int a) {
  if (lis[a].empty()) {
    return 0;
  } else {
    int mx = 0;
    vector<int> K;
    for (int i = 0; i < (int)lis[a].size(); i++) {
      K.push_back(Depth(lis[a][i]));
    }
    sort(K.begin(),K.end());
    reverse(K.begin(),K.end());
    for (int i = 0; i < (int)K.size(); i++) {
      mx = max(mx, K[i] + (i+1));
    }
    return mx;
  }
}

int main() {
  cin >> N;
  for (int i = 1; i < N; i++) {
    cin >> M[i];
    M[i]--;
    lis[M[i]].push_back(i);
  }
  cout << Depth(0) << endl;
  return 0;
}

Measured memory_bytes: 17452
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1], visited[n+1] = {0};
    for (int i=0; i<n; i++)cin>>a[i+1];
    visited[1] = 1;
    int curr = 1;
    int ans = 0;
    while(1){
        curr = a[curr];
        ans++;
        if (curr==2){
            cout<<ans<<endl;
            return 0;
        }
        if (visited[curr] == 1){
            cout<<-1<<endl;
            return 0;
        }
        visited[curr] = 1;
    }
}

Measured memory_bytes: 4416
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    repi(i,n,0){
        cout << s.at(i) << t.at(i);
    }
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<pair<ll,ll>> v(n);
    for(i=0;i<n;i++){
        cin >> k;
        v[i].first = k;
        v[i].second = i+1;
    }
    sort(v.begin(),v.end());
    for(i=0;i<n;i++){
        cout << v[i].second << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
    else
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

ll fac(ll n){
    if(n == 0) return 1;
    ll tmp = 1;
    for (int i = 1; i <= n; ++i) {
        tmp *= i;
    }
    return tmp;
}

int main() {
    int k,x;
    cin >> k >> x;

    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));

$a = substr($n, -1);

switch ($a) {
    case '2':
    case '4':
    case '5':
    case '7':
    case '9':
        echo 'hon';
        break;
    case '0':
    case '1':
    case '6':
    case '8':
        echo 'pon';
        break;
    default:
        echo 'bon';
        break;
}

return;
?>


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

    ll co=0,max=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='A'||s.at(i)=='C'
        ||s.at(i)=='G'||s.at(i)=='T'){
            co += 1;
        }else{
            co = 0;
        }
        if(max<co){
            max = co;
        }
    }

    cout<<max<<endl;

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
using namespace std;

struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};

int main(){
  Dice d;
  char c;
  for(int i=0;i<6;i++) cin>>d.s[i];
  getchar();
  while((c = getchar()) != '\n')d.roll(c);
  cout<<d.top()<<endl;
  return 0;
}



Measured memory_bytes: 3100
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

use std::cmp::*;

fn main() {
    input! {
        n: usize,
        tx: usize,
        ty: usize,
    }

    let x = min(tx - 1, ty - 1);
    let y = max(tx - 1, ty - 1);

    let mut dep = vec![0; n - 1];

    for i in 0..n - 1 {
        for j in i + 1..n {
            /*
            if j < x || y < i {
                dep[j - i] += 1;
            }
            if (x < i && i < y) && (x < j && i < y) {
                dep[j - i] += 1;
            }

            if i <= x &&
            */
            let mut k = vec![0; 3];
            k[0] = j - i;
            k[1] = (1 + (i as i64 - x as i64).abs() + (j as i64 - y as i64).abs()) as usize;
            k[2] = (1 + (i as i64 - y as i64).abs() + (j as i64 - x as i64).abs()) as usize;
            k.sort();
            dep[k[0] - 1] += 1;
        }
    }

    for i in 0..n - 1 {
        println!("{}", dep[i]);
    }
}

/*
    let mut gr = vec![vec![]; n];
    let mut dep = vec!
    for i in 1..n {
        gr[i].push(i - 1);
        gr[i - 1].push(i);
    }

    gr[x - 1].push(y - 1);
    gr[y - 1].push(x - 1);

    println!("{:?}", gr);

*/


Measured memory_bytes: 4352
A1 = [int(x) for x in input().rstrip().split()]
A2 = [int(x) for x in input().rstrip().split()]
A3 = [int(x) for x in input().rstrip().split()]

for i in A2:
    A1.append(i)

for l in A3:
    A1.append(l)

N = int(input())

def my_index(l,a,default = False):
    if a in l:
        return l.index(a)
    else:
        return default

for i in range(N):
    a=int(input())
    for j in range(9):
        if a==A1[j]:
            A1[j]=0

        
            
 
if A1[0]==A1[1]==A1[2]==0:
    print("Yes")
elif A1[3]==A1[4]==A1[5]==0:
    print("Yes")
elif A1[6]==A1[7]==A1[8]==0:
    print("Yes")
elif A1[0]==A1[3]==A1[6]==0:
    print("Yes")
elif A1[1]==A1[4]==A1[7]==0:
    print("Yes")
elif A1[2]==A1[5]==A1[8]==0:
    print("Yes")
elif A1[0]==A1[4]==A1[8]==0:
    print("Yes")
elif A1[2]==A1[4]==A1[6]==0:
    print("Yes")
else:
    print("No")



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

int main(){
    long long n, m;
    cin >> n >> m;
    
    long long count=0;
    if(m>=n*2){
        count = n;
        m-= count*2;
        count += m/4;
    }
    else{
        count = min(m/2, n);
        m -= count *2;
        count += m/4;
    }
    
    cout << count << endl;
    
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int count =0;
	for (int n = 0;n<S.size();++n) {
		if ('R'==S[n]) {
			count++;
		}
	}
	int ans = 0;
	for (int i = 0;i<count;++i) {
		if ('W'==S[i]) {
			ans++;
		}
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 3720
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int sum = 0;

		for(int i = a; i <= b; i++){
			if(c % i ==0){
				sum++;
			}
		}
		System.out.println(sum);
	}

}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
char S[55];
ll i,ans;
int main(){
    scanf("%lld%s", &N, S);
    fornum(i,2,N){
        if(S[i-2]=='A'&&S[i-1]=='B'&&S[i]=='C'){
            ++ans;
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())

    for h in range(1, 3501):
        for n in range(1, 3501):
            x = 4 * h * n - N * n - N * h
            if x <= 0: continue
            w, mod_ = divmod(N * h * n, x)
            if not mod_:
                print(h, n, w)
                return

main()


Measured memory_bytes: 2940
from collections import Counter

n = int(input())
S = [list(sorted(input())) for _ in range(n)]

ans_key = []
ans_key = Counter(S[0]).keys()

for s in S:
    ans_key = list(set(ans_key) & set(Counter(s).keys()))

ans_dict = {}
for key in ans_key:
    ans_dict[key] = float('inf')

for s in S:
    for string in ans_key:
        ans_dict[string] = min(ans_dict[string], list(s).count(string))

ans = ''
for key in ans_dict:
    for i in range(ans_dict[key]):
        ans += key
ans = list(ans)
ans.sort()

print(''.join(ans))


Measured memory_bytes: 3316
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    ll N,M;cin>>N>>M;
    if(M%2==1)M--;
    if(2*N>=M){
        cout<<M/2<<endl;
        return 0;
    }
    else{
        M-=2*N;
        cout<<N+M/4<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
import sys
i=0
j=0
k=0
t=0
m=0
s=0
lists=[]
lists2 =[]

#数値の数を受け取る
line = int(input())

#数値を受け取ってリストの作成
while i < line:
	a = int(input())
	#print (a)
	lists.insert(i,a)
	i +=1

#数値の足し合わせ
while j < line:
    s += lists[j]
    j +=1

#正しければ出力
if s%10 != 0:
	print(s)
else:
    #10の倍数以外のリスト作成
    while k < line:
        if lists[k]%10 != 0:
	        lists2.insert(m,lists[k])
	        m +=1
        k +=1
    if lists2 !=[]:
        t = min(lists2)
        print(s-t)
    else:
    	print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  int N;
  scanf("%d",&N);
  getchar();
  str line;
  getline(cin,line);
  int B[N] = {};
  split_str(line,' '){
    B[i_str(res)]++;
  }

  int itr,ans = 1;
  if(N % 2 == 0) itr = 1;
  else itr = 2;

  for(; itr < N; itr += 2){
    if(B[itr] != 2){
      printf("0");
      return 0;
    }
  }

  rep(i,N / 2){
    ans *= 2;
    ans %= MOD;
  }

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

Measured memory_bytes: 1924
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

void dfs(int u, int c, int p, vector<vector<pair<int, int>>> &graph, vector<int> &color){
	int d = 1;
	debug(u, c, p);
	for(auto q: graph[u]){
		int v = q.first;
		int n = q.second;
		if(v==p) continue;
		if(d==c) d++;
		color[n] = d;
		dfs(v, d, u, graph, color);
		d++;
	}
}

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

	vector<int> color(N-1);
	dfs(0, 0, -1, graph, color);

	int k = 0;
	for(int i=0; i<N-1; i++){
		k = max(k, color[i]);
	}
	cout << k << endl;
	for(int i=0; i<N-1; i++){
		cout << color[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 8320
n = int(input())
f = []
for _ in range(n):
    f.append(list(map(int, input().split())))
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))
def solve(lst):
    if sum(lst) == 0:
        return -float("inf")
    res = 0
    for i in range(n):
        num = 0
        for j in range(10):
            if lst[j] == 1 and f[i][j] == 1:
                num += 1
        res += p[i][num]
    return res
l = []
for _a in range(2):
        for _b in range(2):
            for _c in range(2):
                for _d in range(2):
                    for _e in range(2):
                        for _f in range(2):
                            for _g in range(2):
                                for _h in range(2):
                                    for _i in range(2):
                                        for _j in range(2):
                                            res = solve([_a, _b, _c, _d, _e, _f, _g, _h, _i, _j])
                                            l.append(res)
print(max(l))

Measured memory_bytes: 3064
n, k = map(int, input().split())
mod = 998244353
lr = [list(map(int, input().split())) for _ in range(k)]

dp = [0] * (n + 10)
dp[1] = 1
cumsum = [0] * (n + 10)
cumsum[1] = 1

for i in range(2, n + 1):
    for l, r in lr:
        if l >= i:
            continue

        ll = max(1, i - r)
        rr = i - l
        if ll <= rr:
            dp[i] += cumsum[rr] - cumsum[ll - 1]
            dp[i] %= mod
    cumsum[i] = cumsum[i - 1] + dp[i]
    cumsum[i] %= mod

print(dp[n] % mod)


Measured memory_bytes: 24592
#include <stdio.h>
int main(){
  int n,i,j,res,counter=0;

  while(1){
    res=0;
    counter=0;

    scanf("%d", &n);
    if(n==0)break;
    for(i=1;i<=1000;i++){
      res=0;
      if(i>n/2+10)break;
      res+=i;
      if(res>=n)break;
      for(j=i+1;j<=1000;j++){
	res+=j;
	if(res==n){
	  counter++;
	}
	if(res>=n){
	  break;
	}
      }
    }
    printf("%d\n",counter);
  }
  return 0;
}

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

signed main()
{
    int N,D; cin>>N>>D;
    vector<vector<int>> x(N,vector<int>(D));
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>x[i][j];
        }
    }  

    int ans=0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            int sum=0;
            for(int k=0;k<D;k++){
                sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            int t=sqrt(sum);
            if(t*t==sum) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a);
  sort(f);
  reverse(f);
  ll left = -1;
  ll right = (ll)pow(10,18)+1;
  while(left < right - 1){
    ll tmp = k;
    ll middle = (left + right)/2;
    rep(i,n){
      if(a[i]*f[i] > middle){
        ll target = a[i]*f[i] - middle;
        tmp -= (target + f[i] - 1)/f[i];
      }
    }//i
    if(tmp < 0) left = middle;
    if(tmp >= 0) right = middle;
  }
  cout << right << endl;
}


Measured memory_bytes: 3328
import Control.Monad
import Data.IntMap
import Data.List (sort)
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main :: IO ()
main = do
  n <- readLn
  a <- replicateM n (fst . fromJust . BS.readInt <$> BS.getLine)
  let
    po = fromList $ zip a [1..]
    meu = fromList $ zip (sort a) [1..]
    solve [] = 0
    solve (x:xs) = if (po ! x + meu ! x) `mod` 2 == 0
      then solve xs
      else 1 + solve xs
  print $ solve a `div` 2


Measured memory_bytes: 47484
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){

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

    int cost; 
    int mini = 10000000;
    for (int z = -100; z <= 100 ; z++){
        
        cost = 0;  
        
        for (int i = 0; i <= N-1 ; i++){
            int t = a[i] - z;
            cost += t * t;
        }
        mini  = min(cost,mini);
    }

    cout << mini << endl;
}

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

using namespace std;
typedef long long ll;
int MAXN = 100005;

vector<bool> sieve(int n) {
  vector<bool> is_prime(n, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i * i <= n; ++i) {
    if (is_prime[i]) {
      for (int j = i * i; j <= n; j += i) is_prime[j] = false;
    }
  }
  return is_prime;
}

int main() {
  int x;
  scanf("%d", &x);
  vector<bool> is_prime = sieve(MAXN);

  for (int i = x; i < MAXN; ++i) {
    if (is_prime[i]) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}




Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

a,b,c,d,e,f = m()

wa = [0 for i in range(f+1)]
su = [0 for i in range(f+1)]

wa[0] = 1
su[0] = 1


for i in range(f//100 + 1):
    if i*100 + a*100 <= f:
        wa[i*100 + a*100] = max(wa[i*100 + a*100],wa[i*100])
    if i*100 + b*100 <= f:
        wa[i*100 + b*100] = max(wa[i*100 + b*100],wa[i*100])

for i in range(f + 1):
    if i+c <= f:
        su[i + c] = max(su[i + c],su[i])

    if i+d <= f:
        su[i + d] = max(su[i + d],su[i])


#po = [[0,a,0],[0,b,0]]
po = []

for i in range(1,f+1):
    for j in range(f+1):
        if i+j <= f and wa[i] and su[j] and (i //100) * e >= j:
            po.append([(100*j)/(i+j),i+j,j])

po.sort(reverse = True)


print(po[0][1],po[0][2])

Measured memory_bytes: 4976
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;
const LL mod = 1e9 + 7;

int main()
{
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		if(b - a == c - b) printf("YES\n");
		else printf("NO\n");
	}
    return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int a, b, c;
  a = z;
  b = x;
  c = y;
  cout << a << " "<< b << " "<< c << endl;

  }

Measured memory_bytes: 256
S = str(input())
T = str(input())
ans = []
for i in range(len(S) - len(T) + 1):
  for j in range(len(T)):
    if S[i+j] not in ('?', T[j]):
      break
  else:
    U = S[:i] + T + S[i+len(T):]
    ans.append(U.replace('?', 'a'))
print(min(ans) if ans else 'UNRESTORABLE')

Measured memory_bytes: 3064
INF = 10000
n,k = map(int,input().split())
stair = list(map(int,input().split()))
dp = [0] *n
for i in range(1,n):
    dp[i] = dp[i-1]+abs(stair[i]-stair[i-1])
    for j in range(1,k+1):
        if(i - j >= 0):
            # print(i,i-j)
            dp[i] = min(dp[i], dp[i-j]+abs(stair[i]-stair[i-j]))
        # print(dp)



print(dp[-1])


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

int main(){
  string N;
  cin>>N;
  
  string ans="Yes";
  
  bool frag=false;
  
  if(N[0]=='7')frag=true;
  if(N[1]=='7')frag=true;
  if(N[2]=='7')frag=true;
  
  if(frag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }



}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).rbegin(), (x).rend()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    int n = s.size();
    vec<int> xs, ys;
    bool forx      = true;
    bool firstTurn = true;
    int now        = 0;
    for (auto e : s) {
        if (e == 'T') {
            if (firstTurn) x -= now;
            if (!firstTurn && forx && now != 0) {
                xs.push_back(now);
            } else if (!firstTurn && !forx && now != 0) {
                ys.push_back(now);
            }
            firstTurn = false;
            forx      = !forx;
            now       = 0;
        } else {
            now++;
        }
    }
    if (firstTurn) x -= now;
    if (!firstTurn && forx && now != 0) {
        xs.push_back(now);
    } else if (!firstTurn && !forx && now != 0) {
        ys.push_back(now);
    }

    vec<vec<bool>> dpx(2, vec<bool>(2*n,false));
    vec<vec<bool>> dpy(2, vec<bool>(2*n,false));
    dpx[0][0] = true;
    dpy[0][0] = true;
    for (auto e : xs) {
        for (int j = 0; j <= 2*n; ++j) {
            dpx[1][j] = (dpx[0][abs(j - e)] || dpx[0][j + e]);
        }
        dpx[0] = dpx[1];
        dpx[1] = vec<bool>(2*n,false);
    }
    for (auto e : ys) {
        for (int j = 0; j <= 2*n; ++j) {
            dpy[1][j] = (dpy[0][abs(j - e)] || dpy[0][j + e]);
        }
        dpy[0] = dpy[1];
        dpy[1] = vec<bool>(2*n,false);
    }
    if (dpx[0][abs(x)] && dpy[0][abs(y)]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

from itertools import accumulate
 
def execute():
    s = readStringList()
    if s[-1] == 's':
        s += ['e','s']
    else:
        s.append('s')
    print("".join(s))
    
 
if __name__ == "__main__":
    execute()



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

int main(){
  while(true){
    string s1;
    cin >> s1;

    if(s1==".")
     break;

    string s2;
    cin >> s2;

    if(s1==s2){
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while(true){
      size_t d1b = t1.find('\"');
      if(d1b==string::npos)
       break;
      t1.replace(d1b, 1, "@");

      size_t d1e = t1.find('\"');
      t1.replace(d1e, 1, "@");

      size_t d2b = t2.find('\"');
      if(d2b==string::npos)
       break;
      t2.replace(d2b, 1, "@");

      size_t d2e = t2.find('\"');
      t2.replace(d2e, 1, "@");

      string u1 = s1;
      u1.replace(d1b+1, d1e-d1b-1, "");
      string u2 = s2;
      u2.replace(d2b+1, d2e-d2b-1, "");

      if(u1==u2){
        t1 = u1;
        t2 = u2;
        break;
      }
    }

      if(t1==t2){
        cout << "CLOSE" << endl;
      }
      else{
        cout << "DIFFERENT" << endl;
      }
    }
    return 0;
}



Measured memory_bytes: 3212
n, m = gets.chomp.split.map(&:to_i)
parent = (0...n).to_a
m.times{
    a, b = gets.chomp.split.map{|x| x.to_i - 1}
    pa = a
    pa = parent[pa] while pa != parent[pa]
    pb = b
    pb = parent[pb] while pb != parent[pb]
    x, y = [pa, pb].minmax
    parent[y] = x
}
n.times{|a|
    pa = a
    pa = parent[pa] while pa != parent[pa]
    parent[a] = pa    
}
h = Hash.new(0)
parent.each{|p| h[p] += 1}
shi = mura = 0
h.each{|k, v|
    if v == 1
        mura += 1
    else
        shi += 1
    end
}
puts (shi - mura).abs


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 8010;
string S;
int x,y;
bool p[MC],q[MC],t[MC];

int main(){
	cin >> S;
	cin >> x >> y;
	int n = S.size();
	int z = 0;
	while(z < n && S[z] == 'F') ++z;
	x -= z;
	if(abs(x)>MC) return cout << "No" << endl , 0;
	S += "T";
	p[0] = q[0] = 1;
	int r = 0;
	bool b = 0;
	for(; z <= n ; ++z){
		if(S[z] == 'T'){
			if(r){
				fill(t,t+MC,0);
				repp(i,0,z){
					if(!(b?q:p)[i]) continue;
					t[i+r] = t[abs(i-r)] = 1;
				}
				swap(t,b?q:p);
			}
			r = 0;
			b = !b;
		} else {
			++r;
		}
	}
	cout << (p[abs(x)] && q[abs(y)] ? "Yes" : "No") << endl;
	return 0;
}


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

int dig(int A){
    int cnt = 1;
    while(A/10){
        A /= 10;
        cnt++;
    }
    //cout << cnt<<endl;
    return cnt;
}

int func(int A, int B){
    return max(dig(A),dig(B));
}

int main(){
    long long N;
    cin >> N;
    int rt =int(sqrt(N) + 1);
    int m = rt;
    rep(i,rt+1){
        if(N % (i+1) == 0){
            m = min(func(N / (i+1), (i+1)), m);
        }
    }
    cout << m << endl;
    //cout <<  (flag ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
//warota!w

#include <stdio.h>
 
int N = 100;
 
void out(int A[], int n, int count){
  int i;
  for (i=0;i<n;i++){
    if (i>0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", count);
}
void swap(int *x, int *y){
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
}

void bubbleSort(int* A, int n){
  int j, count=0, flag=1;
  while(flag){
  	flag = 0;
  	for(j=n-1;j>=1;j--){
  		//printf("test1 j=%d\n", j);
  		//printf("j-1 = %d j =%d \n", A[j], A[j-1]);
  		if (A[j] < A[j-1]){
  			//printf("swap\n");
  			swap(&A[j], &A[j-1]);
  			flag=1; count++;
  		}
  	}
  }
  out(A, n, count);
}
 
int main(void){
  int n, i;
  int A[N+1];
  scanf("%d", &n);
 
  for (i=0;i<n;i++) scanf("%d", &A[i]); //data input
  bubbleSort(A, n);
 
  return 0;
}

Measured memory_bytes: 604
N = int(input())
dp = [0] * 100050
money = set()
i = 0
while(6**i < 10**5):
    money.add(6**i)
    i += 1
i = 0
while(9**i < 10**5):
    money.add(9**i)
    i += 1
mm = []
for i in range(1, 10**5+1):
    if i in money:
        mm.append(i)
    dp[i] = min([dp[i-k] for k in mm]) + 1

print(dp[N])


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=2000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
string t[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    rep(i,7){
        if(t[i]==s){
            cout<<7-i<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
N = int(input())
T = list(map(int,input().split()))
M = int(input())

result = []
for i in range(M):
  cnt = 0
  P, X = map(int,input().split())
  for j in range(N):
    if(P-1 == j):
      cnt += X
    else:
      cnt += T[j]
  result.append(cnt)
for r in result:
  print(r)

Measured memory_bytes: 3060
#include<cstdio>
using namespace std;
int main()
{
	int ji = 0,n;
	scanf("%d",&n);
	int x;
	for(int i = 1;i <= n;++i)
	{
		scanf("%d",&x);
		if(x & 1)
			++ji;
	}
	if(ji & 1)
		printf("NO");
	else
		printf("YES");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>

#define rep(i,s,N) for(int i=s; i<N; ++i)
#define N_MAX 1000000

template<typename T>
void print(T *x, int n, std::string sep=" ") {
	rep(i,0,n) {
		if (i==0) {
			std::cout << x[i];
			continue;
		}
		std::cout << sep << x[i];
	}
	std::cout << std::endl;
}

// 6:15
// 6:49 うまくいきそうな感触, algorithm の直観的な理解
// 大きく動かす, 比較対象位置は粗から密へ, O(log(n))で. n = 2^k, log(n) = k log(2) 
// nが奇数の場合どうするか.
// 例: n=5
// 3 1 4 5 2
// 3 - 5
// 1 - 2
// 4 - ?
// 比較しない要素が出るのはまずい. devide and conquer であるから, 各分割で漏れなく処理する必要がある.
// (n-1) / 2 を開始index かつ, interval lengthとすればよい.
//

template<typename U>
int sort_by_insertion(U *x, int n, int g) {
	int cnt = 0;
	for (int i=g; i<n; ++i) {
		U v = x[i];
		int j = i-g;
		while (j>=0 && x[j] > v) {
			x[j+g] = x[j];
			j = j-g;
			cnt++;
		}
		x[j+g] = v;
	}
	return cnt;
}

template<typename U>
std::tuple<int, std::vector<int> > sort_by_shell(U *x, int n) {
	std::vector<int> G;
	int cnt = 0;
	//int g = n / 2; // たぶんここがなにが想定と違うらしい.
	int g = n;
	while (g > 0) {
		G.push_back(g);
		g /= 2;
	}
	//print(G.data(), G.size());
	for (int i=0; i<G.size(); ++i) {
		g = G[i];
		cnt += sort_by_insertion(x, n, g);
	}
	std::tuple<int, std::vector<int> > ret = std::make_tuple(cnt, G);
	return ret;
}

using namespace std;

int main() {
	int N;
	cin >> N;
	int values[N_MAX];
	rep(i,0,N) {
		scanf("%d", &values[i]);
	}
	auto ret = sort_by_shell(values, N);
	int cnt = get<0>(ret);
	vector<int> G = get<1>(ret);
	
	cout << G.size() << endl;
	print(G.data(), G.size());
	cout << cnt << endl;
	print(values, N, "\n");
}



Measured memory_bytes: 7120
n,d = list(map(int, input().split()))
x = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1,n):
        z = 0
        for k in range(d):
            z += (x[i][k] - x[j][k])**2
        if z**0.5 == (z**0.5)//1:
            ans += 1

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  VI a(n); for (int i = 0; i < n; i++) cin >> a[i];
  cout << (n - 1 + k - 2) / (k - 1) << '\n';
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  string s;
  cin>>s;
  cout<<s;

  if(s[s.size()-1]=='s')
    cout<<"es"<<endl;
  else
    cout<<"s"<<endl;
}



Measured memory_bytes: 3652
package main

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

func main() {
	N := readInt()

	if N == 2 {
		// K = 2
		fmt.Println(1)
		return
	}

	r := int(math.Sqrt(float64(N)))
	// K = N - 1, N
	result := 2
	for K := 2; K <= r; K++ {
		t := N
		for t >= K && t%K == 0 {
			t /= K
		}
		if t%K == 1 {
			result++
		}

		if (N-1)%K != 0 {
			continue
		}
		k := (N - 1) / K
		if k == K {
			continue
		}
		t = N
		for t >= k && t%k == 0 {
			t /= k
		}
		if t%k == 1 {
			result++
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


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


int main(){
    int64_t n, k;
    cin >> n >> k;
    vector<int64_t> H(n);
    for (int64_t i=0; i<n; i++){
        int64_t h;
        cin >> h;
        H.at(i) = h;
    }
    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());
    
    int64_t ans = 0;
    for (int64_t i=k; i<n; i++){
        ans += H.at(i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792