akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

#define M 1064527

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    REP(j,K){
        vector<int> b(N+1);
        REP(i,N){
            int l = max(0, i-a[i]);
            int r = min(N, i+a[i]+1);
            b[l]++; b[r]--;
        }
        REP(i,N) b[i+1]+=b[i];
        b.pop_back();
        if(a==b) break;
        a=b;
    }
    REP(i, N) cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 4792
#!/usr/bin/env python3
from collections import deque

N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for i in range(M):
    a, b = map(lambda  x: int(x)-1, input().split())
    adj[a].append(b)
    adj[b].append(a)

ans = 0

def DFS(now,visited):
    global ans
    if len(visited) == N:
        ans += 1
    else:
        for u in adj[now]:
            if u not in visited:
                DFS(u,visited+[u])

def main():
    queue = deque([0])
    visited = [0]
    DFS(0,visited)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <limits.h>

#define WHITE 0
#define BLACK 1
#define NIL -1


void d_stra(int);


int w[10000][10000];

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

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);

    for(j = 0; j < k; j++){
      scanf("%d%d", &v, &c);

      w[u][v] = c;
    }
  }

  d_stra(n);

  return 0;
}


void d_stra(int n){
  int u, v, i;
  int mincost;
  int d[10000];
  int pi[10000];
  int color[10000];

  for(v = 0; v < n; v++){
    d[v] = INT_MAX;
    pi[v] = NIL;
    color[v] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = INT_MAX;

    for(i = 0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INT_MAX) break;

    color[u] = BLACK;

    for(v = 0; v < n; v++){
      if(color[v] != BLACK && 0 < w[u][v] && d[u] + w[u][v] < d[v]){
	pi[v] = u;
	d[v] = d[u] + w[u][v];
      }
    }
  }

  for(i = 0; i < n; i++){
    printf("%d %d\n", i, d[i]);
  }
}



Measured memory_bytes: 2168
N, *A = map(int, open(0).read().split())
M = (N+1)*N//2
S = sum(A)
if S%M!=0:
  print('NO')
  import sys
  sys.exit()
cnt = S//M
x = 0
for i in range(N):
  df = A[(i+1)%N]-A[i]
  if (cnt-df)%N!=0 or cnt<df:
    print('NO')
    break
  x += (cnt-df)//N
else:
  if x==cnt:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 14068
#include <bits/stdc++.h>
#define my_max(a, b) ((a) > (b) ? (a) : (b))
#define my_min(a, b) ((a) < (b) ? (a) : (b))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i, s, t) for(int i = (int)(s); i <= (int)(t); i++)
#define rev(i, t, s) for(int i = (int)(t); i >= (int)(s); i--)
#define lson rt << 1
#define rson rt << 1 | 1
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double lb;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::vector<int> VI;
typedef std::vector<ll> VL;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> rbtree;
ll gcd(ll x, ll y){ return y % x == 0 ? x : gcd(y % x, x); }
template<class T>T my_abs(T a){ if(a < 0) a = -a; return a; }
inline ll read(){
    ll ret = 0, sign = 1;
    char c = getchar();
    while(c < '0' || c > '9'){ if(c == '-') sign = -1; c = getchar();}
    while(c >= '0' && c <= '9'){ ret = ret * 10 + c - '0'; c = getchar(); }
    return ret * sign;
}
inline void write(ll x){
    if(x < 0){
        putchar('-');
        x = -x;
    }
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

//void expand_stack_space(){
//    int size = 256 << 20; // 256MB
//    char *p = (char*)malloc(size) + size;
//    __asm__("movl %0, %%esp\n" :: "r"(p));
//}
const int maxn = 2e5 + 7;
int a[maxn], n;

int main(){
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif // ONLINE_JUDGE
    ll ans = 0;
    scanf("%d", &n);
    map<int, int> mp;
    for(int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        ans += mp[i - a[i]];
        ++mp[i + a[i]];
    }
    printf("%lld\n", ans);
    return 0;
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  int k = a+b;
  if (k%2 == 0) {
    cout << k / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  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[] T = new int[5];
      int[] D = new int[5]; 
      for(int i=0;i<5;i++){
        T[i] = sc.nextInt();
      }
      //総時間
      int sum = 0;
         for(int i=0;i<5;i++){
             //あまり時間がないものの注文
             if(T[i]%10==0){
               D[i]=T[i];
             //あまり時間があるものの注文
             }else{
               D[i]=(T[i]/10)*10+10;
             }
          }
  
          //最後の注文のあまり時間はかからない
          int max = 0;
          for(int i=0;i<5;i++){
            if((D[i]-T[i])>max) {
               max=D[i]-T[i]; 
            }
             sum=sum+D[i];
          }
      
        System.out.println(sum-max);
    }
}

Measured memory_bytes: 35820
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

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

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

const INF = int(1e9)

func main() {
	sc.Split(bufio.ScanWords)
	n, m, x := readInt(), readInt(), readInt()

	c := make([]int, n)
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		c[i] = readInt()
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			a[i][j] = readInt()
		}
	}

	ans := int(1e9)
	for i := 0; i < 1<<n; i++ {
		cost := 0
		d := make([]int, m)
		for j := 0; j < n; j++ {
			if i>>j&1 == 1 {
				cost += c[j]
				for k := 0; k < m; k++ {
					d[k] += a[j][k]
				}
			}
		}
		ok := true
		for _, v := range d {
			if v < x {
				ok = false
			}
		}
		if ok {
			ans = min(ans, cost)
		}
	}
	if ans == INF {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}


