akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
int map[100][100];
int n;
int d[100];
int color[100];
int INF = 1000000;
void solve() {
	int all = 1;
	d[0] = 0;
	color[0] = 1;
	vector<int>v;
	v.push_back(0);
	while (all != n)
	{
		int min = INF;
		int k;
		for (int i = 0; i < v.size(); i++) {
			for (int j = 0; j < n; j++) {
				if (!color[j] && d[v[i]] + map[v[i]][j] <= d[j]) {
					d[j] = d[v[i]] + map[v[i]][j];
					if (d[j] < min) {
						min = d[j];
						k = j;
					}
				}
			}
		}
		color[k] = 1;
		v.push_back(k);
		all++;
	}
}
int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		d[i] = INF;
		for (int j = 0; j < n; j++) map[i][j] = INF;
	}
	for (int i = 0; i < n; i++) {
		int k,all;
		cin >> k>>all;
		for (int j = 0; j < all; j++) {
			int a, b;
			cin >> a >> b;
			map[k][a] = b;
		}
	}
	solve();
	for (int i = 0; i < n; i++) {
		cout << i<<" "<<d[i]<<endl;
	}
}


Measured memory_bytes: 3176
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


double dp[333][333][333];


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(12);
  std::cerr << std::fixed << std::setprecision(12);

  int N, a[333], c[4] = {0}, C = 0;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> a[i];

    c[a[i]] ++;
  }

  memset(dp, 0, sizeof(dp));
  
  for (int k = 0; k <= N; k ++)
    for (int j = 0; j <= N; j ++)
      for (int i = 0; i <= N; i ++) {
        int s = i + j + k, l = N - s;

        if (s > N)
          continue;
        
        if (l) {
          int ll = l - 1, ii = i + 1, jj = j, kk = k, ss = ii + jj + kk;
          
          double p = 1. * ss / N, e = p ? (1 - p) / p : 0.0;
          
          dp[i + 1][j][k] += (1 + e + dp[i][j][k]) * ii / ss;
        }
        
        if (i) {
          int ll = l, ii = i - 1, jj = j + 1, kk = k, ss = ii + jj + kk;

          double p = 1. * ss / N, e = p ? (1 - p) / p : 0.0;
          
          dp[i - 1][j + 1][k] += (1 + e + dp[i][j][k]) * jj / ss;
        }
        
        if (j) {
          int ll = l, ii = i, jj = j - 1, kk = k + 1, ss = ii + jj + kk;

          double p = 1. * s / N, e = p ? (1 - p) / p : 0.0;
          
          dp[i][j - 1][k + 1] += (1 + e + dp[i][j][k]) * kk / ss;
        }
      }

  std::cout << dp[c[1]][c[2]][c[3]] << std::endl;
    
  return 0;
}


Measured memory_bytes: 288768
<?php
  fscanf(STDIN, "%d", $N);
  $n_arr = array();
  $n_arr = explode(" ", fgets(STDIN));

  $ans = 0;
  $CurMin = INF;

  for($i=0;$i<$N;$i++){
	$CurMin = min($CurMin, $n_arr[$i]);
    if($CurMin == $n_arr[$i]){
      $ans++;
    }
  }

  echo $ans;
  ?>

