akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n;
int a[21][21];
int dp[21][(1 << 21)];

int rec(int pos, int mask) {
	if(pos >= n) {
		if(__builtin_popcount(mask) == n) return 1;
		return 0;
	}
	int &ans = dp[pos][mask];
	if(ans != -1) return ans;
	ans = 0;
	for(int i = 0; i < n; i++) {
		if(mask & (1 << i)) continue;
		if(a[pos][i]) ans = add(ans, rec(pos + 1, mask | (1 << i)));
	}
	return ans;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n;
    f(i, n) {
    	f(j, n) cin>>a[i][j];
    }
    f(i, n) {
    	f(j, (1 << n)) dp[i][j] = -1;
    }
   	cout<<rec(0, 0);
    return 0;
}

Measured memory_bytes: 344320
#include<bits/stdc++.h>
#define MAXN 1e5

using namespace std;

long long dp (long long n, long long W, long long w[], long long v[]){
    long long l[n+1][W+1];

    for (int i=0; i<=n; i++){
        for (int j=0; j<=W; j++){
            if (i==0 or j==0){
                l[i][j]=0;
            }
            else if (w[i-1]<=j){
                l[i][j]=max(l[i-1][j], l[i-1][j-w[i-1]] + v[i-1]);
            }
            else{
                l[i][j]=l[i-1][j];
            }
        }
    }

    return l[n][W];
}

long long n,m,a,b,c,W;
string s1,s2;

int main(){
    cin>>n>>W;
    long long v[n];
    long long w[n];

    for (int i=0; i<n; i++){
        cin>>w[i]>>v[i];
    }
    cout<<dp(n, W, w, v);
}