Measured memory_bytes: 2160
import sys

L, R = [int(i) for i in input().split(" ")]
min_rem = 2018

for i in range(L, R + 1):
    if i % 2019 == 0:
        print(0)
        sys.exit()
    else:
        pass

for i in range(L, R):
    for j in range(i + 1, R + 1):
        rem_i = i % 2019
        rem_j = j % 2019
        min_rem = min((rem_i * rem_j) % 2019, min_rem)

print(min_rem)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   string n;
   cin >> n;
   int int_n = stoi(n);
   int sum = 0;
   for(int i=0; i < n.size(); i++){
      char tmp = n[i];
      sum+= atoi(&tmp);
   }

   if(int_n%sum == 0){
      cout << "Yes" << endl;
      return 0;
   }
   else{
      cout << "No" << endl;
      return 0;
   }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c;
bool solve(){
  return min(a,b)<c&&c<max(a,b);
}
int main(){
  cin>>a>>b>>c;
  if(solve()) cout<<"Yes"<<"\n";
  else cout<<"No"<<"\n";
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (a, b, c) = (it.next().unwrap(), it.next().unwrap(), it.next().unwrap());

    if a*c <= b {
        println!("{}", c);
    } else {
        println!("{}", b/a);
    }
}

Measured memory_bytes: 4352
import java.util.*;

public class Main
{
    public static final void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            ans += r - l + 1;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 25836
n, m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(m)]  

for x in range(1000):
  keta = 1
  nx = x // 10
  d = [x%10]
  
  while nx:
    keta += 1
    d.append(nx % 10)
    nx //= 10
  d.reverse()
  if keta != n:
    continue
  ok = True
  for i in range(m):
    if d[p[i][0]-1] != p[i][1]:
        ok = False
  if ok:
    print(x)
    exit()

print(-1)


Measured memory_bytes: 3064
def main():
    n = int(input())
    num_list = [int(input()) for _ in range(n)]

    num_list.sort(reverse=True)

    count = 0

    for i in range(n):
        if i == 0:
            count += num_list[i] // 2
        else:
            count += num_list[i]

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),t=s.nextInt()-1;
		char[] c=s.next().toCharArray();
		c[t]+='a'-'A';
		System.out.println(c);
	}
}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        void Omame()
        {
            cin = new Scanner();
            string s = cin.next();

            for (int i = 0; i < 1 << (s.Length - 1); i++)
            {
                int calcResult = s[0] - '0';
                string ans = s[0].ToString();
                int p = 1;
                for (int j = 0; j < s.Length - 1; j++)
                {
                    int n = s[p] - '0';
                    if ((i >> j & 1) == 1)
                    {
                        calcResult += n;
                        ans += "+" + s[p];
                    }
                    else
                    {
                        calcResult -= n;
                        ans += "-" + s[p];
                    }
                    p++;
                }

                if (calcResult == 7)
                {
                    Console.WriteLine(ans + "=7");
                    return;
                }
            }
        }


        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 13268
