akhauriyash/Code-Regression huggingface dataset:
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

double dp[2][210];
int N, t[210], v[210], lim[40010];

signed main() {
    cin >> N;
    rep(i,0,N) cin >> t[i];
    rep(i,0,N) cin >> v[i];
    int sum = 0;
    rep(i,0,N) rep(j,0,t[i]) rep(k,0,2) lim[sum++] = v[i] * 2;
    rep(i,0,2) rep(j,0,210) dp[i][j] = -1.0;

    dp[0][0] = 0.0;
    rep(i,0,sum) {
        int mo = i % 2;
        repq(j,0,lim[i]) {
            if(dp[mo][j] < 0) continue;
            rep(k,-1,2) {
                // up -> do not exceed
                if(j+k < 0 || j+k > lim[i+1]) continue;
                if(k == 1 && j+k > lim[i]) continue;
                chmax(dp[mo^1][j+k], dp[mo][j] + (j + k/2.0) / 4.0);
            }
        }
        fill(dp[mo], dp[mo]+210, -1.0);
    }
    printf("%.12f\n", dp[sum%2][0]);
    return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 500010
const int MOD = 1000000007;

string s;

int lazy[4 * maxn], ar[maxn], tree[4 * maxn];

int doit(int a, int b) {
    return a | b;
}

void build(int start, int end, int index = 1) {
    if (start == end) {
        tree[index] = 1 << (s[start] - '0');
        return;
    }
    int mid = start + end >> 1;
    build(start, mid, 2 * index);
    build(mid + 1, end, 2 * index + 1);
    tree[index] = doit(tree[2 * index], tree[2 * index + 1]);
}

int queryTree(int start, int end, int l, int r, int index = 1) {
    if (r < start or l > end)
        return 0;

    if (l <= start and r >= end)
        return tree[index];

    int mid = start + end >> 1;
    return doit(queryTree(start, mid, l, r, 2 * index), queryTree(mid + 1, end, l, r, 2 * index + 1));
}

void update(int start, int end, int x, char val, int index = 1) {
    if (x < start or x > end)
        return;

    if (start == end) {
        tree[index] = 1 << (val - '0');
        return;
    }

    int mid = start + end >> 1;
    update(start, mid, x, val, 2 * index);
    update(mid + 1, end, x, val, 2 * index + 1);
    tree[index] = doit(tree[2 * index], tree[2 * index + 1]);
}

void solve() {
    int n;
    cin >> n;
    cin >> s;

    build(0, n - 1);
    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int type;
        cin >> type;

        if (type == 1) {
            int idx;
            char ch;
            cin >> idx >> ch;
            idx--;

            update(0, n - 1, idx, ch);
        }
        else {
            int l, r;
            cin >> l>> r;

            cout << __builtin_popcount(queryTree(0, n- 1,l - 1, r- 1, 1)) << endl;
        }
    }

}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 11292
//
// Created by 中野誠大 on 2019-03-03.
//

#include<iostream>

#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;
//using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
const long long INF = 1LL << 60;

int main(){
    string s;
    cin >> s;
    int p = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] == 'p') p++;
    }
    
    cout << s.size()/2 - p << endl;
    //printf("%d", (s.size() >> 1) - p);
    return 0;
}

Measured memory_bytes: 512
// while( !(succeed == try()) );

#include "bits/stdc++.h"
using namespace std;

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha // Alpha


