akhauriyash/Code-Regression huggingface dataset:
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main() {

    int N,K; cin>>N>>K;
    vector<ll> h(N+1,0), dp(N+K,1000000000000);

    for (int i = 1; i <= N; ++i) {       // 立ち位置
        cin>>h[i];
    }
    dp[1] = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= K; ++j) {  // 配る位置
            dp[i+j] = min(abs(h[i]-h[i+j])+dp[i], dp[i+j]);
        }
    }

    cout<<dp[N]<<endl;


    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int isEmpty(void);
void enqueue(int);
int dequeue(void);

int n, G[N+1][N+1], d[N+1], Q[N], head, tail;

void bfs(void);

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

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u][v]=1;
    }
  }
 
  bfs();
  for(i=1;i<n+1;i++){
    printf("%d %d\n",i, d[i]);
  }
}

void bfs(){
  int i, color[N+1], now, next;

  for(i=1;i<n+1;i++){
    color[i]=WHITE;
    d[i]=-1;
  }
  head=tail=0;

  d[1]=0;
  color[1]=GRAY;
  enqueue(1);
  
  while(isEmpty()!=1){
    now=dequeue();
    /*printf("%d ",now);*/
    for(next=1;next<=n;next++){
      if(G[now][next]==1 && color[next]==WHITE){
        color[next]=GRAY;
        d[next]=d[now]+1;
        enqueue(next);
      }
    color[now]=BLACK;
    }
  }
}


void enqueue(int x){
    Q[tail]=x;
    if(tail+1==N) tail=0;
    else tail++;
}

int dequeue(){
  int x;

  x=Q[head];
  if(head+1==N) head=0;
  else head++;
  return x;
}