Measured memory_bytes: 82484
#include<stdio.h>
int table[500000];
int prime[100000];
int main(){
	table[0]=-1;
	table[1]=-1;
	for(int i=2;i<500000;i++){
		if(table[i]!=-1){
			table[i]=1;
			for(int j=i*2;j<500000;j+=i){
				table[j]=-1;
			}
		}
	}
	int now=0;
	for(int i=0;i<500000;i++){
		if(table[i]==1)prime[now++]=i;
	}
	int a;
	while(scanf("%d",&a),a){
		long long int ret=0;
		for(int i=0;i<a;i++){
			ret+=prime[i];
		}
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using static System.Math;
using static System.Console;
class Simple
{
    int N, M;
    int[] L, R, D;

    List<Edge>[] adj;
    bool[] isVisited;
    long[] dis2next;

    void Solve() {
        //input
        N = io.Int;
        M = io.Int;
        L = new int[M];
        R = new int[M];
        D = new int[M];
        for(int i = 0; i < M; ++i) {
            L[i] = io.Int;
            R[i] = io.Int;
            D[i] = io.Int;
        }
        //cal
        adj = new List<Edge>[N + 1];
        for(int i = 0; i < adj.Count(); ++i) {
            adj[i] = new List<Edge>();
        }
        for(int i = 0; i < M; ++i) {
            adj[L[i]].Add(new Edge(R[i],  D[i]));
            adj[R[i]].Add(new Edge(L[i], -D[i]));
        }
        dis2next  = new long[N + 1];
        isVisited = new bool[N + 1];

        for(int i = 1; i <= N; ++i) {
            if (!isVisited[i]) {
                isVisited[i] = true;
                dfs(i, 0);
            }
        }
        //ret
        WriteLine("Yes");
    }

    void dfs(int cur,int pre) {
        foreach(var e in adj[cur]) {
            var next = e.To;
            var cost = e.Cost;
            if (isVisited[next]) {
                var pred = dis2next[next] - cost;
                if(dis2next[cur]!= pred) {
                    WriteLine("No");
                    io.writeFlush();
                    Environment.Exit(0);
                }
            } else {
                isVisited[next] = true;
                dis2next[next] = dis2next[cur] + cost;
                dfs(next, cur);
            }
        }
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream(); 
    void Stream() { Solve(); io.writeFlush(); }
}
public struct Edge : IComparable<Edge>
{
    public int To;
    public long Cost;
    public Edge(int to, long cost) {
        this.To = to;
        this.Cost = cost;
    }
    public int CompareTo(Edge e) => Cost.CompareTo(e.Cost);
}

class SimpleIO
{
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 51092
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename T>
T gcd(T a, T b) {
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

void solve() {
	ll n, count = 0;
	cin >> n;
	ll N = n;
	// cout << "sqrt : " << sqrt(n) << endl;
	for (int i = 2; i <= ceil(sqrt(N)); ++i) {
		if (n % i == 0) {
			// cout << "\t" << i << endl;
			ll res = 0;
			while (n % i == 0) {
				n /= i;
				res++;
			}
			// cout << res << endl;
			if (res <= 2) {
				count++;
				continue;
			}
			for (int j = ceil(sqrt(2*res)); j >= 2; --j) {
				if (j * (j - 1) <= 2 * res) {
					// cout << i << "->" << res << " : " << sqrt(2 * res) << "->" << j-1<< endl;
					count += (j-1);
					break;
				}
			}
		}
	}

	if (n != 1)
		count++;

	cout << (count == 0 ? n != 1 ? n : 0 : count)<< endl;
}	

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	
	
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	
	return 0;
}





























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

int main(){
  ll n,dis=0; cin>>n;
  vector<ll> a(n+2),d(n+1);
  a[0] = 0; a[n+1] = 0;
  for(int i=1; i<=n+1; i++) {
    cin>>a[i];
    d[i] = abs(a[i]-a[i-1]);
    dis += d[i];
  }
  for(int i=1; i<=n; i++) {
    cout<<dis+abs(a[i-1]-a[i+1])-(abs(a[i-1]-a[i])+abs(a[i]-a[i+1]))<<endl;
  }
}

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

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

    string s;
    cin >> s;
    sort(s.begin(), s.end());
    string res = (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) ? "Yes" : "No";
    cout << res << endl;
}






Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, Q = map(int, readline().split())

data0 = [0]*(N+1)
data1 = [0]*(N+1)
def _add(data, k, x):
    while k <= N:
        data[k] += x
        k += k & -k
def add(l, r, x):
    _add(data0, l, -x*(l-1))
    _add(data0, r, x*(r-1))
    _add(data1, l, x)
    _add(data1, r, -x)

def _get(data, k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s
def query(l, r):
    return _get(data1, r-1) * (r-1) + _get(data0, r-1) - _get(data1, l-1) * (l-1) - _get(data0, l-1)


ans = []
for q in range(Q):
    t, *cmd = map(int, readline().split())
    if t:
        s, t = cmd
        ans.append(str(query(s, t+1)))
    else:
        s, t, x = cmd
        add(s, t+1, x)
write("\n".join(ans))
write("\n")



Measured memory_bytes: 16412
sa = gets.chomp.split("")
sb = gets.chomp.split("")
sc = gets.chomp.split("")
queue = ["a"]
last_player = ""
until queue.empty?
  last_player = queue.shift
  case last_player
  when "a"
    queue.push(sa.shift) unless sa.empty?
  when "b"
    queue.push(sb.shift) unless sb.empty?
  when "c"
    queue.push(sc.shift) unless sc.empty?
  end
end
puts last_player.upcase


Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {

    char s[101];
    scanf("%s", s);

    for (int i = 0; i < strlen(s); i++) {
        char c=s[i];
        
        if(i%2==0){
            
            if(c=='L'){
                printf("No");
                return 0;
            }
            
        }else{

            if (c == 'R') {
                printf("No");
                return 0;
            }
        }
    }
    printf("Yes");

    return 0;

}

Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	//function<long long(int l, int r, int x, int y)>DP = [&](int l, int r, int x, int y) ->long long int {
	//	if (l + 1 == r)return 0;
	//	long long int ret = MOD * MOD;
	//	for (int i = l + 1; i < r; i++) {
	//		ret = min(ret, ((DP(l, i, x, x + y)) + (DP(i, r, x + y, y)) + v[i] * (x + y)));
	//	}
	//	return ret;
	//};
	auto DP = [&](auto &&d,int l, int r, int x, int y) ->long long int {
		if (l + 1 == r)return 0;
		long long int ret = MOD * MOD;
		for (int i = l + 1; i < r; i++) {
			ret = min(ret, ((d(d,l, i, x, x + y)) + (d(d,i, r, x + y, y)) + v[i] * (x + y)));
		}
		return ret;
	};
	cout << DP(DP,0, N - 1, 1, 1) + v.front() + v.back() << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std ;

int R,G,B,N ;

int ans = 0 ;

void fb(int sum) ;

void fg(int sum){
		while(sum<=N){
			fb(sum) ;
			sum += G ;
		}
	}
void fr(){
		int sum = 0 ;
		while(sum<=N){
			fg(sum) ;
			sum += R ;
		}
	}
void fb(int sum){
			if((N-sum)%B==0){
				ans++ ;
			}
			//sum += B ;

	}



int main(){
    scanf("%d %d %d %d",&R,&G,&B,&N) ;
    fr() ;
    printf("%d",ans) ;
    return 0 ;
}


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

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

    int ans = 1;
    for(int i=2; i*i<=x; i++){
        int div = x;
        int count = 0;
        int power = 1;

        while(true){
            div /= i;
            if(div == 0) break;
            power *= i;
            count += 1;
        }
        if(ans < power && count >= 2) ans = power;
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n, m;
	while (cin >> n >> m, n || m) {
		vector<int>v(n + 1, 0), Q; rep(i, 1, n + 1)cin >> v[i];
		rep(i, 0, n + 1) {
			rep(j, i, n + 1) {

				if (v[i] + v[j] <= m)Q.push_back(v[i] + v[j]);
			}
		}
		sort(all(Q));
		dumpc(Q);
		int ans(0);
		rep(i, 0, Q.size()) {
			int l = 0, r = Q.size();
			while (r - l > 1) {
				int mid = (l + r) / 2;
				if (Q[mid] > m - Q[i])r = mid;
				else l = mid;
			}
			if (Q[i] + Q[l] <= m)ans = max(ans, Q[i] + Q[l]);
			dump(ans);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6684
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int h,int w){

  int x =h*h+w*w;
  vector<pair<int,P> > v;;
  FOR(i,1,150){
    FOR(j,i+1,150){
      int y = i*i+j*j;
      if(x<y||x==y&&h<i){
        v.push_back(make_pair(y,P(i,j)));
      }
    }
  }
  sort(all(v));

  cout<<v[0].second.first<<' '<<v[0].second.second<<endl;


}

int main(){
  while(1){
    int h,w;
    cin>>h>>w;
    if(h==0) break;
    f(h,w);
  }

  return 0;
}


Measured memory_bytes: 3264
import java.util.*;

class Main {
    static int r;
    static int D;
    static int x;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        r = sc.nextInt();
        D = sc.nextInt();
        x = sc.nextInt();

        int i=0;
        gram(x,i);
    }

    public static void gram(int xi, int i){
        int xip = r*xi - D;
        System.out.println(xip);
        if(i+1>=10){
            return;
        } else {
            gram(xip, i+1);
        }
    }
}

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

main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int pat = 0;
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c;k++){
                int total = 500 * i + 100 * j + 50 * k;
                if (total == x) pat++;
            }
        }
    }

    cout << pat << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

int main(){
    long long r,D,x;

    cin >> r >> D >> x;

    for(int i = 0; i < 10; i++){
        x = r*x - D;
        cout << x << endl;
    }

    return 0;
}

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

int main(void)
{
    int n, k;
    vector<int> d;
    int maxV = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        d.push_back(tmp);
    }
    for (int i = 0; i <= min(n, k); i++) {
        for (int j = 0; j <= min(k-i, n-i); j++) {
            vector<int> v;
            copy(d.begin(), d.begin()+i, back_inserter(v));
            copy(d.end()-j, d.end(), back_inserter(v));
            int l = min(i+j, k-i-j);
            sort(v.begin(), v.end());
            for (int l_ = 0; l_ < l; l_++) {
                if (v[l_] >= 0) {
                    l = l_;
                    break;
                }
            }
            maxV = max(
                    accumulate(v.begin()+l, v.end(), 0),
                    maxV);
        }
    }
    cout << maxV << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e5) + 7;

struct BIT {
    ll t[N];
    BIT() {fill(t, t + N, 0);}
    void Update(int x, int val) {for(; x < N; x += (x & -x)) t[x] += val;}
    ll Get(int x) {ll res = 0; for(; x > 0; x -= (x & -x)) res += t[x]; return res;}
} bit1, bit2;
int n, m, a[N];
ll sum, cur, x, res;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    sum = 0;
    for(int i = 2; i <= n; ++i) {
        x = a[i];
        if(x < a[i - 1]) x += m;
        sum += x - a[i - 1];
        bit2.Update(a[i - 1] + 1, -a[i - 1]);
        bit2.Update(x + 1, a[i - 1]);
        bit1.Update(a[i - 1] + 1, 1);
        bit1.Update(x + 1, -1);
    }
    res = sum;
    for(int i = 1; i <= m; ++i) {
        x = bit1.Get(i);
        cur = sum - (x * i + bit2.Get(i)) + x;
        x = bit1.Get(i + m);
        cur = cur - (x * (i + m) + bit2.Get(i + m)) + x;
        res = min(res, cur);
    }
    cout << res;
}