void alpha()
{	
	int x;
	cin>>x;

	int t1 = x/500;
	int rem = x%500;
	int t2 = rem/5;

	cout<<t1*1000+t2*5<<endl;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 256
<?php
$input = explode(" ", trim(fgets(STDIN)));
$N = (integer)$input[0];
$Y = (integer)$input[1];
$a = 0;

for ($i=0; $i<=$N; $i++){
    for ($j=0; $j<=$N; $j++){
        $k = $N-$i-$j;
        if ($k < 0){
            $k = 0;
        }
        $total = $i*10000+$j*5000+$k*1000;
        $cnt = $i+$j+$k;
        if (($total==$Y)and($cnt==$N)){
            $a = print "{$i} {$j} {$k}";
            break 2;
        }
    }
}
if ($a == 0){
    print '-1 -1 -1';
}

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

#define testc int t;cin>>t;while(t--)
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define repi(i,n) for(int i=0;i<n;++i)
#define REPI(i,n) for(int i=0;i<=n;++i)

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vld vector < ld >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define mod 1000000007


//Declare needed variables
int n;

void scan_var(){
    cin>>n;
}

void solve(){
    vi v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    vi cost(n);
    cost[0] = 0;
    cost[1] = abs(v[1] - v[0]);
    for(int i=2;i<n;i++){
        cost[i] = min(cost[i-1]+abs(v[i-1]-v[i]),cost[i-2]+abs(v[i-2]-v[i]));
    }
    cout<<cost[n-1]<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    scan_var();
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 440

int n, m, ans;
bool f[AC][AC];

inline int read()
{
	int x = 0;char c = getchar();
	while(c > '9' || c < '0') c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x;
}

void pre(){
	n = read(), m = read();	
}

void work()
{
	for(R i = 1; i <= m; i ++)
	{
		int x = read(), y = read();
		if(f[y][y] || f[x][x]) //这一切的前提都是自己要活着。。。。
		{
			f[x][x] = f[y][y] = true;
			continue;
		}
		for(R j = 1; j <= n; j ++) 
			if(f[x][j])	f[y][j] = f[j][y] = true;//找到y需要连哪些边
		for(R j = 1; j <= n; j ++) 
			if(f[y][j]) f[x][j] = f[j][x] = true;
		f[x][y] = f[y][x] = true;
	}
	
	for(R i = 1; i <= n; i ++)
		for(R j = i + 1; j <= n; j ++) 
			if(!f[i][j] && !f[j][j] && !f[i][i]) ++ ans;//需要两者都不是必须死的，而且没有不能共存的限制
	printf("%d\n", ans);
}

int main()
{
	//freopen("in.in", "r", stdin);
	pre();
	work();
//	fclose(stdin);
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#define TRUE 1
#define FALSE 0
int isPrime(int);
int main(void){
    int N;
    int count = 0;
    //数の上限
    scanf("%d",&N);
    int num[N];
    for(int i = 0;i < N;i++){
        scanf("%d",&num[i]);
        if(isPrime(num[i]) == TRUE) count++;
    }
    printf("%d\n",count);
}

int isPrime(int num){
    int i = 3;
    if(num == 2) return TRUE;
    if((num < 2) || (num % 2 == 0)) return FALSE;
    while(i <= sqrt(num)){
      if(num % i == 0) return FALSE;
        i = i + 2;
    }
    return TRUE;
}


Measured memory_bytes: 2080
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

int main()
{
	int N;
	cin >> N;
	auto x = N % 1000;
	int ans = 0;
	if (x == 0)
		ans = 0;
	else
		ans = 1000 - x;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/12/20 07:29:17
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,a,b; cin>>n>>a>>b;
  string s; cin>>s;
  int sum = 0;
  int cb = 0;
  for (auto c:s) {
    bool ac = true;
    if (c=='a') {
      if (sum < a+b) {
        ++sum;
        ac = true;
      } else {
        ac = false;
      }
    } else if (c =='b') {
      if (sum < a+b and cb < b) {
        ac = true;
        ++sum; ++cb;
      } else {
        ac = false;
      }
    } else {
      ac = false;
    }
    cout << (ac ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 848
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int over = 0, over_a = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i]=='a') {
      if (over<a+b) {
        cout << "Yes" << endl;
        over++;
      } else {
        cout << "No" << endl;
      }
    } else if (s[i]=='b') {
      if (over<a+b && over_a<b) {
        cout << "Yes" << endl;
        over++; over_a++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 848
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
#define INF 114514
using namespace std;




int main(){
	int w, m;
	while (1) {
		int n, sum = 0;
		cin >> m;
		if (m == 0) return 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			int a, b;
			cin >> a >> b;
			sum += b - a;
		}
		if (sum >= m) cout << "OK" << endl;
		else cout << m - sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define mp map<ll,ll>
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const ll inf=1e+18;


int32_t main(){
    
    fast;
    
    ll x;
    cin>>x;

    
    ll ans = 1000 * (x/500);
    x = x%500;
    ans = ans + 5*(x/5);

    cout<<ans;

    return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mod = 1_000_000_007;
        int n = sc.nextInt();
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        long[][] dp = new long[n+1][9]; // rr,rb,rg,br,bb,bg,gr,gb,gg
        int idx = 0;
        if(a[0] == b[0]){
            dp[1][0] = 1L; dp[1][4] = 1L; dp[1][8] = 1L;
            idx = 2;
        }else{
            dp[2][1] = dp[2][2] = dp[2][3] = dp[2][5] = dp[2][6] = dp[2][7] = 1L;
            idx = 3;
        }
        for (int i = idx; i <= n; i++) {
            if(a[i-1] == b[i-1]){
                dp[i][0] = (dp[i-1][4] + dp[i-1][5] + dp[i-1][7] + dp[i-1][8])%mod;
                dp[i][4] = (dp[i-1][4] + dp[i-1][5] + dp[i-1][7] + dp[i-1][8])%mod;
                dp[i][8] = (dp[i-1][4] + dp[i-1][5] + dp[i-1][7] + dp[i-1][8])%mod;
            }else{
                i++;
                dp[i][1] = (dp[i-2][3] + dp[i-2][5] + dp[i-2][6] + dp[i-2][8])%mod;
                dp[i][2] = (dp[i-2][3] + dp[i-2][4] + dp[i-2][6] + dp[i-2][7])%mod;
                dp[i][3] = (dp[i-2][1] + dp[i-2][2] + dp[i-2][7] + dp[i-2][8])%mod;
                dp[i][5] = (dp[i-2][0] + dp[i-2][1] + dp[i-2][6] + dp[i-2][7])%mod;
                dp[i][6] = (dp[i-2][1] + dp[i-2][2] + dp[i-2][4] + dp[i-2][5])%mod;
                dp[i][7] = (dp[i-2][0] + dp[i-2][2] + dp[i-2][3] + dp[i-2][5])%mod;
            }
        }
        long ans = 0L;
        for (int i = 0; i < 9; i++) ans = (ans + dp[n][i])%mod;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 21844
#include <stdio.h>
#define N 101
#define MIN 1000000
   int main(){
  int i,j,n,min,a,b,c;
  int G[N][N],k[N],d[N];
   
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    k[i]=0;
    d[i]=MIN;
    for(j=0;j<n;j++){
      G[i][j]=-1;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      scanf("%d",&G[a][c]);
    }
  }
  d[0]=0;
  while(1){
    min=MIN;
    for(i=0;i<n;i++){
      if(k[i]!=1&&d[i]<min){
        min=d[i];
        a=i;
      }
    }
   
    if(min==MIN){
      break;
    }
    for(i=0;i<n;i++){
      if(G[a][i]!=-1&&k[i]!=1&&d[a]+G[a][i]<d[i])
        d[i]=d[a]+G[a][i];
    }
    k[a]=1;
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main() {
  int num1,num2,ans1,ans2;
  scanf("%d %d",&num1, &num2);
  ans1 = num1*num2;
  ans2 = 2*(num1+num2);
  printf("%d %d\n",ans1,ans2);
  return 0;
}



Measured memory_bytes: 2712
S = input()
K = int(input())
SS = S[::-1]

count = 0
l = len(S)
check = True
ff = 1
while ff < l:
    if S[ff] == S[0]:
        ff += 1
    else:
        break
ll = 1
while ll < l:
    if SS[ll] == SS[0]:
        ll += 1
    else:
        break

if S[0] != SS[0]:
    ff = 0
    ll = 0

if ff == l:
    print(l * K // 2)
    exit()

i = ff
c = 1
while i < l - ll - 1:
    if S[i] == S[i + 1]:
        c += 1
    else:
        count += c // 2
        c = 1
    i += 1
count += c // 2

# print(count, ff, ll)

print(K * count + (K - 1) * ((ff + ll) // 2) + ff // 2 + ll // 2)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[100005],oj[100005];
int main()
{
	std::ios::sync_with_stdio(false);
	int n,sum=0,max=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<=n) 
		{
			oj[a[i]]++;
			if(a[i]>max) max=a[i];
		}
		else sum++;
	}
	for(int i=1;i<=max;i++)
	{
		if(oj[i]!=i&&oj[i]!=0)
		{
			if(oj[i]>i) sum+=oj[i]-i;
			else sum+=oj[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 768
a,b,c = gets.split.map(&:to_i)
h = {}
h[[a,b,c]] = true
count = 0
loop do
  break if a.odd? || b.odd? || c.odd?
  count += 1
  na = (b+c)/2
  nb = (a+c)/2
  nc = (a+b)/2
  a,b,c = [na, nb, nc]
  if h[[a,b,c]]
    puts (-1)
    exit
  end
end
puts count


Measured memory_bytes: 1788
while True:
    M, T, P, R = map(int, input().split())
    if M == T == P == R == 0:
        quit()
    a_list = [[0, 0, i] for i in range(T)]
    wa = [[0 for j in range(P)] for i in range(T)]
    for i in range(R):
        m, t, p, j = map(int, input().split())
        t -= 1
        p -= 1
        if j == 0:
            a_list[t][0] += m + wa[t][p]*20
            a_list[t][1] += 1
        else:
            wa[t][p] += 1
    a_list.sort(key=lambda x: x[2], reverse=True)
    a_list.sort(key=lambda x: x[0])
    a_list.sort(key=lambda x: x[1], reverse=True)
    temp = [-1, -1]
    ans = ''
    for i in range(len(a_list)-1):
        ans += str(a_list[i][2]+1)
        if a_list[i][0] == a_list[i+1][0] and a_list[i][1] == a_list[i+1][1]:
            ans += '='
        else:
            ans += ','
    ans += str(a_list[-1][2]+1)
    print(ans)


Measured memory_bytes: 7832
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200004],num[35];
map <ll,ll> mp;
int main(){
	ll n;
	cin>>n;
	num[0]=2;
	for (ll i=1;i<35;i++) num[i]=num[i-1]*2;
	for (ll i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	sort (a,a+n);
	ll ans=0;
	for (ll i=n-1;i>=0;i--){
		ll aa=lower_bound(num,num+35,a[i])-num;
		if (a[i]==num[aa]) aa++;
		ll l=num[aa]-a[i];
		mp[a[i]]--,mp[l]--;
		if (mp[a[i]]<0 || mp[l]<0) mp[a[i]++],mp[l]++;
		else ans++;
	}
	cout<<ans;
	return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

class ModInt{
public:
    long long n;
    int p;

    ModInt(){
    }

    //値と割る値を受け取って、オブジェクトを返す
    ModInt(long long _n, int _p){
        p = _p;
        n = _n % _p;

        //負の値を受け取ったときには正の値に戻す
        if(n < 0){
            n += p;
        }
    }

    ModInt operator+(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n += a.n;

        if(tmp.n > tmp.p){
            tmp.n -= tmp.p;
        }
        
        return tmp;
    }

    ModInt operator-(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n -= a.n;

        if(tmp.n < 0){
            tmp.n += tmp.p;
        }

        return tmp;
    }

    ModInt operator*(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = (tmp.n * a.n) % tmp.p;

        return tmp;
    }

    int modpow(int b, int k){
        if(k == 0){
            return 1;
        }else if(k % 2 == 1){
            long long tmp = b;
            tmp = tmp * modpow(b, k - 1) % p;
            
            return tmp;
        }else{
            long long tmp = modpow(b, k / 2);
            return tmp * tmp % p;
        }
    }

    int modinv(int b){
        return modpow(b, p - 2);
    }

    ModInt operator/(ModInt a){

        ModInt tmp = ModInt(*this);

        tmp.n = tmp.n * modinv(a.n) % tmp.p;
        return tmp;
    }
};

ll f(ll n, ll k){
    ll min = (k - 1)* k/2;
    ll max = (n + (n - k + 1)) * k / 2;

    return max - min + 1;
}

int main(){

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

    ModInt ans = ModInt(0, MODN);

    for(int i = k; i <= n + 1; i++){
        //n + 1こからkことる
        //cerr << f(n + 1, i) << endl;
        ans = ans + ModInt(f(n, i), MODN);
    }

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


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<fstream>

#define SIZE 9

using namespace std;

int n;
int k;
int w[100001];
int mid;

bool check(int high,int low){
	mid = (high+low)/2;
	int tmp = 1;
	int weight = 0;
	for(int i=0;i<n;i++){
		if(weight+w[i] > mid){
			if(w[i]>mid) return false;
			tmp++;
			if(tmp > k) return false;
			weight = 0;
		}
		weight += w[i];
	}
	return true;
}

int main(){
	int p;
	int low,high;

	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>w[i];
	low = 0;
	high = 900000000;
	while(high-low > 1){
		if(check(high,low)) high=mid;
		else low = mid;
	}
	p = high;
	cout<<p<<endl;
	return 0;
}

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
   int h,a;
   cin>>h>>a;
   cout<<(h+a-1)/a<<endl;
   
   
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	long long ans = 0;
	for (int i = 0; i < n / 2; i++) {
		ans += a[n - 1 - i] - a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <complex>
#include <cmath>
#include <iostream>
using namespace std;
typedef complex<double> xy_t;

double dot_product(xy_t a,xy_t b) {
  return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b) {
  return (conj(a)*b).imag();
}

xy_t projection(xy_t p,xy_t b) {
  return b * dot_product(p,b)/norm(b);
}

int N;
xy_t A[4];
double S;
const double eps = 1e-11;

int main() {
  scanf("%d",&N);
  for (int n=0;n<N;n++) {
    double re,im;
    for (int i=0;i<4;i++) {
      scanf("%lf%lf",&re,&im);
      xy_t P(re,im); // カッコ悪い記述だが仕方ない。
      A[i] = P;
    }
    A[1] -= A[0];
    A[3] -= A[2];
    S = cross_product(A[1],A[3]);
    bool p = abs(S) < eps;
    printf(p ? "YES\n" : "NO\n");
  }
}

Measured memory_bytes: 1204
#CF
s = input()
n = len(s)
c = 0
f = 0
for i in range(n):
    if s[i] == 'C' and c == 0:
        c = i+1
    if s[i] == 'F':
        f = i+1
if c != 0 and f != 0 and c < f:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main(){
    int n; cin >> n;
    vector <int> a;

    for(int i = 0; i < n; i++){
        int b; cin >> b;
        a.push_back(b);
    }

    sort(a.begin(),a.end());

    int count = 0;
    for(int i = a[n/2 -1] + 1; i <= a[n/2];i++){
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>

int main(void){
    int N,K,Q;
    scanf("%d %d %d",&N,&K,&Q);
    int A[Q];
    int ANS[N];
    for(int i=0;i<Q;i++){
        scanf("%d",&A[i]);
    }
for(int i=0;i<N;i++){
    ANS[i] = K-Q;
}
    for(int i=0;i<Q;i++){
        ANS[A[i]-1] ++;
    }
    for(int i=0;i<N;i++){
        if(ANS[i]<=0){
            printf("No\n");
        }else{
            printf("Yes\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1280
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            Console.WriteLine(s.Substring(0, 3));
        }
    }
}


Measured memory_bytes: 25664
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int topId, int c) {
    stack<int> S;
    S.push(topId);
    color[topId] = c;
    while (!S.empty()) {
        int u = S.top();
        S.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (color[v] == NIL) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor() {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int u = 0; u < n; u++) {
        if (color[u] == NIL) dfs(u, id++);
    }
}

int main() {
    int s, t, m, q;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 9032
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

mod = 10**9 + 7
def gcd(x, y):
    x = abs(x); y = abs(y)
    while y:
        x, y = y, x%y
    return x

azr = bzr = czr = 0
n = ni()
d = dict()
for _ in range(n):
    a, b = nm()
    if a < 0:
        a = -a
        b = -b
    if a == b == 0:
        czr += 1
    elif a == 0 :
        azr += 1
    elif b == 0:
        bzr += 1
    else:
        g = gcd(a, b)
        a //= g
        b //= g
        if (a, b) not in d:
            d[(a, b)] = 0
        d[(a, b)] += 1

ans = (pow(2, azr, mod) + pow(2, bzr, mod) - 1) % mod
for x, y in d.items():
    if d[x] == 0:
        continue
    p, q = x
    if q < 0:
        q = -q
        p = -p
    if (q, -p) in d:
        z = d[(q, -p)]
        ans = ans * (pow(2, y, mod) + pow(2, z, mod) - 1) % mod
        d[x] = d[(q, -p)] = 0
    else:
        ans = ans * pow(2, y, mod) % mod
        d[x] = 0
ans = (ans - 1 + czr) % mod
print(ans)


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

int main()
{
    vector<int> n(4);
    vector<int> a = { 1, 9, 7, 4 };

    for (int i = 0; i < n.size(); i++)
    {
        cin >> n[i];
    }
    
    for (int i = 0; i < n.size(); i++)
    {
        for (int j = 0; j < a.size(); j++)
        {
            if (a[j] == n[i])
            {
                a.erase(a.begin() + j);
                break;
            }
            if (j == a.size() - 1)
            {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

long long N;
long long mod = 1000000007;
long long zero_bit[60];
long long one_bit[60];

int main() {
    std::cin >> N;

    std::vector<long long> A(N);
    for (long long i = 0; i < N; i++) {
        std::cin >> A[i];
        //int tmp_zero = 0, tmp_one = 0;
        for (long long bit = 0; bit < 60; bit++) {
            /*
            if ((A[i] >> bit) & 1) {
                one_bit[bit]++;
                //tmp_one++;
                //std::cout << "1";
            } else {
                zero_bit[bit]++;
                //tmp_zero++;
                //std::cout << "0";
            }
            */
            ((A[i] >> bit) & 1) ? one_bit[bit]++ : zero_bit[bit]++;
        }
        //std::cout << std::endl;
        //std::cout << "tmp_one = " << tmp_one << std::endl;
        //std::cout << "tmp_zero = " << tmp_zero << std::endl;
    }

    long long result = 0;
    for (long long bit = 0; bit < 60; bit++) {
        long long tmp = (1LL << bit) % mod;
        long long tmp2 = ( tmp * (one_bit[bit] * zero_bit[bit] %mod) ) % mod;
        result = (result + tmp2) % mod;
        //result %= mod;
        //std::cout << "zero_bit[" << bit << "] = " << zero_bit[bit] << std::endl;
        //std::cout << "one_bit[" << bit << "] = " << one_bit[bit] << std::endl;
    }
    //result = result % mod;

    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=20000050;
int main()
{
	int n,k,a[2000];
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	  cin>>a[i];
	sort(a+1,a+n+1);
	ll ans=0;
	for(int i=1;i<=k;++i)
	  ans+=a[i];
	cout<<ans<<endl;    
}


Measured memory_bytes: 3624
import java.util.*; 
public class Main{
public static void main(String ... string){
  Scanner sc = new Scanner(System.in); 
  String s = sc.nextLine(); 
  if(s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)){
   System.out.println("Yes"); 
  }
  else System.out.println("No"); 
}

}

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

int main(){
  int n;
  string a;
  char b;
  int q = 0;
  cin >> n;
  
  cin >> a;
  for(int i = 0; i < n; i++){
   if(i == 0){
	++q;
   }else{
     if(a[i] != b){
       ++q;
     }
   }
   b = a[i];
  }
  cout << q << endl;
}

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

int max1(int a, int b) {
	if (a > b)
		return a;
	else
		return b;
}

int main()
{
	int N = 0;
	int *A,*B,*C;
	int SUM = 0;
	int sumA = 0, sumB = 0, sumC = 0;
	char ref = 0;
	int N_limit = pow(10, 5);

	if (scanf("%d", &N) <= 0) {
		exit(1);
	}
	if ( N <= 0 || N_limit < N)
		exit(1);

	A = (int *)malloc(N * sizeof(int));
	B = (int *)malloc(N * sizeof(int));
	C = (int *)malloc(N * sizeof(int));



	for (int i = 0; i < N; i++)
	{

		if (scanf("%d%d%d", &A[i], &B[i], &C[i]) < 3) {
			exit(1);
		}
		if (A[i] <= 0 || pow(10, 4) < A[i])
			exit(1);
		else if (B[i] <= 0 || pow(10, 4) < B[i])
			exit(1);
		else if (C[i] <= 0 || pow(10, 4) < C[i])
			exit(1);
	}

	int ref_A = 0, ref_B = 0, ref_C = 0;


	for (int i = 0; i < N; i++)
	{
		if (i - 1 < 0)
		{
			sumA = A[i];
			sumB = B[i];
			sumC = C[i];
			ref_A = sumA;
			ref_B = sumB;
			ref_C = sumC;
			continue;
		}
		sumA = A[i] + max1(ref_B, ref_C);
		sumB = B[i]+ max1(ref_C, ref_A);
		sumC = C[i] + max1(ref_A, ref_B);

		ref_A = sumA;
		ref_B = sumB;
		ref_C = sumC;

	}

	if (sumA >= sumB)
	{
		if (sumA >= sumC)
		{
			SUM = sumA;
		}
		else
		{
			SUM = sumC;
		}
	}
	else if (sumB >= sumA)
	{
		if (sumB >= sumC)
		{
			SUM = sumB;
		}
		else
		{
			SUM = sumC;
		}

	}
	else if (sumC >= sumB)
	{
		if (sumC >= sumA)
		{
			SUM = sumC;
		}
		else
		{
			SUM = sumA;
		}
	}


	printf("%d", SUM);
}

Measured memory_bytes: 1280
# coding: utf-8


def solve(*args: str) -> str:
    k = int(args[0])

    ret = 0
    count = 0
    prev = []
    while not ret:
        cur = []
        for i in range(10):
            c = str(i)
            if len(prev):
                for p in prev:
                    if abs(ord(p[0])-ord(c)) <= 1:
                        cur.append(c+p)
                        if c != '0':
                            count += 1
                            if count == k:
                                ret = c+p
            else:
                cur.append(c)
                if c != '0':
                    count += 1
                    if count == k:
                        ret = c
        prev = cur

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 16240
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(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 = 1000000001;
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 L, R, d; cin >> L >> R >> d;
	int ans = 0;
	rep(i, L, R + 1) {
		if (i % d == 0)++ans;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int n,k,q;
    int* a;
    int* correct;
    cin >> n >> k >> q;
    a = new int[q];
    correct = new int[n];
    for(int i=0;i<n;i++){
        correct[i] = 0;
    }
    for(int i=0;i<q;i++){
        cin >> a[i];
        correct[a[i]-1]++;
    }
    for(int i=0;i<n;i++){
        if(k-(q-correct[i])<=0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define eef(i,x)for(int i=head[x],y=e[i].to;y;i=e[i].next,y=e[i].to)
int read(){char c=getchar();int d=0,f=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());return d*f;}
char Read(){char c=getchar();while(c<'a'||c>'z')c=getchar();return c;}
typedef pair<int,int>PII;
typedef long long LL;
const double pi=acos(-1);
const int N=200001;
int n, mx, p[N], w[N], f[N][2], hz[N];
int t[N][2], ans[N];
int ask(int id,int x){int s=0;
	for(;x<=n;x+=x&-x)s=max(s,t[x][id]);return s;
}
vector<pair<PII,int> > op[N];int opid;
void upd(int id,int x,int s){
	for(;x>=1;x-=x&-x)if(s>t[x][id]){
		op[opid].push_back(mp(mp(x,id), t[x][id]));
		t[x][id]=s;
	}
}
bool check(int sx,int px,int sy,int py,int x){
	int S1=ask(1,p[py]+1),S0=ask(0,p[py]+1);
	if(sy<=sx+hz[x]&&sy+S1>=sx+hz[x])return 1;
	if(sy<=sx+hz[x]&&sy+S0>=sx+hz[x]&&(sy+S0)%2==(sx+hz[x])%2)return 1;
	S1=ask(1,p[px]+1),S0=ask(0,p[px]+1);
	if(sx<=sy+hz[x]&&sx+S1>=sy+hz[x])return 1;
	if(sx<=sy+hz[x]&&sx+S0>=sy+hz[x]&&(sx+S0)%2==(sy+hz[x])%2)return 1;
	return 0;
}
int main(){
	n=read();
	ref(i,1,n)p[i]=read(),w[i]=1;
	ref(i,1,n)if(p[i]>mx)mx=p[i],w[i]++;
	def(i,n,1)hz[i]=hz[i+1]+w[i]-1;
	def(i,n,0){
		if(w[i]==2) f[i][0]=ask(0,p[i]+1)+w[i];
		f[i][1]=ask(1,p[i]+1);if(f[i][1])f[i][1]+=w[i];
		if(w[i]==1) f[i][1]=max(f[i][1],ask(0,p[i]+1)+w[i]);
		if(i){
			opid=i;
			upd(0,p[i],f[i][0]);
			upd(1,p[i],f[i][1]);
		}
	}
	int sx=0,px=0,sy=0,py=0;
	if(!check(sx,px,sy,py,1)){
		printf("-1\n");
		return 0;
	}
	ref(i,1,n){
		if(!op[i].empty())def(j,op[i].size()-1,0){
			PII u=op[i][j].fi; int v=op[i][j].se;
			t[u.fi][u.se]=v;
		}
		int Sx=sx,Px=px;
		if(p[i]>p[px])Sx++,Px=i;
		if(check(Sx,Px,sy,py,i+1))sx=Sx,px=Px;
		else{
			if(p[i]>p[py])sy++,py=i;
			ans[i]=1;
		}
	}
	ref(i,1,n)printf("%d",ans[i]);
	printf("\n");
}

Measured memory_bytes: 43008
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  string a, b;
  cin >> a >> b;

  auto str = a.append(b);
  int num = stoi(str);
  auto sq = sqrtf(num);
  
  if(sq == int(sq))
  {
      std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }
}



Measured memory_bytes: 256
import Data.List

main = do
  x <- readLn :: IO Integer
  putStrLn $ show $ head $ filter (>= x) $ primes

primes :: [Integer]
primes = 2 : [ n | n <- [3..], head (primeFactors n) == n ]

primeFactors :: Integer -> [Integer]
primeFactors n = factors n primes
    where factors n ps@(p:qs)
              | n < 2        = []
              | n < p^2      = [n]
              | mod n p == 0 = p : factors (div n p) ps
              | otherwise    = factors n qs


Measured memory_bytes: 1404
program SLR
 implicit none
 integer::N,Y,ishota=0,ishotb=0,ishotc=0,p=0,q=0,r=0
 read(*,*)N,Y
 do ishota=0,N
  do ishotb=0,N-ishota
   do ishotc=0,N-ishota-ishotb
    if(10000*ishota+5000*ishotb+1000*ishotc==Y.and.ishota+ishotb+ishotc==N)then
     p=ishota
     q=ishotb
     r=ishotc
    end if
   end do
  end do
 end do
 if(p==0.and.q==0.and.r==0)then
  print'(i0,a,i0,a,i0)',-1," ",-1," ",-1
 else
  print'(i0,a,i0,a,i0)',p," ",q," ",r
 end if
end program SLR

Measured memory_bytes: 2844
import java.util.*;

public class Main {
    public static int f(int x) {
	return x*x;
    }
    public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	while(s.hasNext()) {
	    int d = s.nextInt();
	    int sum = 0;
	    for(int i = d; i <= 600 - d; i += d) {
		sum += f(i);
	    }
	    sum *= d;
	    System.out.println(sum);
	}
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <climits>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

int main(void) {
  int N;
  int F[100][14];
  int P[100][15];
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++)
      cin >> F[i][j];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 11; j++)
      cin >> P[i][j];
  }

  int total = INT_MIN;
  for (int b = 1; b < (1 << 10); b++) {
    int cc = 0;

    for (int i = 0; i < N; i++) {
      int c = 0;
      for (int j = 0; j < 10; j++) {
        if ((b >> j & 1) && F[i][j])
          c++;
      }
      cc += P[i][c];
    }

    total = max(total, cc);
  }
  cout << total << endl;
}


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

int main() {
  //入力
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h.at(i);
  
  vector<int> dp(n, -1);
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1)-h.at(0));
  
  for(int i = 2; i < n; i++){
    dp.at(i) = min(dp.at(i-1) + abs(h.at(i)-h.at(i-1)),
                  dp.at(i-2) + abs(h.at(i)-h.at(i-2)));
  }
  
  
  //出力
  cout << dp.at(n-1) <<endl;
  return 0;
}

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

int main() {
    string str;
    cin >> str;
    if(str.at(2) == str.at(3) && str.at(4) == str.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100

int main(){
  int graph[MAX][MAX];
  int i,n,a,b,c,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      graph[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&b);
    a--;
    for(j=0;j<b;j++){
      scanf("%d",&c);
      c--;
      graph[a][c]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)
	printf(" ");
      printf("%d",graph[i][j]);
    }
    printf("\n");
  }

  return 0;
}



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

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;


clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int32_t main()
{
  FIO
  
  int k;
  cin>>k;
  int even=k/2;
  int odd=k-even;

  cout<<odd*even;

  //timer();
  return 0;
}  

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,allsum = 0;
    cin >> n;
    vector<int> v;
    for(int i = 0;i < n;i++)
    {
        int x;
        cin >> x;
        v.push_back(x);
        allsum += x;
    }
    int mini = allsum;
    int sum = 0;
    for(int i = 0;i < n - 1;i++)
    {
        sum += v.at(i);
        mini = min(mini,abs(sum - (allsum - sum)));
    }
    cout << mini;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;

public class Solver
{
    public void Solve()
    {
        int a = ri;
        int b = ri;
        Console.WriteLine((a * 3 + b) / 2);
    }

    int ri { get { return sc.Integer(); } }
    long rl { get { return sc.Long(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    private const int mod = 1000000007;
    int PowUpper(int n, int b) { int p = 1; while (p <= n) { p *= b; } return p; }
    int Abs(int n) { return (n > 0) ? n : -n; }
    int Gcd(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = Gcd(p, n[i]); } return p; }
    int Gcd(int a, int b) { return (a == 0) ? b : Gcd(b % a, a); }
    int Lcm(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = Lcm(p, n[i]); } return p; }
    int Lcm(int a, int b) { return a * b / Gcd(a, b); }
    int Max(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = (p > n[i]) ? p : n[i]; } return p; }
    int Min(params int[] n) { int p = n[0]; for (int i = 1; i < n.Length; i++) { p = (p < n[i]) ? p : n[i]; } return p; }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public long Long()
    {
        long ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public int Integer() { return (int)Long(); }
    public double Double() { return double.Parse(Scan()); }
}


Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> c(n), s(n), f(n);
	for (int i = 0; i < n - 1; ++i) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int i = 0; i < n; ++i) {
		int time = s[i] + c[i];
		for (int j = i + 1; j < n - 1; ++j) {
			if (time < s[j]) {
				time = s[j];
			} 
			else if (time % f[j] == 0);
			else {
				time += (f[j] - time % f[j]);
			}

			time += c[j];
		}

		cout << time << "\n";
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int r = 0, l = 0;
    int rm, lm;
    vector<int> ans(n, 0);
    for (int i = 0; i < n;) {
        while(s[i] == 'R') r++, i++;
        rm = i - 1;
        lm = i;
        while(s[i] == 'L') l++, i++;
        ans[rm] += (r + 1) / 2 + l / 2;
        ans[lm] += r / 2 + (l + 1) / 2;
        r = l = 0;
    }
    rep(i, n) cout << ans[i] << " \n"[i == n - 1];
}

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


Measured memory_bytes: 3880