int isEmpty(){
  if(head==tail) return 1;
  else return 0;
}



Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  for(int i = sqrt(N);i >= 2;i--) {
    if(N%i==0) {
      cout << i-1+(N/i)-1 << endl;
      return 0;
    }
  }

  cout << N-1 << endl;

  
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }

        long ans = Long.MAX_VALUE;
        long x = a[0];
        long y = 0;
        for(int i = 1; i < n; i++){
            y += a[i];
        }
        ans = Math.min(ans, Math.abs(x-y));
        if(n > 2) {
            for (int i = 1; i < n-1; i++) {
                x += a[i];
                y -= a[i];
                ans = Math.min(ans, Math.abs(x - y));
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 63768
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>

using namespace std;


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

	for (int i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;

	return 0;
}



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

int main()
{

    long long n,m,a,b,c,d,e,f,g,ans=0,i,sz;  vector<long long>v,u;
    map<long long,long long>mp,nq;

    scanf("%lld",&n);

    for(i=1;i<=n;i++)
    {

        scanf("%lld",&a); u.push_back(a);  mp[a]++;   if(mp[a]==1)v.push_back(a);

    }

    sz=v.size();

    for(i=0;i<sz;i++)
    {
        c=mp[v[i]];  g=v[i];

        if(c==2){nq[g]=1; ans=ans+1;}
        else if(c==3){nq[g]=3;  ans=ans+3;}
        else
        {
            d=c*(c-1); d=d/2;  nq[g]=d;   ans=ans+d;
        }
    }

    for(i=0;i<n;i++)
    {
        c=u[i];  f=ans-nq[c];

        e=mp[c]-1;

        if(e<2)d=0;
        else if(e==2)d=1;
        else if(e==3)d=3;
        else
        {
            d=e*(e-1);  d=d/2;
        }


        printf("%lld\n",f+d);


    }


    return 0;

}


Measured memory_bytes: 21820
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int A,B;
    cin >> A >> B;
    cout << max(0LL,A-B*2) << endl;
}


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

int main(){
  int n; int m;
  cin >> n >> m;
  bool islandsto[n+1];
  bool islandsfrom[n+1];

  for(int i=1; i<=n; i++){
    islandsto[i] = false;
    islandsfrom[i] = false;
  }

  int a, b;
  for(int i=0; i<m; i++){
    cin >> a >> b;
    if(a==1) islandsto[b] = true;
    if(b==n) islandsfrom[a] = true;
  }

  bool flag=false;

  for(int i=2; i<n; i++){
    if(islandsto[i] && islandsfrom[i]){
      flag = true;
      break;
    }
  }
  

  flag = flag || islandsto[n]==1;

  if(flag){
    cout << "POSSIBLE" << endl;
  }else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let n = s.len() as usize;

    let mut dp = vec![vec![0i64; 13]; n+1];

    dp[0][0] = 1;
    for i in 0..n {
        if s[i] == '?' {
            for j in 0..10 {
                for k in 0..13 {
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
                }
            }
        } else {
            let c = s[i] as usize - '0' as usize;
            for k in 0..13 {
                dp[i + 1][(k * 10 + c) % 13] += dp[i][k];
            }
        }

        for j in 0..13 {
            dp[i+1][j] %= 1000000007;
            //println!("({}, {}): {}", i, j, dp[i][j]);
        }
    }
    println!("{}", dp[n][5]);
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  ll a, b; cin >> a >> b;
  if (a == 1 || b == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll cnt = 0;
  if (a > b) swap(a, b);
  for (ll i = 2; i*i <= a; i++) {
    if (a%i == 0) {
      if (b%i == 0) cnt++;
      while (!(a%i)) a /= i;
    }
  }
  if (a != 1 && b%a == 0) cnt++;
  cout << cnt + 1 << endl;
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b, c; cin >> a >> b >> c;
	cout << (a^b^c);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import static java.lang.System.in;
import static java.lang.System.out;

import java.io.*;
import java.util.*;

public class Main {
	static final double EPS = 1e-10;
	static final double INF = 1L << 31;
	static final double PI = Math.PI;

	public static Scanner sc = new Scanner(in);
	StringBuilder sb = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public class UnionFind {

		  private int[] _parent;
		  private int[] _rank;


		  public int find(int i) {

		    int p = _parent[i];
		    if (i == p) {
		      return i;
		    }
		    return _parent[i] = find(p);

		  }


		  public void union(int i, int j) {

		    int root1 = find(i);
		    int root2 = find(j);

		    if (root2 == root1) return;

		    if (_rank[root1] > _rank[root2]) {
		      _parent[root2] = root1;
		    } else if (_rank[root2] > _rank[root1]) {
		      _parent[root1] = root2;
		    } else {
		      _parent[root2] = root1;
		      _rank[root1]++;
		    }
		  }


		  public UnionFind(int max) {

		    _parent = new int[max];
		    _rank = new int[max];

		    for (int i = 0; i < max; i++) {
		      _parent[i] = i;
		    }
		  }
	}

	public void run() throws IOException {
		String input;
		String[] inputArray;
		input = br.readLine();
		inputArray = input.split(" ");

		int n = Integer.valueOf(inputArray[0]);
		int m = Integer.valueOf(inputArray[1]);
		ArrayList<ArrayList<Integer>> langs = new ArrayList<ArrayList<Integer>>();
		for (int i=0; i<m; i++)
			langs.add(new ArrayList<Integer>());
		for (int i=0; i<n; i++){
			input = br.readLine();
			inputArray = input.split(" ");
			int k =  Integer.valueOf(inputArray[0]);
			for (int j=1; j<=k; j++){
				int l = Integer.valueOf(inputArray[j])-1;
				langs.get(l).add(i);
			}	
		}
		UnionFind U = new UnionFind(n);
		for (int i=0; i<m; i++){
			for (int j=1; j<langs.get(i).size(); j++)
				U.union(langs.get(i).get(0), langs.get(i).get(j));
		}
		int group = U.find(0);
		for (int i=1; i<n; i++){
			if (U.find(i)!=group){
				sb.append("NO");
				ln(sb);
				return;
			}
		}
		sb.append("YES");
		ln(sb);
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	public static void ln(Object obj) {
		out.println(obj);
	}
}


Measured memory_bytes: 37696
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

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

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	//入力;
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	REP(i, N - 2) {
		if (S[i] == 'A') {
			if (S[i + 1] == 'B') {
				if (S[i + 2] == 'C') {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;

	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <typeinfo>
using namespace std;
int main() {
	string a, b,ss;
	double ans;
	cin >> a >> b;
	int s;
	ss = a + b;
	s = stoi(ss);
	ans = sqrt(s);
	if (fmod(ans,1) == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;
vector<int> dp;
int sol(vector<int> a,int k,int i){
	if(i<0)
		return 0;
	if(i<=k){
		return dp[i]=abs(a[i]-a[0]);
	}
	if(dp[i]!=1e9)
		return dp[i];
	
	for(int j=1;j<=k;j++){
		dp[i]=min(dp[i],abs(a[i]-a[i-j])+sol(a,k,i-j));
	}
	// cout<<i<<" "<<dp[i]<<endl;
	return dp[i];
}

int main(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	dp.resize(n);
	for(int i=0;i<n;i++){
		dp[i]=1e9;
		cin>>a[i];
	}
	dp[0]=0;	
	// int ans=sol(a,k,n-1);

	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i+j<n)
				dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
		}
	}

	// for(auto i:dp)
	// 	cout<<i<<" ";
	// cout<<endl;
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LLONG_MAX : INT_MAX;
const int MOD = 1000000007;
const long double EPS = 1e-8;

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int x[n];
	rep (i, n) cin >> x[i];
	int ans = 0;
	rep (i, n - 1) ans += min(b, (x[i + 1] - x[i]) * a);
	cout << ans << endl;
	return 0;
}


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

/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

//const ll md = 1e9 + 7;//998244353;
const int xn = 5e5 + 10;
const int xm = 1e2 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int Md = 998244353;
const int TM = 3;
const int Base = 257;

ll n, num[xn], c[xn], f[xn], D, qq, x;

int main(){
    InTheNameOfGod;
    
    cin >> n >> D;
    for (int i = 1; i <= n; ++ i) cin >> num[i];
    c[0] = D;
    for (int i = 1; i <= n; ++ i){
    	c[i] = c[i - 1];
    	if (abs(c[i - 1] - num[i]) <= c[i - 1]) c[i] = abs(c[i - 1] - num[i]);
	}
	for (int i = n; i >= 1; -- i){
		f[i] = f[i + 1];
		if (f[i + 1] >= (num[i]) / 2 || f[i + 1] >= num[i] - 1) f[i] += num[i];
	}
    cin >> qq;
    while (qq --){
    	cin >> x;
    	if (f[x + 1] < c[x - 1]) cout << "YES" << endl;
    	else cout << "NO" << endl;
	}
	
    return 0;
}


Measured memory_bytes: 13696
#include <stdio.h>

int main () {
	int i, L, A, B, C, D, sum=0;
	scanf("%d%d%d%d%d", &L ,&A, &B, &C, &D);
	if (A/C >= B/D){
		sum = L - (A + C -1)/C;
	}else if (A/C < B/D) {
		sum = L - (B + D -1)/D;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 596
def main():
    n, k = map(int, input().split())
    people = [True for i in range(n)]
    for i in range(k):
        d = int(input())
        for j in map(lambda x: int(x)-1, input().split()):
            people[j] = False
    print(sum(people))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 67792
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n;  cin >> n;
    double ans;
    if (n%2 == 1) {
        ans = (n+1)/2.0/n;
        cout << ans << endl;
        return 0;
    }
    else {
        ans = 1.0 / 2.0;
        cout << ans << endl;
        return 0;
    }
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    if (s[0] == '1') ++ans;
    if (s[1] == '1') ++ans;
    if (s[2] == '1') ++ans;
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, m = map(int,input().split())
ab = []
for i in range(n):
    ab.append([int(i) for i in input().split()])

ab.sort()
ans = 0
drink = 0
i = 0
while drink < m:
    if drink + ab[i][1] <= m:
        ans += ab[i][0] * ab[i][1]
        drink += ab[i][1]
    else:
        ans += ab[i][0] * (m - drink)
        break
    i += 1
print(ans)


Measured memory_bytes: 21616
#include <cstdio>

int a, b, c, k, ans;

int main() {
    scanf("%d%d%d%d", &a, &b, &c, &k);
    if (a >= k) {
        printf("%d", k);
        return 0;
    }
    ans = a, k -= a;
    if (b >= k) {
        printf("%d", ans);
        return 0;
    }
    k -= b;
    printf("%d", ans - k);
}


Measured memory_bytes: 1732
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
import itertools

# import math

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


A, B = map(int, readline().split())
print(A*B//gcd(A,B))

Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll a,b,c,d;
    cin >>a>>b>>c>>d;
    
    cout << max({a*c,a*d,b*c,b*d}) << endl;


    return 0;
    

}

Measured memory_bytes: 3624
N, M = (int(x) for x in raw_input().split())
AB = [[int(x) for x in raw_input().split()] for i in xrange(N)]
AB.sort()
result = 0
for ab in AB:
	a, b = ab
	result += min(b, M) * a
	M -= min(b, M)
print(result)


Measured memory_bytes: 20412
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,f[300006],a,b,ans=1,max1[300006],s;
int find(int x)
{
	return x==f[x]?x:(f[x]=find(f[x]));
}
void merge(int i,int j)
{
	s=find(i);
	f[find(i)]=find(j);
	max1[f[j]]+=max1[s];
	if(ans<max1[f[j]])
	ans=max1[f[j]];
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		f[i]=i;max1[i]+=1;
	}
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",&a,&b);
		if(find(a)!=find(b))
		merge(a,b);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5392
#include<bits/stdc++.h>
using namespace std;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int s=0;
	char c=getchar();
	while (c=='-' || c=='+') {
		if (c=='-') --s;
		else ++s;
		c=getchar();
	}
	printf("%d\n", s); 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
#define INF -99999999 
using namespace std;
 
int main(){
    int N;
    string S;
    cin >> N >> S;
    ll a,b,c;
    a = b = c = 0;
    for (int i = 0; i < N; i++)
    {
        if(S[i] == 'R') a++;
        else if(S[i] == 'G') b++;
        else c++;
    }
    ll ans = a*b*c;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = i+1; j < N; j++)
        {
            ll k = 2*j-i;
            if(k >= N) continue;
            else if(S[i] != S[j] && S[i] != S[k] && S[k] != S[j]) ans -= 1;
        }
        
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define fr(n) for(ll i=0;i<n;i++)
#define frr(n) for(ll i=n;i>=0;i--)
#define nl printf("\n")
#define debug(arr,n) for(int i=0; i<n; i++) printf("%lld ", arr[i])
#define debugr(arr,s,e) for(int i=s; i<=e; i++) printf("%lld ", arr[i])

int main(){
    ll n,q;
    cin>>n>>q;
    vector<vector<int>>vec(n);
    while(q--){
        ll a,t,x;
        cin>>a;
        if(a==0){
            cin>>t>>x;
            vec[t].push_back(x);
        }
        else if(a==1){
            cin>>t;
            ll l=vec[t].size();
            if(!vec[t].empty()){
                for(ll i=0;i<l;i++){
                    cout<<vec[t][i];
                    if(i!=l-1) cout<<" ";
                }
            }
            nl;
        }
        else{
            cin>>t;
            for(auto c:vec[t]){
                vec[t].pop_back();
            }
        }
    }
    return 0;
}


Measured memory_bytes: 5868
import math

n, m = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


if n >= 2 and m >= 2:
    ans = combinations_count(m, 2) + combinations_count(n, 2)
elif n < 2 and m < 2:
    ans = 0
elif n < 2:
    ans = combinations_count(m, 2)
elif m < 2:
    ans = combinations_count(n, 2)


print(ans)


Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int low,high;
	int check=0;
	if((a*100)%8==0)
	low=(a*100)/8;
	else
	low=ceil((float)(a*100)/8);
	if(((a+1)*100)%8==0)
	high=((a+1)*100)/8-1;
	else
	high=floor((float)((a+1)*100)/8);
	//cout<<low<<" "<<high<<endl;
	for(int i=low;i<=high;i++){
		if(((i*10)/100)==b){
			cout<<i;
			check=1;
			break;
		}
	}
	if(check==0)
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll dp[101010][13];

int main(){
    string s;
    cin>>s;
    int n=s.size();

    dp[0][0]=1;

    rep(dgt,n) rep(mo,13){
        if(s[dgt]=='?'){
            rep(nxt,10){
                dp[dgt+1][(mo*10+nxt)%13]=(dp[dgt+1][(mo*10+nxt)%13]+dp[dgt][mo])%MOD;
            }
        }
        else{
            dp[dgt+1][(mo*10+s[dgt]-'0')%13]=(dp[dgt+1][(mo*10+s[dgt]-'0')%13]+dp[dgt][mo])%MOD;
        }
    }

    cout<<dp[n][5]<<endl;
    
}


 

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


struct Item {
    int a;
    int b;
    int price;
};

int dp[41][500][500];

int main(){
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    Item items[N];
    rep(i, N) {
        int a, b, p;
        cin >> a >> b >> p;
        items[i] = {a, b, p};
    }
    //N<=40, a,b<=10なので、最大400gしか買えない
    //i=買ったaの量、j=買ったbの量、値＝お値段とする
    const int MAX = 450;
    rep(i, N + 1) {
        rep(j, MAX) {
            rep(k, MAX) {
                dp[i][j][k] = INT_MAX;
            }
        }
    }
    int minPrice = INT_MAX;
    dp[0][0][0] = 0;
    rep(i, N) {
        Item item = items[i];
        rep(x, MAX) {
            rep(y, MAX) {
                if (dp[i][x][y] == INT_MAX) {
                    continue;
                }
                dp[i + 1][x][y] = min(dp[i + 1][x][y], dp[i][x][y]);
                int x2 = x + item.a;
                int y2 = y + item.b;
                int pp = dp[i][x][y] + item.price;
                dp[i + 1][x2][y2] = min(dp[i + 1][x2][y2], pp);
                if (x2 % Ma == 0 && y2 == Mb * (x2 / Ma)) {
                    minPrice = min(minPrice, pp);
                }
            }
        }
    }
    if (minPrice == INT_MAX) {
        cout << -1 << endl;
    } else {
        cout << minPrice << endl;
    }
    return 0;
}

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


template <typename Cost = int> class Edge{
public:
  int from,to;
  Cost cost;
  Edge() {}
  Edge(int to, Cost cost): to(to), cost(cost){}
  Edge(int from, int to, Cost cost): from(from), to(to), cost(cost){}

  Edge rev() const {return Edge(to,from,cost);}
  
  friend std::ostream& operator<<(std::ostream &os, const Edge &e){
    os << "(FROM: " << e.from << "," << "TO: " << e.to << "," << "COST: " << e.cost << ")";
    return os;
  }
};

template <typename T> using Graph = std::vector<std::vector<Edge<T>>>;
template <typename T> using Tree = std::vector<std::vector<Edge<T>>>;

template <typename C, typename T> void add_edge(C &g, int from, int to, T w){
  g[from].push_back(Edge<T>(from, to, w));  
}

template <typename C, typename T> void add_undirected(C &g, int a, int b, T w){
  g[a].push_back(Edge<T>(a, b, w));
  g[b].push_back(Edge<T>(b, a, w));
}



std::vector<int> bfs_0_1(const Graph<int> &g, const std::vector<int> &src){
  int n = g.size();
  std::vector<int> ret(n, INT_MAX);
  std::vector<bool> visited(n);

  for(auto i : src) ret[i] = 0;
  std::deque<int> dq(src.begin(), src.end());

  while(not dq.empty()){
    int cur = dq.front(); dq.pop_front();

    if(visited[cur]) continue;
    visited[cur] = true;

    for(auto &e : g[cur]){
      if(ret[e.to] > ret[e.from] + e.cost){
        ret[e.to] = ret[e.from] + e.cost;
        
        if(e.cost == 0) dq.push_front(e.to);
        else dq.push_back(e.to);
      }
    }
  }
  
  return ret;
}




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

  int N,M;
  while(std::cin >> N >> M){
    std::vector<int> p(M), q(M), c(M);
    for(int i = 0; i < M; ++i){
      std::cin >> p[i] >> q[i] >> c[i];
      --p[i], --q[i];
    }
    
    std::vector<std::map<int,int>> a(N);
    std::vector<std::set<int>> cs(N);

    for(int i = 0; i < M; ++i){
      cs[p[i]].insert(c[i]);
      cs[q[i]].insert(c[i]);
    }

    int k = N;
    for(int i = 0; i < N; ++i){
      for(auto j : cs[i]){
        a[i][j] = k;
        ++k;
      }
    }

    Graph<int> g(k);
    
    
    for(int i = 0; i < N; ++i){
      for(auto &kv : a[i]){
        g[i].push_back(Edge<int>(i, kv.second, 1));
        g[kv.second].push_back(Edge<int>(kv.second, i, 0));
      }
    }

    for(int i = 0; i < M; ++i){
      g[a[p[i]][c[i]]].push_back(Edge<int>(a[p[i]][c[i]], a[q[i]][c[i]], 0));
      g[a[q[i]][c[i]]].push_back(Edge<int>(a[q[i]][c[i]], a[p[i]][c[i]], 0));
    }
    
    auto ans = bfs_0_1(g, {0});

    std::cout << (ans[N-1] == INT_MAX ? -1 : ans[N-1]) << std::endl;
  }
  
  return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a>>b>>c;
  cout <<c<<' '<<a<<' '<<b;
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll a[N], sum[N];
unordered_map<ll, ll> mem;
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        ll n, k;
        cin >> n >> k;
        for (int i = 1; i <= n; i++){
                cin >> a[i];
        }
        ll cur = 0, ans = 0;
        mem[0]++;
        for (int i = 1; i <= n; i++){
                cur = cur + a[i];
                sum[i] = (cur - i) % k;
                if (i >= k) mem[sum[i - k]]--;
                ans += mem[(cur - i) % k];
                mem[(cur - i) % k]++;
        }
        cout << ans;
}


Measured memory_bytes: 11592
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;

int keta(LL a, LL b) {
	LL c;
	if (a > b)c = a;
	else c = b;
	int ans = 0;
	while (c) {
		c /= 10;
		ans++;
	}
	return ans;
}
int main() {
	LL a;
	cin >> a;
	int ans = 1000000;
	for (LL i = 1; i*i <= a; i++) {
		if (a%i == 0) {
			LL b = a / i;
			ans = min(ans, keta(i, b));
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define li long 
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
void optimize()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll power(ll x, ll y) 
{ 
   ll res = 1;       
  
   // x = x   
  
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = (res*x); 
  
        
        y = y>>1;  
        x = (x*x);  
    } 
    return res; 
} 
long long gcd(long long a, long long b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
long long lcm(long long a, long long b)  
{  
    return (a*b)/gcd(a, b);  
} 
ll cal(ll n)
{
    if(n<=0)return 1*1LL;
    else return n*cal(n-2);
}
void test_case()
{
   ll n;
   cin>>n;
   ll count = 0;
   if(n&1)cout<<0;
   else{
       ll num = 10;
   while(n/num>0)
   {
      count+=(n/num);
      num*=5;
   }
   cout<<count;
   }
}

int main()
{
	optimize();
	test_case();
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, A, B, C;
  cin>>N>>A>>B>>C;
  int l[N];
  for(int i=0;i<N;++i) cin>>l[i];
  vector<int> arr1, arr2;
  int num1, num2;
  int tmp1, tmp2;
  int ans = inf;
  int tmp;
  int tmpnum1, tmpnum2;
  int len1, len2;
  for(int bit1=0;bit1<(1<<N);++bit1) {
    arr1.clear();
    arr2.clear();
    for(int i=0;i<N;++i) {
      if((bit1&(1<<i))==0) arr1.push_back(i);
      else arr2.push_back(i);
    }
    num1 = arr1.size();
    num2 = arr2.size();
    tmp1 = inf;
    tmp2 = inf;
    if(num1==0 || num2==0) continue;
    for(int bit2=0;bit2<(1<<num1);++bit2) {
      tmpnum1=0;
      tmpnum2=0;
      len1=0;
      len2=0;
      for(int i=0;i<num1;++i) {
        if((bit2&(1<<i))==0) {
          tmpnum1++;
          len1 += l[arr1[i]];
        }
        else {
          tmpnum2++;
          len2 += l[arr1[i]];
        }
      }
      if(tmpnum1==0 || tmpnum2==0) continue;
      tmp = 10*(tmpnum1-1)+10*(tmpnum2-1)+abs(A-len1)+abs(B-len2);
      tmp1 = min(tmp1, tmp);
    }
    for(int bit2=0;bit2<(1<<num2);++bit2) {
      tmpnum1=0;
      len1=0;
      for(int i=0;i<num2;++i) {
        if((bit2&(1<<i))==0) {
          tmpnum1++;
          len1 += l[arr2[i]];
        }
      }
      if(tmpnum1==0) continue;
      tmp = 10*(tmpnum1-1)+abs(C-len1);
      tmp2 = min(tmp2, tmp);
    }
    ans = min(ans, tmp1+tmp2);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3528
n,m = map(int,raw_input().split())
a = []
buf = -111
for q in range(m):
  a.append(int( raw_input() ))
  buf = a[q]
  if buf - a[q] == 1:
    print 0
    exit(0)

if n==1:
  print 1
  exit(0)
if n==2:
  if m==1:
    print 1
    exit(0)
  if m==0:
    print 2
    exit(0)

now = [-1]*100001

if m == 0:
  now[0] = 1
  now[1] = 1
  for q in range(2,n+1):
    now[q] = (now[q-1] + now[q-2]) % 1000000007
  print now[q] % 1000000007
  exit(0)
    
now[0] = 1
if a[0] == 1: now[1] = 0
else: now[1] = 1

for q in a:
  now[q] = 0

for q in range(2,n+1):
  if now[q] != -1: continue
  now[q] = (now[q-1] + now[q-2]) % 1000000007
  
print now[q] % 1000000007

Measured memory_bytes: 9844
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int search(const vll& a, const int K, vector<short int>& dp){
  if(dp[K]>=0) return dp[K];
  for(ll num : a){
    if(num <= K){
      int tmp = search(a, K-num, dp);
      if(tmp%2==0){
        return dp[K] = (tmp+1)%2;
      }
    }
  }
  return dp[K] = 0;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vll a(N);
  rep(i, 0, N){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<ll>());
  vector<short int> dp(K+1, -1);

  if(search(a, K, dp)%2==1) printf("First\n");
  else printf("Second\n");

  return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[maxn];
int main()
{
    int n,x=0,y=0,z=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%4!=0)
        {
            if(a[i]%2==0)
                a[i]=2;
            else a[i]=1;
        }
        else a[i]=4;
        if(a[i]==1) x++;
        else if(a[i]==2) y++;
        else z++;
    }
    if(y==0)
    {
        if(x>z+1) printf("No\n");
        else printf("Yes\n");
    }
    else if(y==1)
    {
        x++;
        if(x>z+1) printf("No\n");
        else printf("Yes\n");
    }
    else if(y==2)
    {
        if(x>z) printf("No\n");
        else printf("Yes\n");
    }
    else
    {
       if(x>z) printf("No\n");
       else printf("Yes\n");
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
int n,m;
int ans;
int a,b;

struct dsu{
    int p[200001],r[200001];
    void init(int n){
        rep2(i,1,n){
            p[i] = i;
            r[i] = 1;
        }
    }
    int find(int u){
        if(u == p[u]) return u;
        return p[u] = find(p[u]);
    }
    int merge(int u, int v){
        u = find(u); v = find(v);
        if(u == v) return 0;

        if(r[u] > r[v]){
            r[u] += r[v];
            p[v] = u;
        }
        else{
            r[v] += r[u];
            p[u] = v; 
        }
        return 1;
    }
};

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n >> m;
    dsu d;
    d.init(n);
    ans = -10;

    rep1(i,0,m){
        cin >> a >> b;
        d.merge(a,b);
    }

    rep2(i,1,n){
        ans = max(ans, d.r[i]);
    }
    cout << ans;
	return 0;
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef char* String;

String string_input(void){
    int i,len;
    char buf[100];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    
    len=strlen(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    String* S;
    NEW(S,N);
    for(int i=0;i<N;i++){
        S[i]=string_input();
    }

    int* ans;
    NEW(ans,26);
    for(int i=0;i<26;i++) ans[i]=50;

    int* tmp;
    NEW(tmp,26);
    for(int i=0;i<N;i++){
        for(int j=0;j<26;j++) tmp[j]=0;

        for(int j=0;j<strlen(S[i]);j++){
            tmp[S[i][j]-'a']++;
        }

        for(int j=0;j<26;j++) ans[j]=MIN(ans[j],tmp[j]);
    }

    for(int i=0;i<26;i++){
        char c='a'+i;
        for(int j=1;j<=ans[i];j++) printf("%c",c);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  unsigned long long sum = 0;
  for(int i = 1; i < n + 1; i++){
  	if(i % 3 != 0 && i % 5 != 0){
    	sum += i;
      
    }
  }
  cout << sum;
}

Measured memory_bytes: 3636
S=gets.chop.chars
ans=[0]*S.size
S.each.with_index do |c,i|
  next if c==?R
  next if S[i-1]==?L
  ans[i]=1
  1.upto(i) do |l|
    c=S[i-l]
    break if c==?L
    ans[i-l[0]]+=1
  end
  1.upto(S.size-1-i) do |r|
    c=S[i+r]
    break if c==?R
    ans[i-r[0]]+=1
  end
end
puts ans*" "

Measured memory_bytes: 23636
#ifndef _MSC_VER
#pragma GCC optimize("O3")
#include "bits/stdc++.h"
#endif

using namespace std;

#define LOCAL 0
#define ll long long

const ll INF = (ll)4e18;

int main()
{
#if LOCAL == 1
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif
    
    int n, x;
    cin >> n >> x;
    
    vector <int> a(n);
    
    for (int i = 0; i < n; ++i)
        cin >> a[i];
        
    vector < vector <int> > b(n, vector <int> (n));
    
    for (int i = 0; i < n; ++i)
    {
        b[i][0] = a[i];
        for (int j = 1; j < n; ++j)
            b[i][j] = min(b[i][j - 1], a[(i - j + n) % n]);
    }
    
    ll best = INF;
    for (int i = 0; i < n; ++i)
    {
        ll sum = 1LL * x * i;
        for (int j = 0; j < n; ++j)
            sum += b[j][i];
        best = min(best, sum);
    }
    
    cout << best;
    
    return 0;
}


Measured memory_bytes: 16000
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
using namespace std;
#define pb push_back
typedef long long lint;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
int main(){
	int n,m,r,q,i,j;vector <int> out;
	while(1){
		cin>>n>>m;
		if(n==0) break;
		vector<vector<int> > sei(m+1,vector<int>(1300,0));
		int r,q;
		cin>>r;
		for(i=0;i<r;i++){
			int t1,n1,m1,s;cin>>t1>>n1>>m1>>s;
			if(s==1) sei[m1][t1]++;
			else sei[m1][t1]-=1;
		}
		for(i=0;i<=m;i++){
			for(j=500;j<=1295;j++){
				sei[i][j]+=sei[i][j-1];
			}
		}
		cin>>q;
		for(i=0;i<q;i++){
			int s2,e,m2;cin>>s2>>e>>m2;
			int ret=0;
			for(j=s2;j<e;j++) if(sei[m2][j]>0) ret++;
			out.pb(ret);
		}
	}
	for(i=0;i<out.size();i++) cout<<out[i]<<endl;
	return 0;
}

Measured memory_bytes: 49000
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A, B; cin >> A >> B;

	bool ans = false;
	if(A%3 == 0) ans = true;
	else if(B%3 == 0) ans = true;
	else if((A+B)%3 == 0) ans = true;

	if(ans == true) cout << "Possible" << endl;
	else cout << "Impossible" << endl;


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if (k <= a) {
        cout << (a - k) << " " << b << endl;
    }
    else if (k <= a + b) {
        cout << 0 << " " << (a + b - k) << endl;
    }
    else {
        cout << 0 << " " << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define sd(n) scanf("%d",&n)
#define ll long long
const int maxn=2e5+100;
int a[maxn],dp[maxn];
int main(){
    int n;
    sd(n);
    for(int i=1;i<=n;++i)sd(a[i]);
    int ans=0,now=0,v[2],p[2];
    for(int i=0;i<=n+1;++i){
        p[0]=0,p[1]=a[i]-now;
        if(p[0]<p[1])swap(p[0],p[1]);//
        int nxt[3]={1000000000,1000000000,0};
        for(int j=0;j<2;++j){
            for(int k=0;k<2;++k){
                nxt[j+k]=min(max(0,v[j]+p[k]),nxt[j+k]);
            }
        }
        int d=nxt[0]>a[i];
        for(int u=0;u<2;++u)v[u]=nxt[u+d];

        ans+=d;
        now=a[i];
    }
cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
import math
def solve():
  n = int(input())
  a = [int(input()) for _ in range(5)]
  #step1to2
  time = 0
  time += math.ceil(n/a[0])
  people = a[0]
  #print(time)
  #step2to3
  for i in range(1,5):
    if people <= a[i]:
      time += 1
    else:
      
      time += 1+math.ceil(n/a[i])-math.ceil(n/people)
      people = min(people,a[i])
    #print(time)
  print(time)
      
    
solve()

Measured memory_bytes: 3064
n, a, b = map(int, input().split())
mod = 10 **9 +7
fac = [1] * 200001
inv = [1] * 200001
for i in range(1,len(fac)):
    fac[i] = fac[i-1] * i % mod
    inv[i] = pow(fac[i], mod-2, mod)

facna = 1
facnb = 1
for i in range(n-a+1,n+1):
    facna = facna * i %mod
for i in range(n-b+1,n+1):
    facnb = facnb * i %mod
ret = pow(2,n,mod) - 1 - facna * inv[a] - facnb * inv[b]
ret = ret%mod
print(ret)


Measured memory_bytes: 18764
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, h;
    cin >> n >> h;
    vector<pii> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a.rbegin(), a.rend());
    vector<int> gr;
    for(int i = 0; i < n; i++) {
        if(a[i].se >= a[0].fi) {
            gr.push_back(a[i].se);
        }
    }
    sort(gr.rbegin(), gr.rend());
    int ans = 0, sum = 0;
    for (int i = 0; i < sz(gr); i++) {
        if (sum < h) {
            ans++;
            sum += gr[i];
        }
    }
    if(sum < h) {
        ans += ceil(1.0 * (h - sum) / a[0].fi); 
    }
    cout << ans << "\n";
}

Measured memory_bytes: 2936
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <complex>
#include <map>
#include <set>


#define forin(i, f, t) for(ll i = f; i < t; i++)

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using Pair = pair<ll, ll>;

const int MAX = 50;

double arg(Pair center, Pair pos) {
    return atan2(pos.second - center.second, pos.first - center.first);
}

int main() {
    int n;
    cin >> n;
    
    if (n == 2) {
        cout << 0.5 << endl << 0.5 << endl;
        return 0;
    }
    
    vector<Pair> hole(n);
    for (auto i = 0; i < n; i++) {
        cin >> hole[i].first >> hole[i].second;
    }
    
    vector<double> ans;
    for (auto c : hole) {
        vector<double> args;
        for (auto h : hole) {
            if (c == h)
                continue;
            args.push_back(arg(c, h));
        }
        sort(args.begin(), args.end());
        
        if (args.back() - args.front() <= M_PI) {
            auto theta = args.back() - args.front();
            ans.push_back(0.5 - theta / (2 * M_PI));
        } else {
            bool isConv = false;
            for (auto i = 0; i < args.size() - 1; i++) {
                if (args[i + 1] - args[i] >= M_PI) {
                    isConv = true;
                    auto theta = args[i + 1] - args[i];
                    ans.push_back(theta / (2 * M_PI) - 0.5);
                    break;
                }
            }
            if (!isConv)
                ans.push_back(0);
        }
    }
    
    for (auto a : ans)
        cout << a << endl;
    
    
}



Measured memory_bytes: 640
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int h, n;
  cin >> h >> n;
  vector<int> dp(h + 1, INF);
  dp[0] = 0;
  rep(i, n)
  {
    int a, b;
    cin >> a >> b;
    rep(j, h)
    {
      int nj = j + a;
      nj = min(nj, h);
      dp[nj] = min(dp[nj], dp[j] + b);
    }
  }
  cout << dp[h] << "\n";
  return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353; //1000000007;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	int A, B;
	get(A, B);

	int H = 100, W = 100;
	std::vector<std::vector<char>> grid(H, std::vector<char>(W, '#'));
	for (int h = 50; h < H; h++) {
		for (int w = 0; w < W; w++) {
			grid[h][w] = '.';
		}
	}

	int nh = 0, nw = 0;
	for (int a = 1; a < A; a++) {
		grid[nh][nw] = '.';
		nw += 2;

		if (nw >= W - 1) {
			nh += 2;
			if (nw % 2) {
				nw = 0;
			}
			else {
				nw = 1;
			}
		}
	}
	nh = H / 2 + 1;
	nw = 0;
	for (int b = 1; b < B; b++) {
		grid[nh][nw] = '#';
		nw += 2;

		if (nw >= W - 1) {
			nh += 2;
			if (nw % 2) {
				nw = 0;
			}
			else {
				nw = 1;
			}
		}
	}
	printf("%d %d\n", H, W);

	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			printf("%c", grid[h][w]);
		}
		putchar('\n');
	}
}


Measured memory_bytes: 3700