Measured memory_bytes: 3840
N = int(input())
Als = []

x = input().split(" ")

for i in range(N):
    Als.append(int(x[i]))

Als.sort(reverse = False)

Alice = 0
Bob = 0


for i in range(N):
    now = Als.pop()
    if i%2 == 0:
        Alice += now
    else:
        Bob += now

print(Alice - Bob)
        


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

static const int MAX = 100;
static const int INF = 1e9;

map<pair<int, int>, int> mp;

// ワ―シャルフロイド法 O(V^3)
void warshall_floyd(vector<vector<int>> &M) { // 隣接行列Mを書き換える
  int n = M.size();
  for (int i = 0; i < n; i++) // 経由する頂点
    for (int j = 0; j < n; j++) // 始点
      for (int k = 0; k < n; k++) // 終点
        M[j][k] = min(M[j][k], M[j][i] + M[i][k]);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  // 重み付き無向(有向)グラフの隣接リスト
  int n, m; // n:頂点数 m:辺数
  cin >> n >> m;
  
  vector<vector<int>> M(n, vector<int>(n, INF)); // M:頂点数がnのグラフを表す隣接行列(初期値INF)
  for (int i = 0; i < n; i++) M[i][i] = 0;
  
  vector<pair<int, int>> G[n]; // G:頂点数がnのグラフを表す隣接リスト
  
  int u, v, w;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    M[u][v] = w;
    M[v][u] = w; // 重み付き有向グラフではこの行をコメントアウト
    G[u].emplace_back(make_pair(v, w));
    G[v].emplace_back(make_pair(u, w)); // 有向グラフではこの行をコメントアウト
  }
  
  warshall_floyd(M);
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < G[j].size(); k++) {
        if (M[i][j] + G[j][k].second == M[i][G[j][k].first]) {
          if (j < G[j][k].first) mp[make_pair(j, G[j][k].first)]++;
          else mp[make_pair(G[j][k].first, j)]++;
        }
      }
    }
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      if (i > G[i][j].first) continue;
      if (mp[make_pair(i, G[i][j].first)] > 0) ans++;
    }
  }
  
  cout << m - ans << '\n';
}