Measured memory_bytes: 18936
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    if (a%2==0 || b%2==0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int l,r,d;
void input(){
    fast_io();
    cin >> l >> r >> d;
}

int solve(){
    int ans = 0;
    for (int i = l; i <= r; i++)
    {
        if(i%d==0) ans++;
    } 
    cout << ans << endl;
    
    return 0;
}   

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

Measured memory_bytes: 3644
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a

         
def nfac(n):
    if n % 2 == 0:
        while n % 2 == 0:
            n //= 2
        r = 2
    else:
        r = 1

    p = 3
    while p*p <= n:
        if n % p == 0:
            n //= p
            r += 1
            while n % p == 0:
                n //= p
        p += 2
    if n > 1:
        r += 1
    return r

         
a, b = map(int, input().split())
print(nfac(gcd(a,b)))

Measured memory_bytes: 38512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, D;
  cin >> H >> W >> D;
  int A[H][W];
  P num[H*W+1];
  FOR(i,0,H) {
    FOR(j,0,W) {
      cin >> A[i][j];
      num[A[i][j]] = P(i, j);
    }
  }
  int cost[H*W+1];
  FOR(i,1,D+1) {
    int x = i;
    cost[i] = 0;
    int cnt = 1;
    while(x + D <= H * W) {
      // x -> x + D
      cost[x+D] = cost[x] + abs(num[x].first-num[x+D].first) + abs(num[x].second-num[x+D].second);
      x += D;
      cnt++;
    }
  }
  int Q; cin >> Q;
  
  FOR(i,0,Q) {
    int L, R; cin >> L >> R;
    cout << cost[R] - cost[L] << endl;
  }
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(){
int n,k;
double sum=0;
double buf;
scanf("%d %d",&n,&k);
for(int i=1;i<=n;i++){
int cnt=0;
buf=1.0;
int seki=i;
while(seki<k){
seki*=2;
buf*=0.5;
}
sum+=buf;
}
sum*=1.0/n;
printf("%.12f",sum);

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int> a;
  a.resize(n);
  int i,j;
  for(i=0;i<n;i++)
    cin>>a[i];
  vector<int> od;
  od.resize(100001);
  vector<int> ev;
  ev.resize(100001);
  for(i=0;i<n;i=i+2)
    ev[a[i]] += 1;
  for(i=1;i<n;i=i+2)
    od[a[i]] += 1;
  int od1 = 0;
  int co1 = 0;
  int od2 = 0;
  int co2 = 0;
  int ev1 = 0;
  int ce1 = 0;
  int ev2 = 0;
  int ce2 = 0;
  for(i=1;i<=100000;i++)
  {
    if(od[i]>co1)
    {
      od2 = od1;
      co2 = co1;
      od1 = i;
      co1 = od[i];
    }
    else if(od[i]>co2)
    {
      od2 = i;
      co2 = od[i];
    }
  }
  for(i=1;i<=100000;i++)
  {
    if(ev[i]>ce1)
    {
      ev2 = ev1;
      ce2 = ce1;
      ev1 = i;
      ce1 = ev[i];
    }
    else if(ev[i]>ce2)
    {
      ev2 = i;
      ce2 = ev[i];
    }
  }
  int ans = 0;
  if(od1!=ev1)
    ans = n - co1 - ce1;
  else
    ans = min(n-co1-ce2,n-co2-ce1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,temp;
  vector<int>v;
  cin  >> n;
  char c;
  while(n--){
    cin >> c;
    if(c == '0'){
      int x;
      cin >> x;
      v.push_back(x);
    }else if(c == '1'){
      int p;
      cin >> p;
      cout << v[p] << endl;
    }else if(c == '2'){
      v.pop_back();
    }
  }
  return 0;
}


Measured memory_bytes: 3832
import os
import math

def main():
	a,b,c,d = map(int, input().split())
	takahasi = math.ceil(a/d)
	aoki = math.ceil(c/b)
	
	if aoki <= takahasi:
		print("Yes")
	else:
		print("No")

if __name__ == "__main__":
	main()


Measured memory_bytes: 9140
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, w := scanInt(), scanInt()
	ws := make([]int, n)
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		ws[i] = scanInt()
		vs[i] = scanInt()
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, w+1)
	}

	for i := 0; i < n; i++ {
		for sumW := 0; sumW <= w; sumW++ {
			if sumW-ws[i] >= 0 {
				dp[i+1][sumW] = max(dp[i+1][sumW], dp[i][sumW-ws[i]]+vs[i])
			}

			dp[i+1][sumW] = max(dp[i+1][sumW], dp[i][sumW])
		}
	}

	fmt.Println(dp[n][w])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

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

        int ans=1;
        for(int i = 1; i < n; i++){
                for(int j = 0; j < i; j++){
                        if ( h[j] > h[i]){
                                break;
                        }
                        if( j == i -1){
                                ans++;
                        }
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 256
/*----------------------|
/ Author : Ashraf Tasin |
/ Date   :   08.08.19   |
/----------------------*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define all v.begin(),v.end()
#define flash ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define db double
#define endl "\n"
#define mnm pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>
#define show for(int i=0;i<v.size();i++) cout << v[i] << " ";
#define eps 1e-6
#define mx 100008
using namespace std;

int dx[]={-1,1,-1,0,1,-1,0,1};
int dy[]={0,0,-1,-1,-1,1,1,1};

/*Knight Moves

int dx[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int dy[] = { 1, 2, 2, 1, -1, -2, -2, -1 }; */

/*Normal Moves

int x[] = {0, 1, 0, -1};
int y[] = {-1, 0, 1, 0}; */


int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    flash

    int a,b;
    cin >> a >> b;
    
    for(int i=b-a+1;i<b;++i) cout << i << " ";
    for(int i=b;i<b+a;++i) cout << i << " ";
    cout << endl;
    

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;

char ar[100][100];


int main()
{
    idfc;

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

    int i,j;
    for(i=0;i<n;i++)for(j=0;j<m;j++)cin>>ar[i][j];

    int a=1<<n;
    int b=1<<m;
    int x,y;
    int ans=0;
    int c;
    for(i=0;i<a;i++)
    {
        for(j=0;j<b;j++)
        {
            c=0;
            for(x=0;x<n;x++)
            {
                for(y=0;y<m;y++)
                {
                    if((i&(1<<x))||(j&(1<<y)))continue;
                    if(ar[x][y]=='#')c++;
                }
            }
            if(c==k)ans++;
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mk make_pair
#define fi first
#define lb lower_bound
#define test ll int t;cin>>t;while(t)
#define se second
using namespace std;

int main(){
    int  n,x,t;
    cin>>n>>x>>t;
    int ans=t*(n/x);
    if(n%x!=0)ans+=t;
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long

using namespace std;

int main(){
    int n, a, b, j;
    ll k;

    cin >> n >> k;
    vector<ll> v(100001);

    for(int i = 0; i < n; i++){
        cin >> a >> b;
        v[a] += b;
    }

    j = 0;
    while(1){
        if(v[j] != 0) k -= v[j];
        if(k <= 0) break;
        j++;
    }

    cout << j;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
typedef long long ll;

ll k, t, a[51];

int main()
{
	cin >> k;
	t = k/50;
	cout << 50 << endl;
	fo(i,0,49) a[i] = i+t;
	fo(i,0,(k%50)-1) a[50-i-1] ++;
	fo(i,0,49) cout << a[i] << ' ';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#define LEN 100
#define BASE 25

using namespace std;

int maps[LEN][LEN];
int off[LEN][LEN];

int checker[4];
int ncheck[4];

map<int, int> points[LEN];

class State {
public:
	char where;
	int enemy;
	int budget;
	int check[4];
	State() {check[0]=0;check[1]=0;check[2]=0;check[3]=0;}
	State(char w, int e, int b ) {
		where = w;
		enemy = e;
		budget = b; 
		check[0] = ncheck[0];
		check[1] = ncheck[1];
		check[2] = ncheck[2];
		check[3] = ncheck[3];
	}
};

bool operator< ( const State& a, const State& b) {
	if( a.enemy == b.enemy )
		return a.budget < b.budget;
	return a.enemy < b.enemy;
}

bool operator> ( const State& a, const State& b) {
	if ( a.enemy == b.enemy )
		return a.budget > b.budget;
	
	return a.enemy > b.enemy;
}

priority_queue<State, vector<State>, greater<State> > status;

inline void copy ( State now ) {
	checker[0] = now.check[0];
	checker[1] = now.check[1];
	checker[2] = now.check[2];
	checker[3] = now.check[3];
}

inline void ncopy ( ) {
	ncheck[0] = checker[0];
	ncheck[1] = checker[1];
	ncheck[2] = checker[2];
	ncheck[3] = checker[3];
}

inline bool check ( int i ) {
	return 0 == ((1<<(i%25)) & checker[i/BASE]);
}

inline void add ( int i ) {
	ncheck[i/BASE] = ((1<<(i%25)) | checker[i/BASE]);
}

inline void insert ( int i, int e, int b ) {
	
	map<int,int>::iterator itr = points[i].find(e);
	if ( itr == points[i].end() ) {
		points[i][e] = b;
		status.push(State(i,e,b));
	} else if ( (*itr).second < b ) {
		(*itr).second = b;
		status.push(State(i,e,b));
	}
}

int main () {


	while ( true ) {
		int n,m,l;
		cin >> n >> m >> l;

		if ( n == 0 )
			break;

		for ( int i=0; i<n; i++ ) {
			for ( int j=0; j<n; j++ ) {
				maps[i][j] = -1;
				off[i][j] = 0;
			}
			points[i].clear();
		}

		for ( int i=0; i<m; i++ ) {
			int a,b,d,e;
			cin >> a >> b >> d >> e;

			maps[a-1][b-1] = maps[b-1][a-1] = d;
			off[a-1][b-1] = off[b-1][a-1] = e;
		}

		for ( int i=0; i<4; i++ ) {
			ncheck[i] = 0;
			checker[i] = 0;
		}

		status = priority_queue<State, vector<State>, greater<State> >();

		/*
		while( !status.empty() ) {
			status.pop() ;
		}	
		*/

		ncheck[0] = 1;
		status.push(State(0,0,l));
		int count = 0;
		while(!status.empty()) {
			State now = status.top();
			status.pop();
			if ( now.where == n-1 ) {
				cout << now.enemy << endl;
				break;
			}

			copy(now);

			for ( int i=0; i<n; i++ ) {
				if ( maps[now.where][i] > 0 ) {
					if ( check( i ) ) {
						ncopy();
						add(i);
						int e, b;
						if ( off[now.where][i] == 0 ) {
							e = now.enemy;
							b = now.budget;
							insert(i,e,b);
						} else {
							if ( now.budget - maps[now.where][i] >= 0 ) {
								e = now.enemy;
								b = now.budget - maps[now.where][i];
								insert(i,e,b);
							}
							e = now.enemy + off[now.where][i];
							b = now.budget;
							insert(i,e,b);
						}
					}
				}
			}
		}
	}
}

		

Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
int ch[26][100003];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	string s;
	cin >> s;
	REP(i,s.size()){
		ch[s[i]-'a'][i]++;
	}
	REP(chi,26){
		REP(i,s.size()){
			if(ch[chi][i] && ch[chi][i+1]){
				cout << i+1 << " " << i+2 << endl;
				return 0;
			}
			if(ch[chi][i] && ch[chi][i+2]){
				cout << i+1 << " " << i+3 << endl;
				return 0;
			}
		}
	}
		cout << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 10576
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, m;cin>>n>>m;
  vector<bool> ac(n, false);
  vector<int> wa(n);
  rep(i, m){
  	int p;string s;cin>>p>>s;p--;
    if(s=="AC")ac[p]=true;
    else if(!ac[p])wa[p]++;
  }
  int correct=0, penalty=0;
  rep(i, n){
  	if(!ac[i])continue;
    correct++;
    penalty += wa[i];
  }
  cout<<correct<<" "<<penalty<<endl;
  return 0;
}



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

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

  map<string, int> mp;
  for (ll i = 0; i < s.size(); i++) {
    for (ll j = 1; j <= min(k, (ll)(s.size() - i)); j++) {
      mp[s.substr(i, j)]++;
    }
  }

  int cnt = 1;
  for (auto x : mp) {
    if (cnt == k) {
      cout << x.first << endl;
      return 0;
    }
    cnt++;
  }
  return 0;
}


Measured memory_bytes: 4756
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int a, b;
    string n, k, u;
    cin >> n >> k;
    cin >> a >> b;
    cin >> u;
    if (u == n)
        a--;
    else if (u == k)
        b--;
    cout << a <<' '<< b;
}


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

long long mmax(long long x, long long y) {
	if (x > y) return x;
	else return y;
}


int main() {
	int n, w;
	cin >> n >> w;
	Graph A(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		A[i].push_back(a);
		A[i].push_back(b);
	}

	long long dp[109][100009];
	rep(i, 109) rep(j,100009) dp[i][j] = -1;
	rep(i, 100009) dp[0][i] = 0;
	rep(i, n) {
		rep(j, w+1) {
			dp[i+1][j] = dp[i][j];
			if (j >= A[i][0]) {
				long long temp;
				temp = dp[i][j - A[i][0]] + A[i][1];
				dp[i+1][j] = mmax(dp[i+1][j], temp);
			}
		}
	}

	//rep(i, w + 1) cout << dp[n][i] << endl;
	long long ans = dp[n][w];
	cout << ans << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

const int LIM=1000000;

int N;
int A[2222222];
int cnt[LIM+1];

signed main(){
	cin>>N;
	rep(i,N){
		cin>>A[i];
		cnt[A[i]]++;
	}

	for(int i=1;i<=LIM;i++){
		for(int j=i+i;j<=LIM;j+=i)cnt[j]+=cnt[i];
	}

	int ans=0;
	rep(i,N){
		if(cnt[A[i]]==1)ans++;
	}

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


Measured memory_bytes: 12960
// contest.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "bits/stdc++.h"
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#define YES "Yes"
#define NO "No"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef pair < ut, ut > pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5 * 1e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
VI edges[SIZE];
////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////
//LL L;
LL exist[2][SIZE];
bool reached[SIZE];
string s;
void init() {

}
LL solve2() {
	
	return 0;
}
LL solve() {
	cin >> N >> M;
	cin >> s;
	s = "1" + s;
	int a, b;
	REP(i, M) {
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
		exist[s[a] - 'A'][b]++;
		exist[s[b] - 'A'][a]++;
	}
	queue<int> qu;
	EFOR(i, 1, N) {
		if (!exist[0][i] or !exist[1][i]) {
			qu.push(i);

			reached[i] = true;
		}
	}
	int ans = 0;
	while (!qu.empty()) {
		int now = qu.front();
		qu.pop();
		ans++;
		for (auto next : edges[now]) {
			if (reached[next]) continue;
			exist[s[now] - 'A'][next]--;
			if (exist[s[now] - 'A'][next] == 0) {
				qu.push(next);
				reached[next] = true;
			}
		}
	}
	return ans!=N;
}
signed main() {
	YESNO;
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;


signed main() {
    int N;
    cin >> N;
    if (N % 2 == 0)N -= 1;
    cout << N / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
import qualified Control.Arrow         as Arrow
import qualified Data.ByteString.Char8 as BSC8
import qualified Data.Vector.Unboxed   as VU

which :: a -> a -> Bool -> a
which a b p = if p then a else b

getI :: BSC8.ByteString -> Maybe (Int, BSC8.ByteString)
getI = fmap (Arrow.second BSC8.tail) . BSC8.readInt
getAB :: IO (Int, Int)
getAB = (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 getI <$> BSC8.getLine

main :: IO ()
main = do
  (a, v) <- getAB
  (b, w) <- getAB
  t <- readLn :: IO Int
  let d  = abs $ a - b
  let v' = max 0 $ v - w
  putStrLn $ which "YES" "NO" $ d <= v' * t

Measured memory_bytes: 4196
class Heap
  attr_reader :size
  def initialize
    @heap = []
    @size = 0
  end
  def sum
    @heap.inject(:+)
  end
  def push(n)
    i = @size
    while i > 0
      pid = (i - 1) / 2
      break if n >= @heap[pid]
      @heap[i] = @heap[pid]
      i = pid
    end
    @heap[i] = n
    @size += 1
  end
  def pop
    top = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size
      cid1 = i * 2 + 1
      cid2 = cid1 + 1
      if cid2 < @size && @heap[cid2] < @heap[cid1]
        cid1 = cid2
      end
      break if @heap[cid1] >= n
      @heap[i] = @heap[cid1]
      i = cid1
    end
    @heap[i] = n
    top
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = Heap.new()
a.map{|x| b.push(-x)}
m.times do
  c = b.pop
  b.push(-(-c / 2))
end
puts -b.sum

Measured memory_bytes: 10324
from copy import copy

def f(N,s):
    if N==0:
        return 0

    D=len(str(N))
    return (N//(10**(D-s)))%10

N,M=map(int,input().split())

if N==1:
    T=[x for x in range(10)]
else:
    T=[x for x in range(10**(N-1),10**N)]

for _ in range(M):
    s,c=map(int,input().split())
    U=copy(T)
    for a in U:
        if f(a,s)!=c:
            T.remove(a)

if T:
    print(min(T))
else:
    print(-1)


Measured memory_bytes: 69400
my$n = <>;
my@v = split(" ", <>);

my@v1 = sort {$a<=>$b} @v;
while(scalar(@v1) != 0) {
  my$a=shift(@v1);
  my$b=shift(@v1);
  my$c=shift(@v1);
  if ($c==0) {
    print (($a+$b)/2);
    last;
  }
  if ($a < $b) {
    if ($b<$c) {
      unshift(@v1, ($a+$b)/2, $c);
    }
    else {
      unshift(@v1, ($a+$c)/2, $b);
    }
  }
  else {
    if ($a<$c) {
      unshift(@v1, ($a+$b)/2, $c);
    }
    else {
      unshift(@v1, ($b+$c)/2, $a);
    }
  }
  
}


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

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i, m, n) for(int i = (int)m; i < (int)n; i++)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;


/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    ll n, answer = 1; cin >> n;
    rep2(i, 1, n+1) {
        answer *= i;
        answer = answer % 1000000007;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
s = input()
k = int(input())

if len(set(s)) == 1:
    print((len(s)*k)//2)
    exit()

ss = s + s

shoko = 0
prev = ''
cnt = 0
for i in range(len(s)):
    if s[i] == prev:
        cnt += 1
    else:
        shoko += cnt // 2
        cnt = 1
    prev = s[i]
shoko += cnt // 2

kosa = 0
prev = ''
cnt = 0
for i in range(len(ss)):
    if ss[i] == prev:
        cnt += 1
    else:
        kosa += cnt // 2
        cnt = 1
    prev = ss[i]
kosa += cnt // 2
kosa -= shoko

print(shoko + (k-1)*kosa)

Measured memory_bytes: 38256
N, A, B = map(int, input().split())

S = input()

total = 0
abroad = 0

for s in S:
  if s == 'a' and total < (A+B):
    print('Yes')
    total += 1
  elif s == 'b' and total < (A+B) and abroad < B:
    print('Yes')
    total += 1
    abroad += 1
  else:
    print('No')

Measured memory_bytes: 9296
#include <stdio.h>
int main()
{
	int a,b,c,i,ans=0;
	scanf("%d %d %d",&a,&b,&c);
	int s[a];
	for(i=0;i<a;i++)
	{
		scanf("%d",&s[i]);
		if(s[i]<b||s[i]>=c)
			ans++;
	}
	printf("%d\n",ans);
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
int N;
ll A[200100];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    ll sum = 0, squareSum = 0;

    for(int i=0;i<N;++i){
        sum = (sum + A[i]) % MOD;
        squareSum = (squareSum + A[i] * A[i] % MOD) % MOD;
    }

    ll res = (sum * sum % MOD + MOD - squareSum) % MOD * ((MOD + 1) / 2) % MOD;
    std::cout << res << std::endl;
}


Measured memory_bytes: 5172
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
long rec(long X){
  if(X==0)return 0;
  if(X==1)return 1;
  return 2*rec(X/2)+1;
}
inline void solve(void){
  long H;in(H);
  out(rec(H));
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

int main() {
  int N, l, r, sum=0;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    sum += (r - l + 1);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
l = [i+1 for i in range(N)]
for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for j in range(d):
    if A[j] in l:
      l.remove(A[j])
print(len(l))

Measured memory_bytes: 9188
#include "iostream"
using namespace std;

int main() {
	int n, k, a;
	int d[10];
	cin >> n >> k;
	for (int i = 0; i < 10; i++)
		d[i] = true;
	for (int i = 0; i < k; i++) {
		cin >> a;
		d[a] = false;
	}
	while (true) {
		a = n;
		while(true){
			if (a == 0) {
				cout << n << endl;
				return 0;
			}
			if (d[a % 10] == false)break;
			a = a / 10;
		}
		n++;
	}
	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int p = 0;
    vector<int> a(n+1,0);
    for (int i = 0;i < n;++i) {
        if (s[i] == '<') a[i+1] = a[i]+1;
    }
    for (int i = n-1;i >= 0;--i) {
        if (s[i] == '>') a[i] = max(a[i],a[i+1]+1);
    }
    ll ans = 0;
    for (int i = 0;i < n+1;++i) ans += a[i];
    cout << ans << endl;
    // p_ary(a,0,n+1);
}

Measured memory_bytes: 2820
#include <stdio.h>

int main(){
  char s[4];
  scanf("%s", s);

  if(s[2] == '\0'){ // 2文字の場合
    printf("%s", s);
  }
  else{             // 3文字の場合
    printf("%c", s[2]);
    printf("%c", s[1]);
    printf("%c", s[0]);
  }
  return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DModSum solver = new DModSum();
        solver.solve(1, in, out);
        out.close();
    }

    static class DModSum {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextInt();
            out.println(n * (n - 1) / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22612
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a[7];
	rep(i, 7) cin>>a[i];
	swap(a[2], a[4]);
	swap(a[1], a[3]);
	ll res = a[3];
	if(a[0]%2+a[1]%2+a[2]%2>=2 && a[0]&&a[1]&&a[2]){
		res += 3;
		a[0]--;
		a[1]--;
		a[2]--;
	}
	rep(i, 3){
		res += a[i]/2*2;
		a[i] %= 2;
	}
	if(a[0]&&a[1]&&a[2]) res += 3;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n;
	cin >> n;
	vector < int > v(n);
	int neg = 0;
	ll sum_p = 0, sum_n = 0;
	for (auto &el: v) {
		cin >> el;
		if (el >= 0) {
			sum_p += el;
		} else {
			++neg;
			sum_n -= el;
		}
		el = abs(el);
	}
	sort(all(v));
	ll sum = sum_p + sum_n;
	if (neg & 1) {
		sum -= 2 * v.front();
	}
	cout << sum << "\n";
}

Measured memory_bytes: 640
#include <stdio.h>
int min(int x, int y) { return x < y ? x : y; }
int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d\n", min(a, b) + min(c, d));
	return 0;
}

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

template <ll mod> class modint
{
private:
    ll x;

public:
    modint(ll x = 0) : x(x >= 0 ? x % mod : (x % mod) + mod) {}
    modint &operator+=(const modint rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator-=(const modint rhs) {
        if ((x += mod - rhs.x) >= mod) x -= mod;
        return *this;
    }
    modint &operator*=(const modint rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    modint &operator/=(const modint rhs) {
        *this *= rhs.inv();
        return *this;
    }
    modint operator+(const modint rhs) const { return modint(*this) += rhs; }
    modint operator-(const modint rhs) const { return modint(*this) -= rhs; }
    modint operator*(const modint rhs) const { return modint(*this) *= rhs; }
    modint operator/(const modint rhs) const { return modint(*this) /= rhs; }

    modint operator-() const { return modint(-x); }

    modint pow(ll n) const {
        modint e = *this, ret = modint(1);
        while (n) {
            if (n & 1) ret *= e;
            e *= e, n >>= 1;
        }
        return ret;
    }

    modint inv() const { return pow(mod - 2); }

    friend ostream &operator<<(ostream &os, const modint &m) {
        os << m.x;
        return os;
    }

    friend istream &operator>>(istream &is, modint &m) {
        ll in;
        is >> in;
        m = modint(in);
        return is;
    }
};
using mint = modint<1000000007>;

class Combination
{
private:
    vector<mint> _fact, _inv_fact;
    
public:
    Combination(int size) : _fact(size + 1), _inv_fact(size + 1) {
        _fact[0] = 1;
        for (int i = 1; i <= size; i++) _fact[i] = _fact[i-1] * i;
        _inv_fact[size] = _fact[size].inv();
        for (int i = size - 1; i >= 0; i--) _inv_fact[i] = _inv_fact[i+1] * (i+1);
    }

    mint fact(int k) const {return _fact[k];}
    mint inv_fact(int k) const {return _inv_fact[k];}

    mint P(int n, int r) {
        if (r < 0 || n < r) return 0;
        else return fact(n) * inv_fact(n - r);
    }

    mint C(int n, int r) {
        if (r < 0 || n < r) return 0;
        else return fact(n) * inv_fact(r) * inv_fact(n - r);
    }

    mint H(int n, int r) {
        if (n < 0 || r < 0) return 0;
        else return r == 0 ? 1 : C(n + r - 1, r);
    }
};

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

    int n, k; cin >> n >> k;
    Combination c(n);
    int m = min(k, n);

    mint ans = 0;
    for (int i = 0; i <= m; i++) {
        ans += c.C(n, i) * c.C(n - 1, i);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;


void solve(long long N){
  ll rv = 0;
  for (ll i = 1; i <= N; ++i) {
    rv += (i + i*(N/i))*(N/i)/2;
  }
  cout << rv << endl;
}

int main() {
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	int count[3], p[5];
	
	while(true){
		
		for(int i = 0; i < 3; i++){
			count[i] = 0;
		}
		
		cin >> p[0];
		if(p[0] == 0){
			break;
		}
		p[0]--;
		count[p[0]]++;
		
		for(int i = 1; i < 5; i++){
			cin >> p[i];
			p[i]--;
			count[p[i]]++;
		}
		
		int emp = 0;
		
		int win, lose;
		
		for(int i = 0; i < 3; i++){
			if(count[i] == 0){
				win = (i + 1) % 3;
				lose = (i + 2) % 3;
				emp++;
			}
		}
		
		if(emp == 0 || emp == 2){
			for(int i = 0; i < 5; i++){
				cout << "3" << endl;
			}
		}else{
			for(int i = 0; i < 5; i++){
				if(p[i] == win){
					cout << "1" << endl;
				}else{
					cout << "2" << endl;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // Random rand = new Random();

		// 整数の入力
        int hp= sc.nextInt();
        int attack = sc.nextInt();

        int count = 0;
        if(hp % attack == 0){
            count = hp / attack;
        }else{
            count = (hp / attack) + 1;
        }
        
        System.out.println(count);



    
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  vector<int> t(N + 1), x(N + 1), y(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }
 t[0]=0; x[0]=0; y[0]=0;
  bool can_move = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i + 1] - t[i];
    int dxy = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);  // 前回との移動値
    // 移動量を超えるか、偶数と奇数が一致しない場合は不可
    if (dxy > dt || dt % 2 != dxy % 2) can_move = false;
  }
 
  cout << (can_move ? "Yes" : "No") << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w;
char s[525];
int mp[525][525];
int a[525][525];
int b[525][525];

int main(){
  scanf("%d%d",&h,&w);
  REP(i,h){
    scanf("%s",s);
    REP(j,w)mp[i][j]=(s[j]=='#');
  }
  REP(i,h)REP(j,w)a[i][j]=b[i][j]=mp[i][j];
  REP(i,h){
    if(i%2==0){
      FOR(j,1,w-1){
        a[i][j] = 1;
      }
    }else{
      FOR(j,1,w-1){
        b[i][j] = 1;
      }
    }
  }
  REP(i,h)a[i][0] = 1;
  REP(i,h)b[i][w-1] = 1;
  REP(i,h){
    REP(j,w)putchar(a[i][j]?'#':'.');
    putchar('\n');
  }
  putchar('\n');
  REP(i,h){
    REP(j,w)putchar(b[i][j]?'#':'.');
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 3840
bingo = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
ans = []
for m in range(n):
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == b[m]:
                ans.append([i,j])
for i,j in ans:
    bingo[i][j] = -1
lists = []
cnt = 0

i = 0 
j = 0
if bingo[0][0] == -1 and bingo[0][1] == -1 and bingo[0][2] == -1:
                cnt = 1
if bingo[1][0] == -1 and bingo[1][1] == -1 and bingo[1][2] == -1:
                cnt = 1
if bingo[2][0] == -1 and bingo[2][1] == -1 and bingo[2][2] == -1:
                cnt = 1
if bingo[0][0] == -1 and bingo[1][0] == -1 and bingo[2][0] == -1:
                cnt = 1
if bingo[0][1] == -1 and bingo[1][1] == -1 and bingo[2][1] == -1:
                cnt = 1
if bingo[0][2] == -1 and bingo[1][2] == -1 and bingo[2][2] == -1:
    cnt = 1
if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
                cnt = 1
if bingo[0][2] == -1 and bingo[1][1] == -1 and bingo[2][0] == -1:
                cnt = 1

if cnt == 1:
    print("Yes")
else:
    print("No")

        


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

#define int long long
#define pb push_back
#define mp make_pair
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin>>s;
    int n=s.length();
    for(int i=1;i<n;i++)
    {
        if(s[i]==s[i-1])
        {
            cout<<"Bad";
            return 0;
        }
    }
    cout<<"Good";
    return 0;

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  long long A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A,A+N);
  long long ans=0;
  long long ansmax=0;
  
  if(N%2 == 1){
    for(int i=0;i<=N/2-1;i++){
      ans+=A[N-1-i]*2;
    }
    ans-=A[N-1-N/2];
    ans-=A[N-2-N/2];
    for(int i=0;i<=N/2-2;i++){
      ans-=A[i]*2;
    }
    //cout<<"ans1"<<ans<<endl;
    ansmax=ans;
    ans=0;
    
    for(int i=0;i<=N/2-2;i++){
      ans+=A[N-1-i]*2;
    }
    ans+=A[N-1-N/2];
    ans+=A[N-N/2];
    for(int i=0;i<=N/2-1;i++){
      ans-=A[i]*2;
    }
    //cout<<"ans2"<<ans<<endl;
    ansmax=max(ans,ansmax);
  }
  else{
    ans=0;
    for(int i=0;i<N/2-1;i++){
      ans+=A[N-1-i]*2;
    }
    //cout<<"#"<<ans<<endl;
    ans+=A[N-N/2];
    ans-=A[N-N/2-1];
    for(int i=0;i<N/2-1;i++){
      ans-=A[i]*2;
    }
    //cout<<"ans3"<<ans<<endl;
    ansmax=max(ans,ansmax);
  }
  
  
  cout<<ansmax<<endl;
  return 0;
}


Measured memory_bytes: 4404
#include<stdio.h>
#include<malloc.h>

void swap(int *VerticalLine, int a, int b)
{
	int temp;

	temp = VerticalLine[a];
	VerticalLine[a] = VerticalLine[b];
	VerticalLine[b] = temp;
	
	return;
}

int main(void)
{
	int *VerticalLine;
	int *a, *b;
	int w, n;
	int i;
	
	scanf("%d", &w);
	scanf("%d", &n);
	
	VerticalLine = (int *)malloc(sizeof(int) * w);
	for(i = 0; i < w; ++i)
	{
		VerticalLine[i] = (i + 1);
	}
	a = (int *)malloc(sizeof(int) * n);
	b = (int *)malloc(sizeof(int) * n);
	
	for(i = 0; i < n; ++i)
	{
		scanf("%d,%d", &a[i], &b[i]);
	}
	
	for(i = 0; i < n; ++i)
	{
		swap(VerticalLine, (a[i] - 1), (b[i] - 1));
	}
	
	for(i = 0; i < w; ++i)
	{
		printf("%d\n", VerticalLine[i]);
	}
	
	free(VerticalLine);
	free(a);
	free(b);
	return 0;
}

Measured memory_bytes: 596