# solution

import io
import sys

data = int(input())
array = [0] + [int(x) for x in input().split()] + [0]

cnt = sum(abs(array[i+1] - array[i]) for i in range(data+1))

for j in range(1, data+1):
    print(cnt - (abs(array[j]-array[j-1]) + abs(array[j+1]-array[j])) + abs(array[j+1]-array[j-1]))


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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}


int n, m, a[maxN], ans;
vector<int> g[maxN], vtx;
bool visited[maxN], marked[maxN];

void DFS(int u) {
    visited[u] = true;
    vtx.pb(u);
    for(int v: g[u]) {
        if (!visited[v]) DFS(v);
    }
}

int main () {
    scanf("%d%d", &n, &m);
    fto(u, 1, n) scanf("%d", &a[u]);
    fto(i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].pb(v); g[v].pb(u);
    }


    fto(u, 1, n) {
        if (!visited[u]) {
            DFS(u);

            for(int v: vtx) marked[a[v]] = true;
//            fto(u, 1, n) printf("%d ", marked[u]);
//            puts("");
            for(int v: vtx) {
//                printf("%d %d\n", v, marked[v]);
                if (marked[v]) ++ans;
            }
            for(int v: vtx) marked[a[v]] = false;
            vtx.clear();

        }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 9852
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;
typedef long long ll;

ll n, k, ans, M=1e9+7;
ll fac[N]={1,1}, inv[N]={1,1}, fiv[N]={1,1};
ll C(ll p, ll q) {
	return fac[p] * fiv[p-q] % M * fiv[q] % M;
}

int main() {
	int i;
	cin >> n >> k;
	for(i=2; i<=n; i++) {
		fac[i] = fac[i-1] * i % M;
		inv[i] = inv[M%i] * (M-M/i) % M;
		fiv[i] = fiv[i-1] * inv[i] % M;
	}
	k = min(n-1, k);
	for(i=0; i<=k; i++) {
		ans += C(n,i) * C(n-1,i) % M;
	}
	cout << ans % M;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N,M,C;cin>>N>>M>>C;
    vi B(M);
    for(int i=0;i<M;i++)cin>>B[i];
    int ans=0;
    for(int i=0;i<N;i++){
        int score=C;
        for(int j=0;j<M;j++){
            int a;cin>>a;
            score+=a*B[j];
        }
        if(score>0)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3576
while True:
    l=str(input())
    if l=="0": break
    A,B = 0,0
    for i in range(1,len(l)):
        if l[i]=="A":
            A+=1
        else:
            B+=1
    if A>B:
        A+=1
    else:
        B+=1
    print(A,B)


Measured memory_bytes: 5560
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b,re1=0,h,w,count=0,count2=0;
    string s;
    double n;
    cin>>n;
    REP(i,1,n+1){
        if(i%2==0){
            count++;
        }
        else{
            count2++;
        }
    }
    cout<<fixed<<count2/n<<setprecision(10)<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<string> A(55),B(55);
  for(int i=0;i<N;i++){cin >> A[i];}
  for(int i=0;i<M;i++){cin >> B[i];}
  string ans="No";
  int a=0;
  for(int i=0;i+M<=N;i++){
    for(int j=0;j+M<=N;j++){
      a=1;
      for(int k=0;k<M;k++){
        for(int l=0;l<M;l++){
          if(A[i+k][j+l]!=B[k][l]){a=0;}
        }
      }
      if(a==1){ans="Yes";}
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll K;
    cin >> K;
    ll t=K%50;
    ll s=K/50;
    cout<<50<<endl;
    for(ll i=0;i<t;i++){
        cout<<100+s-t<<" "
    ;}
    for(ll i=0;i<50-t;i++){
        cout<<49+s-t<<" "
    ;}cout<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, d, x;
  cin >> n >> d >> x;
  VI a(n);
  REP(i, n) cin >> a[i];

  int ans = 0;
  REP(i, n) {
    int now = 1, cnt = 0;
    while(now <= d) {
      ans++;
      cnt++;
      now = cnt*a[i]+1;
    }
  }
  cout << ans + x << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

const int mod = 1e9 + 7;

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

	int n = s.size();

	reverse(s.begin(), s.end());
	vector<int> cs = {1, 10, 9, 12, 3, 4};
	vector<vector<long long>> dp(n + 1, vector<long long>(13, 0));

	dp[0][0] = 1;

	for (int i = 0; i < n; i++) {
		int c = cs[i%6];
		if (s[i] != '?') {
			int x = (s[i] - '0') * c % 13;
			for (int j = 0; j < 13; j++) {
				dp[i+1][(j+x)%13] += dp[i][j];
				dp[i+1][(j+x)%13] %= mod;
			}
		} else {
			for (int y = 0; y < 10; y++) {
				int x = y * c % 13;
				for (int j = 0; j < 13; j++) {
					dp[i+1][(j+x)%13] += dp[i][j];
					dp[i+1][(j+x)%13] %= mod;
				}
			}
		}
	}

	int ans = dp[n][5];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 13696
from itertools import combinations, product


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

def lcm(a, b):
    return a * b // gcd(a, b)


def get(fmt):
    ps = input().split()
    r = []
    for p, t in zip(ps, fmt):
        if t == "i":
            r.append(int(p))
        if t == "f":
            r.append(float(p))
        if t == "s":
            r.append(p)
    if len(r) == 1:
        r = r[0]
    return r

def put(*args, **kwargs):
    print(*args, **kwargs)


def rep(n, f, *args, **kwargs):
    return [f(*args, **kwargs) for _ in range(n)]
    
def rep_im(n, v):
    return rep(n, lambda: v)
    
YES_NO = ["NO", "YES"]

H, W = get("ii")
h, w = get("ii")

put(H * W - h * W - w * H + h * w)

Measured memory_bytes: 3064
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var cnt = 0L
    repeat(1000) {
        val num = it.toString().padStart(3, '0')
        var idx = 0

        s.forEach {
            if (it == num[idx]) idx++
            if (idx == 3) {
                cnt++
                return@repeat
            }
        }
    }

    println(cnt)
}

Measured memory_bytes: 34504
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(b<a*c?b/a:c)<<endl;
}


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

// Contest: AtCoder Beginner Contest 143 (https://atcoder.jp/contests/abc143)
// Problem: E: Travel by Car (https://atcoder.jp/contests/abc143/tasks/abc143_e)

using namespace std;

using ll = int64_t;
using u64 = uint64_t;
using u32 = uint32_t;

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

    int n; ll k; cin >> n >> k;
    vector<ll> a(n), f(n);
    for (auto& ai : a) cin >> ai;
    for (auto& fi : f) cin >> fi;
    sort(begin(a), end(a));
    sort(begin(f), end(f), greater<>());

    ll l = -1, r = 1e13;
    while (r - l > 1) {
        ll m = (r + l) / 2;
        ll c = 0;
        for (int i = 0; i < n; ++i)
            if (a[i] * f[i] > m)
                c += a[i] - m / f[i];
        if (c <= k)
            r = m;
        else
            l = m;
    }

    cout << r << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
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; }

// auto mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator-=(const mint a) {
      if ((x += mod-a.x) >= mod) x -= mod;
      return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
      if (t&1) a *= *this;
      return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// mintと併用
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main() {
    int n, m; cin >> n >> m;
    mint ans = 0;
    for(int k = 0; k <= n; ++k) {
        mint now = c(n, k);
        now *= c.p(m, n);
        now *= c.p(m-k, n-k);
        if(k%2 != 0) now = -now;
        ans += now;
    }
    cout << ans << endl;
}

Measured memory_bytes: 18620
n, k, s = map(int, input().split())
if k == n:
    print(" ".join([str(s) for _ in range(n)]))
    exit()

arr = []
for i in range(1, n + 1):
    if i <= k:
        arr.append(s)
    else:
        arr.append(8 ** 9 + 14499)  # テキトー
print(" ".join(list(map(str, arr))))


Measured memory_bytes: 12056
#include<stdio.h>
#include<math.h>
int main(){
    int n;
    scanf("%d",&n);
    int b[100];
    int i;
    for(i=1;i<n;i++){
        scanf("%d",&b[i]);
    }
    int a[101];
    for(i=1;i<=n;i++){
        if(i==1){
            a[i] = b[i];
        }
        else if(i==n){
            a[i] = b[n-1];
        }
        else{
            a[i] = fmin(b[i-1],b[i]);
        }
    }
    int sum = 0;
    for(i=1;i<=n;i++){
        sum += a[i];
        //printf("a[%d]=%d\n",i,a[i]);
    }
    printf("%d\n",sum);
    return 0;
}

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

int main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    
    vector<vector<int>> ans(H, vector<int>(W));
    rep(i, H) {
        rep(j, W) {
            if ((i < B && j < A) || (B <= i && A <= j)) cout << 0;
            else cout << 1;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5120
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    double down = 0;
    for(int i = 0; i < N; i++){
        down += (double)1 / A[i];
    }
    cout << 1 / down << setprecision(15) << endl;
}


Measured memory_bytes: 3772
#include <iostream>
#include <string>
#include <vector>
#include <bitset>

void solution(const std::vector<std::bitset<100>> &a, const int w) {
    std::bitset<100> mask;
    for (const std::bitset<100> &row : a) {
        mask |= row;
    }
    for (const std::bitset<100> &row : a) {
        if (row.any()) {
            for (int j = 0; j < w; ++j) {
                if (!mask[j]) continue;
                if (row[j]) {
                    std::cout << '#';
                } else {
                    std::cout << '.';
                }
            }
            std::cout << std::endl;
        }
    }
}

int main() {
    std::vector<std::bitset<100>> a;
    int h, w;
    std::cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        std::string buf;
        std::cin >> buf;
        std::bitset<100> row;
        for (int j = 0; j < w; ++j) {
            if (buf[j] == '#') row.set(j);
        }
        a.push_back(row);
    }
    solution(a, w);
    return 0;
}

Measured memory_bytes: 256
main :: IO ()                                                                                                              
main = map read . words <$> getLine >>= \(w:a:b:_) -> print $ f' w a b                                                     
                                                                                                                           
f w a b                                                                                                                    
  | a <= b && b < a + w = 0                                                                                                
  | b <= a && a < b + w = 0                                                                                                
  | a + w <= b = b - a - w                                                                                                 
  | b + w <= a = a - b - w                                                                                                 
                                                                                                                           
f' w a b                                                                                                                   
  | abs (b - a) < w = 0                                                                                                    
  | otherwise = abs (b - a) - w

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

void add(ll &a, ll b){
  // a += bをする
  a = (a + b) % MOD;
}

int main() {
  int h,w; cin >>h >>w;
  vector<string> a(h);
  rep(i, h) cin >>a.at(i);

  vector<vector<ll>> dp(h, vector<ll>(w, 0));
  dp.at(0).at(0) = 1;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      if (a.at(i).at(j) == '#') continue;
      if (i+1 < h && a.at(i+1).at(j) == '.') add(dp.at(i+1).at(j), dp.at(i).at(j));
      if (j+1 < w && a.at(i).at(j+1) == '.') add(dp.at(i).at(j+1), dp.at(i).at(j));
    }
  }
  cout <<dp.at(h-1).at(w-1) <<endl;
}