Measured memory_bytes: 384
A, B, C = map(int, input().split())

if (A%2) == (B%2) == (C%2):
    x, y, z = sorted([A,B,C])
    diff = z*2 - x - y
    print(diff//2)

else:
    count_odd = 0
    count_even = 0
    for n in [A,B,C]:
        if n%2==1:
            count_odd += 1
        else:
            count_even += 1
    
    if count_odd == 2:
        if A%2 == 1:
            A += 1
        if B%2 == 1:
            B += 1
        if C%2 == 1:
            C += 1        
    else:
        if A%2 == 0:
            A += 1
        if B%2 == 0:
            B += 1
        if C%2 == 0:
            C += 1

    x, y, z = sorted([A,B,C])
    diff = z*2 - x - y
    print(diff//2 + 1)


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

//map <vector<int>, int> m;

int main() {
	// your code goes here
	int a,b,t,l,i,j,minAns=100000000,n,k;
	cin >> n >> k;

	int ans = n-k+1;


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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <ccomplex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int n;
vector<string> ans;

void func(int pos, char c, const string cur) {
	if (pos == n) {
		cout << cur << endl;
		return;
	}
	for (char i = 'a'; i <= min('z', c); i++) {
		func(pos + 1, c + (i == c), cur + i);
	}
}

int main() {
	cin >> n;
	func(0, 'a', "");
	for (auto s : ans) {
		cout << s << endl;
	}
	cerr << ans.size() << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long e[100010];
int main() {
    long long n, k;
    cin >> k;
    n = 3;
    long long ans = 0;
    for (long long i = 1; i <= k; i++) {
        long long m = k / i;
        long long b = 0;
        for (long long j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                b += e[j];
                if (j != i / j && j != 1) {
                    b += e[i / j];
                }
            }
        }
        if (i == 1) {
            b = 0;
        }
        long long n1 = n;
        long long ans1 = 1;
        while (n1 > 0) {
            if ((n1 & 1) == 1) {
                ans1 = ans1 * m % 1000000007;
            }
            m = m * m % 1000000007;
            n1 >>= 1;
        }
        ans += ans1 * (i - b) % 1000000007;
        ans %= 1000000007;
        e[i] = (i - b);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, Y;
  cin >> n >> Y;
  Y /= 1000;
  rep(x, n + 1) {
    if (10 * x > Y) break;
    int y = (Y - 10 * x) - (n - x);
    if (y % 4 != 0) continue;
    y /= 4;
    int z = n - x - y;
    if (y >= 0 && z >= 0) {
      cout << x << " " << y << " " << z << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
int main() {
  ll x, K;
  cin >> x >> K;
  if(K == x) cout << 0 << endl;
  else if(K > x) {
    if(x < (double)K / 2) cout << x << endl;
    else cout << K - x << endl;
  }
  else {
    x = x % K;
    if(x < (double)K / 2) cout << x << endl;
    else cout << K - x << endl;
  }
}



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

int main() {
	int n;
	while(cin >> n, n) {
		int bill[2][128] = {0};
		int edge[256][256];
		const int INF = 512;
		for(int i = 0; i < 256; i++) {
			for(int j = 0; j < 256; j++) {
				edge[i][j] = INF;
			}
			edge[i][i] = 0;
		}

		for(int i = 0; i < 2; i++)
			for(int j = 0; j < n; j++)
				cin >> bill[i][j];

		for(int i = 0; i < 2; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = 0; k < 3; k++) {
					if(j + k < n && (bill[i][j] == 0 || (bill[i][j] == 1 && bill[i][j+1] != 1))) {
						edge[n*i + j][n*(!i) + j + k] = 1;
					}
				}
			}
		}
		for(int i = 0; i < 2; i++) {
			for(int j = 1; j < n; j++) {
				if(bill[i][j-1] == 1 && bill[i][j] == 1)
					edge[n*i + j-1][n*i + j] = 0;
				else if(bill[i][j] == 2)
					edge[n*i + j][n*i + j-1] = 0;
			}
		}

		for(int i = 0; i < 2 * n; i++) {
			for(int j = 0; j < 2 * n; j++) {
				for(int k = 0; k < 2 * n; k++) {
					edge[j][k] = min(edge[j][k], edge[j][i] + edge[i][k]);
				}
			}
		}
		
		int res = INF;
		if(bill[0][n-1] != 2) {
			res = min(res, min(edge[0][n-1], edge[n][n-1]));
		}
		if(bill[1][n-1] != 2) {
			res = min(res, min(edge[0][2*n-1], edge[n][2*n-1]));
		}

		if(res == INF)
			cout << "NA" << endl;
		else
			cout << res << endl;
	}
}

Measured memory_bytes: 1416
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int cup[100],stat[100],sum[100],wat[200];
int N,SET;

int search(int cc,int left,int look,int num){
	int i;

	stat[look]=1;

	if(left==0){
		if(cc<N)stat[cc]=2;
		if(num==0)return 1;
		for(i=N-1;i>=0;i--){
			if(stat[i]==0)break;
			if(stat[i]==1 && search(i,cup[i],99,num))return 1;
		}
		if(look<N)stat[look]=0;
		stat[cc]=1;
		return 0;
	}

	int ccc=(look<N) ? look:cc;

	for(i=ccc-1;i>=0;i--){
		if(left<cup[i])continue;
		if(sum[i]<left)break;
		if(stat[i]==0 && search(cc,left-cup[i],i,num-1))return 1;
		if(i==cc-1 && stat[i]==0)break;
	}

	stat[look]=0;

	return 0;
}

int main(){
    int i,j,k;

    while(scanf("%d",&N)*N){
		SET++;

		for(i=0;i<=100;i++)wat[i]=0;
		for(i=0;i<N;i++){
			scanf("%d",&k);
			wat[k]++;
		}
		for(i=0,j=0,k=0;i<=100,j<N;i++){
			for(;wat[i]>0;wat[i]--){
				k+=i;
				cup[j]=i;
				stat[j]=0;
				sum[j]=k;
				j++;
			}
		}

		if(search(99,0,N-1,N-1))printf("YES\n"); else printf("NO\n");

    }
 
    return 0;
}

Measured memory_bytes: 588
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e6+9;

ll fact[MAXN];

ll power(ll a, ll b)
{
    ll ret = 1;

    while(b)
    {
        if(b&1)  ret = (ret*a)%MOD;

        a = (a*a)%MOD;

        b>>=1;
    }

    return ret;
}

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    fact[0] = 1;
    for(i=1; i<MAXN; i++)
        fact[i] = (fact[i-1]*i)%MOD;

    cin>>x>>y;
    k = x+y;
    if(k%3!=0){
        cout<<0<<endl;
    }
    else
    {
        k = k/3; k++;
        q = (k-1)*2;
        p = q-k+1;

        if(x<p || x>q) cout<<0<<endl;
        else
        {
            ll idx = x-p+1;
            idx--; k--;
            ll ans = fact[k];
            ans = (ans*power(fact[idx], MOD-2))%MOD;
            ans = (ans*power(fact[k-idx], MOD-2))%MOD;

            cout<<ans<<endl;
        }
    }

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


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

using namespace std;

int main (){

int v[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int num;
cin >> num;
cout << v[num-1] << endl;
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
   int a,b,c,d[100],e,i,z=1;

    scanf("%d%d%d",&a,&b,&c);
    
    for(i=0;i<a && i<b;i++){
        if(a%z == 0 && b%z == 0){
            d[e] = z;
            e++;
        }
        z++;
    }
    printf("%d\n",d[e-c]);
    
    return 0;
}

Measured memory_bytes: 128
//https://atcoder.jp/contests/dp/tasks/dp_h
#include <bits/stdc++.h>
#include <sstream> 
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define pi 2*acos(0.0)
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repe(i,a,b) for(ll i=a;i<=b;++i)
#define CPrint(c)  for(auto i:(c)) { cout<<i<<" "; } nl 
#define eb   emplace_back
#define ef   emplace_front
#define pb   push_back
#define pf   push_front
#define popb pop_back
#define popf pop_front
#define mp   make_pair
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
//Allows to traverse any type of macro
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
//debuggers
#define trace2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define trace3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define trace4(w,x,y,z) cout<<#w<<"="<<w<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<ll,ll> pll;
const int mod = 1e9 + 7;

const int nax = 1005;
char sl[nax][nax];

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main()
{
  int h, w;
    scanf("%d%d", &h, &w);
    for(int row = 0; row < h; ++row) {
        scanf("%s", sl[row]);
    }
    vector<vector<int>> dp(h, vector<int>(w));
    dp[0][0] = 1;
    for(int row = 0; row < h; ++row) {
        for(int col = 0; col < w; ++col) {
            for(int r2 : {row, row + 1}) {
                int c2 = col;
                if(r2 == row) {
                    c2 = col + 1;
                }
                if(r2 < h && c2 < w && sl[r2][c2] == '.') {
                    add_self(dp[r2][c2], dp[row][col]);
                }
            }
        }
    }
    printf("%d\n", dp[h-1][w-1]);
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	ll n,a[200009],m;
	string s;
	cin>>n>>m;
	if(m%2==0 && m>=2*n && m<=4*n)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int H, W; cin >> H >> W;
  vvc C(H,vc(W)); rep(i,H) rep(j,W) cin >> C.at(i).at(j);
  
  rep(i,2*H) {
    rep(j,W) {
      cout << C.at(i/2).at(j);
      if (j == W-1) cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

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



Measured memory_bytes: 3640
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
        ll n,i,s=0,ans=0;
        cin >> n;
        vector<ll> a(n);
        vector<ll> p(n-1);
        for(i=0;i<n;++i){
                cin >> a.at(i);
                s += a.at(i);
        }
        s %= MOD;
        for(i=0;i<n-1;++i){
                s -= a.at(i);
                if(s<0) s += MOD;
                ans += s*a.at(i);
                ans %= MOD;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 6392
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
using namespace std;

int main()
{
    char val;
    int temp;
    cin>>val;
    temp = islower(val);
    if(temp!=0)
    {
        cout<<'a';
    }
    else
    {
        cout<<'A';
    }
}


Measured memory_bytes: 3616
def main():
    input()
    nums = list(map(int, input().split()))
    nums_count = {}

    for i in range(len(nums)):
        nums_count.setdefault(nums[i], 0)
        nums_count[nums[i]] += 1
        if nums_count[nums[i]] >= 2:
            print('NO')
            exit()
    print('YES')




if __name__ == '__main__':
    main()

Measured memory_bytes: 107732
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' '); 
            int a = Int32.Parse(input[0]);
            int b = Int32.Parse(input[1]);

            Console.WriteLine(b % a == 0 ? a + b : b - a);
        }      
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000000;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	string s;
	cin >> s;
	rep(i, s.size()) {
		rep(j, N) {
			if (s[i] == 'Z')s[i] = 'A';
			else s[i]++;
		}
	}
	cout << s << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<ctime>
#include<algorithm>
#include<cmath>
#include <cstring>
#include <string>
#include <set>
using namespace std;
set<string > s2;
int main()
{
   string s;int k;cin>>s>>k;
   int l=s.length();
   for(int i=0;i<l;i++)
   {
      for(int j=1;j<=5&&(i+j<=l);j++)
         s2.insert(s.substr(i,j));
   }
   set<string>::iterator iter;
   int j=1;
   for(iter=s2.begin();iter!=s2.end();iter++,j++)
   {
      if(j==k){
         cout<<*iter;
      }
   }
}









//int cow[5005];
//int f[5005];
//int n,res;
//int cow_rev(int k)
//{
//   memset(f, 0, sizeof f);
//   int ans=0,sum;
//   for(int i=0;i+k<n;i++)
//   {
//
//   }
//   for(int i=n-k;i<n;i++)
//   {
//
//   }
//   return ans;
//}
//
//int main()
//{
//   cin>>n;
//   char c;
//   for(int i=0;i<n;i++)
//   {
//      cin>>c;
//      cow[i]=c=='F'?0:1;
//   }
//   for(int i=1;i<=n;i++)
//   {
//
//   }
//}


Measured memory_bytes: 1664
def resolve():
    x = int(input())
    q = x // 100
    r = x % 100
    if r == 0 :
        print("1")
        return None
    if r % 5 == 0:
        y = r//5
    else:
        y = (r //5)+ 1
    if q < y:
        print("0")
    else:
        print("1")
resolve()

Measured memory_bytes: 3064
n, m = map(int, input().split())
ans = 1
if n == 1:
    ans = m
else:
    for i in range(1, min(m // n + 1, int(m ** 0.5) + 1))[::-1]:
        if m % i == 0:
            ans = max(ans, i)
            if i >= n:
                ans = max(ans, m // i)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
     int n;
     long long a[10001]={0};
     cin>>n;
     for(int i=0; i<n; i++){
        cin>>a[i];
         }
     long long min=1000000,max=-1000000, sum=0;
     for(int i=0; i<n; i++){
         if(a[i]<min){
            min=a[i];
            }
         if(a[i]>max){
            max=a[i];
            }
         sum=sum+a[i];
        }
     
        cout<<min<<" "<<max<<" "<<sum<<endl;
    }




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

int main() {
    int H; cin >> H;
    int A[300];
    rep(i, H){
        cin >> A[i+1];
    }
    for (int i = 1; i <= H; i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(i/2 > 0){
            cout << "parent key = " << A[i/2] << ", ";
        }
        if(i*2 <= H){
            cout << "left key = " << A[i*2] << ", ";
        }
        if(i*2 + 1 <=H){
            cout << "right key = " << A[i*2 + 1] << ", ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3100
n = int(input())
robots = [[int(s) for s in input().strip().split()] for _ in range(n)]
robots = sorted([(x - l, x + l) for x, l in robots], key=lambda x: x[1])
result = 0
reach = float("-inf")
for l, r in robots:
  if l >= reach:
    result += 1
    reach = r
print(result)

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

int main() {
  int a, b, S;
  cin >> a >> b;
	S = a * b % 2;
      if (S == 0) {
        cout << "Even" << endl;
      }
  		else {
          cout << "Odd" << endl;
        }
  
  
      
  // ここにプログラムを追記
}

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


const ll MAX = 100000;
const ll mod = 1000000007;
const ll MOD = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];
ll inv2[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[0] = inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        //inv2[i] = inv[i];
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

ll dp[6][32000];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    dp[0][0]=1;
    ll x = 1;
    COMinit();
    for(ll i=b;i>=a;i--){
        for(ll j=0;j<=n;j++) dp[x][j] = dp[x^1][j];
        ll mul=1,tmp=1;
        for(ll j=0;j<c;j++){
            tmp *= COM(i*c-i*j,i);
            tmp %= mod;
        }
        tmp *= finv[c];
        tmp %= mod;
        for(ll j=c;j<=d;j++){
            if(i*j > n) break;
            if(j!=c){
                tmp *= COM(i*j,i);
                tmp %= mod;
                tmp *= inv[j];
                tmp %= mod;
            }
            mul = tmp; 
            ll now = i*j;
            for(ll k=n;k>=i*j;k--){
                dp[x][k] += (dp[x^1][k-i*j] * mul)%mod;
                dp[x][k] %= mod;
                now++;
                mul *= (now * inv[now-i*j])%mod;
                mul %= mod;               
            }
        }
        x ^= 1;
    }
    cout << dp[x^1][n] << endl;
}

Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef pair<int, int> P;

int main() {
	int N;
	cin >> N;
	P ab[100], cd[100];
	bool used[100] = {};
	for (int i = 0; i < N; i++)cin >> ab[i].first >> ab[i].second;
	for (int i = 0; i < N; i++)cin >> cd[i].second >> cd[i].first;

	int ans = 0;
	sort(ab, ab + N);
	sort(cd, cd + N);
	for (int i = N - 1; i >= 0; i--) {
		int x = ab[i].first, y = ab[i].second;
		for (int j = 0; j < N; j++) {
			if (used[j])continue;
			if (x < cd[j].second && y < cd[j].first) {
				used[j] = true;
				ans++;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)
 
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
 
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
 
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
 
// --------------------------------------
int n;
ll c;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  cin >> n >> c;
  vector<ll> x(n + 1), v(n + 1), vc(n + 1), r(n + 1), l(n + 1);
  x[0] = 0, v[0] = 0;
  FOR(i, 1, n + 1) cin >> x[i] >> v[i];
 
  // vc[0] = 0;
  // FOR(i, 1, n + 1) vc[i] = vc[i - 1] + v[i];
 
  ll sum;
  r[0] = 0;
  FOR(i, 1, n + 1) {
    sum += v[i];
    r[i] = max(r[i - 1], sum - x[i]);
  }
 
  l[n] = max(0LL, v[n] - (c - x[n]));
  sum = v[n];
  for(int i=n-1; i>0; i--) {
    sum += v[i];
    l[i] = max(l[i + 1], sum - (c - x[i]));
  }
 
  ll ans = 0;
  REP(i, n) {
    ans = max(ans, r[i] - x[i] + l[i + 1]);
  }
 
  for(int i=n; i>0; i--) {
    ans = max(ans, l[i] - (c - x[i]) + r[i - 1]);
  }
 
  ans = max(ans, l[n]);
  ans = max(ans, r[n]);
  cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'
	
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
	
	
int main(){
	fast_io; cout_precision;
	int n;	cin >> n;
	int dp[10][10];	clr(dp);
	for(int i=1; i<=n; i++){
		int k = (i/pow(10 , floor(log10(i))));
		dp[i%10][k]++;
	}
	int ans = 0;
	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++)	ans+=dp[i][j]*dp[j][i];
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a[101];
	int c,k;
	cin>>c;
	cin>>k;
	for(int i=0;i<c;i++){
		cin>>a[i];
	}
	for(int i=0;i<c;i++){
		cout<<a[i]<<endl;
		cout<<a[i]<<endl;
	}
	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  map<ll, int> count;
  ll a;
  REP(i, N) {
    cin >> a;
    if (count.find(a) == count.end()) {
      count.insert(make_pair(a, 1));
    } else {
      ++count.at(a);
    }
  }

  int ans = 0;
  for (auto const &it : count) {
    if (it.second % 2 == 1) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
// {{{ Template
// Author:  wenxing
// Date:    2018-01-07 20:48 +0800
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r; i >= l; --i)
#define repv(ele, vec) for (auto &ele : vec)
#define zero(mem) memset(mem, 0, sizeof(mem))
#define sd(_) scanf("%d", &_)
#define sdd(_, __) scanf("%d%d", &_, &__)
#define sddd(_, __, ___) scanf("%d%d%d", &_, &__, &___)
#define sdddd(_, __, ___, ____) scanf("%d%d%d%d", &_, &__, &___, &____)

#define sf(_) scanf("%f", &_)
#define sff(_, __) scanf("%f%f", &_, &__)
#define sfff(_, __, ___) scanf("%f%f%f", &_, &__, &___)
#define sffff(_, __, ___, ____) scanf("%f%f%f%f", &_, &__, &___, &____)

#define sl(_) scanf("%ld", &_)
#define sll(_, __) scanf("%ld%ld", &_, &__)
#define slll(_, __, ___) scanf("%ld%ld%ld", &_, &__, &___)
#define sc(_) scanf("%c", &_)
#define ss(_) scanf("%s", _)
#define mid(a, b) (((a) + (b)) >> 1)
#define lft(x) x << 1
#define rht(x) x << 1 | 1
#define inf 0x3f3f3f3f
#define mod 19260817
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
// }}}

// - Pseudocode -

// {{{ Global Variables
int n, h, b[100100], maxa = 1, x;
// }}}

int main() {
    sdd(n, h);
    rep(i, 0, n) {
        sdd(x, b[i]);
        maxa = max(x, maxa);
    }
    sort(b, b + n);
    auto lb = upper_bound(b, b + n, maxa);
    int idx = lb - b;

    int s = 0;
    for (int i = n - 1; i >= idx; --i) {
        s += b[i];
        if (s >= h) {
            printf("%d\n", n - i);
            return 0;
        }
    }

    h -= s;
    int prestep = h / maxa;
    int secstep = n - idx;
    // cout << prestep << " " << secstep << endl;
    if (h % maxa != 0) ++prestep;

    printf("%d\n", prestep + secstep);

    return 0;
}


Measured memory_bytes: 640
n = int(input())
a = [0] + list(map(int, input().split()))

c = [0] * (n+1)
d = []

for i in reversed(range(1, n+1)):
    s = sum(c[::i])
    if s % 2 != a[i]:
        c[i] += 1
        d.append(str(i))

print(sum(c))
if sum(c) > 0:
    print(" ".join(d))

Measured memory_bytes: 95980