Measured memory_bytes: 9216
#include <cstdio>
using namespace std;

int main() {
	char S[101], T[101];
	int l, p;
	bool res = false;

	scanf("%s", S);
	scanf("%s", T);

	for (int i = 0; i < 101; i++) {
		if (S[i] == '\0') {
			l = i;
			break;
		}
	}

	for (int i = 0; i < l; i++) {
		p = 0;
		while (p < l && S[p] == T[(i + p) % l]) {
			p++;
		}
		if (p == l) {
			res = true;
		}
	}

	if (res) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	//printf("l = %d\n", l);

	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

map<ll, ll> mp;
queue<ll > que;
vector<ll > ans;

int main(){

    ll N, K;
    cin >> N >> K;

    ll ans = N;

    ans = min(ans, abs(N - K * (N / K)));
    ans = min(ans, abs(N - K * (N / K + 1)));

    cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int hour = S/3600;
		S -= hour * 3600;
		int minutes = S/60;
		S -= minutes * 60;
		System.out.println(hour + ":" + minutes + ":" + S);
	}
}

Measured memory_bytes: 26380
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


class BinaryIndexTree:
    def __init__(self, n):
        self.size = n
        self._container = [0] * (n + 1)
        self.depth = n.bit_length()

    def sum(self, i):
        if i == 0:
            return 0
        s = 0
        while i > 0:
            s += self._container[i]
            i -= i & (-i)
        return s

    def add(self, i, x):
        if i == 0:
            return
        while i <= self.size:
            self._container[i] += x
            i += i & (-i)

    def lower_bound(self, x):
        if x == 0:
            return 0

        s = 0
        idx = 0
        for i in range(self.depth, -1, -1):
            k = idx + (1 << i)
            if k <= self.size and s + self._container[k] < x:
                s += self._container[k]
                idx += 1 << i
        return idx + 1

    def __repr__(self):
        return str(self._container)


def main():
    N, Q = map(int, readline().split())
    a = list(map(int, readline().split()))
    bit = BinaryIndexTree(N + 1)

    for i, x in enumerate(a, 1):
        bit.add(i, x)

    for _ in range(Q):
        a, b, c = map(int, readline().split())
        if a == 0:
            b += 1
            bit.add(b, c)
        else:
            b += 1
            c += 1
            print(bit.sum(c - 1) - bit.sum(b - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 127964
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll h,w,n,sr,sc;
  cin >> h >> w >> n >> sr >> sc;
  sr--;sc--;
  string s,t;
  cin >> s >> t;
  ll L=0,R=w-1,U=0,D=h-1;
  bool a=true;
  for(ll i=n-1;i>=0;i--){
    if(i!=n-1){
      if(t[i]=='L'){
        R=min(R+1,w-1);
      }
      else if(t[i]=='R'){
        L=max(L-1,(ll)0);
      }
      else if(t[i]=='U'){
        D=min(D+1,h-1);
      }
      else{
        U=max(U-1,(ll)0);
      }
    }
    if(s[i]=='L'){
      L++;
    }
    else if(s[i]=='R'){
      R--;
    }
    else if(s[i]=='U'){
      U++;
    }
    else{
      D--;
    }
    if(U>D||L>R){
      a=false;
    }
  }
  if(L<=sc&&sc<=R&&U<=sr&&sr<=D&&a){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
int A[101010];
const ll mo=1000000007;

int C[3];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll ret=1;
	FOR(i,N) {
		cin>>x;
		y=count(C,C+3,x);
		
		(ret=ret*y)%=mo;
		FOR(j,3) if(C[j]==x) {
			C[j]++;
			break;
		}
		
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
const int N = 405949; // 405949 is my favorite number, but it's less than 5e5
const int LG = 20;
const int MOD = 1e9 + 7;
const int INF = 1e9;

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <time.h>
#include <unordered_set>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define uniq(x) sort(all(x)); x.resize(unique(all(x)) - (x).begin());

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll inv(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(N);
    __ufact.resize(N);
    __rev.resize(N);
    __rev[1] = 1;
    for (int i = 2; i < N; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < N; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int n, k;
ll ans = 0;
ll a[N], b[N];

signed main()
{
    #ifdef ONLINE_JUDGE
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // ONLINE_JUDGE
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], b[i] = a[i] - i;
    sort(b + 1, b + n + 1);
    ll s = b[n / 2 + 1];
    for (int i = 1; i <= n; i++) ans += abs(a[i] - s - i);
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
Check corner cases.
*/


Measured memory_bytes: 5888
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println(Math.min(a,b)+Math.min(c,d));
    }
}

Measured memory_bytes: 23764
<?php
$S=fgets(STDIN);
$ans=[];
for ($i=0; $i <strlen($S) ; $i++) {
  if($S[$i]=='B'){
    if(count($ans)>=1){
      $D=array_splice($ans,-1,1);
    }
  }else{
    $ans[]=$S[$i];
  }
}
$ans=implode("",$ans);
echo $ans;
 ?>

Measured memory_bytes: 3576
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll a,b;
    cin >> a >> b;

    ll g = GCD(a,b);
    map<ll,ll> y;

    ll buf = g;
    for(ll p = 2; p * p <= buf; ++p)
    {
        while(buf % p == 0)
        {
            y[p] = 1;
            buf /= p;
        }
    }

    if(buf != 1) y[buf] = 1;

    cout << sz(y) + 1 << endl;

    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

long long Combi::nPk_modp(long long n, long long k, long long p)
{
  ll ans = 1;
  for(long long i = k; i <= n; i++)
  {
    ans = (ans * i) % p;
  }

  return ans;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll N, K; cin >> N >> K;
    int d;
    vector<bool> A(N, false);
    ll ans = 0;

    for (int i = 0; i < K; ++i) {
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int tmp; cin>>tmp;
            tmp--;
            if(!A[tmp]) A[tmp]= true;
        }
    }

    for (int k = 0; k < N; ++k) {
        if(!A[k]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

bool is_good(int a, int b, int c) {
    return a != b && b != c && c != a;
}

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int n;
    string s;
    cin >> n >> s;
    vector<int> cs(n);
    rep(i,n) {
        switch (s[i])
        {
        case 'R':
            cs[i] = 0;
            break;
        case 'G':
            cs[i] = 1;
            break;
        case 'B':
            cs[i] = 2;
            break;
        }
    }

    // dp[i][T] = csの[0,i)にあるTの個数
    vector<vector<ll>> dp(n+1, vector<ll>(8));
    dp[0][0] = 1;
    rep(i, n) {
        // dp[i+1] を更新
        rep(T, 8) {
            // cs[i]を使わない
            dp[i+1][T] += dp[i][T];
            // cs[i]を使う
            if (!((T >> cs[i]) & 1)) {
                dp[i+1][T + (1 << cs[i])] += dp[i+1][T];
            }
        }
    }

    // j - i == k - j となる個数
    ll all = 0;
    rep(i, n) {
        for (int di = 0; i + 2 * di < n; di++) {
            int j = i + di, k = j + di;
            all += is_good(cs[i], cs[j], cs[k]);
        }
    }

    cout << dp[n][7] - all << endl;

    return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a* b, c * d) << endl;
	return 0;
}

Measured memory_bytes: 256
import collections
def main4():
    dd = collections.defaultdict(int)
    n = int(input())
    res = 0
    for i in range(n):
        s = input()
        a = sorted(s)
        dd[''.join(a)]+=1
    for i in dd.values():
        res += (i*(i-1))//2
    print(res)


if __name__ == '__main__':
    main4()

Measured memory_bytes: 22464
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        long sum = 0;
        int tmp = 2;
        StringBuilder sb = new StringBuilder();
        ArrayList al = new ArrayList<Integer>();

        if(n == 3){
            System.out.println("2 5 63");
            return;
        }
        if(n == 4){
            System.out.println("2 5 20 63");
            return;
        }
        if(n == 5){
            System.out.println("2 5 30 50 63");
            return;
        }

        for(int i=0; i<n; i++){
            while(true){
                if(tmp%2==0 || tmp%3==0){
                    al.add(tmp);
                    
                    sum += tmp;
                    tmp++;
                    break;
                }
                tmp++;  
            }
        }
        
        if(sum % 6 == 0){

        }else if(sum % 6 == 2){
            al.removeAll(Arrays.asList(new Integer[]{8}));
            al.add(30000);
        }else if(sum % 6 == 3){
            al.removeAll(Arrays.asList(new Integer[]{9}));
            al.add(30000);
        }else if(sum % 6 == 5){
            al.removeAll(Arrays.asList(new Integer[]{9}));
            al.add(29998);
        }

        for(int i=0; i<n; i++){
            sb.append(al.get(i));
            sb.append(" ");       
        }
        System.out.println(new String(sb));
    }
}


Measured memory_bytes: 24916