akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N, M;
string S;

vector<int> l_zero, r_zero; // i からみて 1 がないすぐ左／右の場所(自分が 0 なら自分)

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

    cin >> N >> M >> S;

    // -1 チェック
    int cnt = 0;
    REP(i, N + 1) {
        if(S[i] == '1') {
            cnt++;
            if(cnt >= M) {
                printf("-1\n");
                return 0;
            }
        }
        else {
            cnt = 0;
        }
    }

    // l_zero, r_zero の作成
    l_zero.assign(N + 1, -1);
    r_zero.assign(N + 1, -1);
    int cur = 0;
    REP(i, N + 1) {
        if(S[i] == '0') { cur = i; }
        l_zero[i] = cur;
    }
    cur = N;
    for(int i = N; i >= 0; --i) {
        if(S[i] == '0') { cur = i; }
        r_zero[i] = cur;
    }

    // まず最短距離を出す
    int ans_dist = 0;
    vector<int> ans_pos;
    cur = 0;
    ans_pos.push_back(0);
    while(cur < N) {
        // 行けそうなら行く
        if(cur + M >= N) {
            cur = N;
            ans_dist++;
            break;
        }

        int next_cur = cur + M;
        if(S[next_cur] == '1') {
            next_cur = l_zero[next_cur];
        }
        cur = next_cur;
        ans_pos.push_back(cur);
        ans_dist++;
    }
    ans_pos.push_back(N);

    // ans_pos を左に寄せられないか調整
    reverse(ans_pos.begin(), ans_pos.end());
    vector<int> ans_r;
    REP(i, ans_pos.size() - 1) {
        if(ans_pos[i] < ans_pos[i+1]) {
            ans_pos[i+1] = ans_pos[i];
            continue;
        }
        // 現在の移動距離
        int cur_dist = ans_pos[i] - ans_pos[i + 1];
        // まだいける移動距離
        int sub_dist = M - cur_dist;

        int new_pos = ans_pos[i+1] - sub_dist;
        if(new_pos < 0) { new_pos = 0; }
        new_pos = r_zero[new_pos];
        int new_dist = ans_pos[i] - new_pos;
        ans_r.push_back(new_dist);

        ans_pos[i + 1] = new_pos;
    }

    reverse(ans_r.begin(), ans_r.end());
    REP(i, ans_r.size()) {
        printf("%lld%c", ans_r[i], (i == ans_r.size() - 1) ? '\n' : ' ');
    }

    return 0;
}


Measured memory_bytes: 4292
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    string S;
    cin >> S;

    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        cout << "Bad" << endl;
    }
    else{
        cout << "Good" << endl;
    }

    return 0;
}

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

using namespace std;

long long p[100005];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n;
	cin >> n;
	for(long long i = 0; i < n; ++i) cin >> p[i];
	sort(p, p + n);
	cout << p[n / 2] - p[n / 2 - 1];

	return 0;
}



Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A*N,B) << endl;
    return 0;
}


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

using namespace std;

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

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

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

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

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

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

int h,w;
int a[525][525];

int main(){
  scanf("%d%d",&h,&w);
  REP(i,h)REP(j,w)scanf("%d",&a[i][j]);
  vi ops;
  int cnt = 0;
  REP(i,h){
    if(i%2==0){
      REP(j,w){
        cnt++; if(cnt==h*w)break;
        if(a[i][j]%2==0)continue;
        int toi = j==w-1 ? i+1 : i;
        int toj = j==w-1 ? j : j+1;
        a[i][j]--;
        a[toi][toj]++;
        ops.push_back(i+1);
        ops.push_back(j+1);
        ops.push_back(toi+1);
        ops.push_back(toj+1);
      }
    }else{
      FORR(j,0,w){
        cnt++; if(cnt==h*w)break;
        if(a[i][j]%2==0)continue;
        int toi = j==0 ? i+1 : i;
        int toj = j==0 ? j : j-1;
        a[i][j]--;
        a[toi][toj]++;
        ops.push_back(i+1);
        ops.push_back(j+1);
        ops.push_back(toi+1);
        ops.push_back(toj+1);
      }
    }
  }
  // REP(i,h)REP(j,w)printf("%d%c",a[i][j],j==w-1?'\n':' ');
  printf("%d\n",ops.size()/4);
  REP(i,ops.size()/4){
    printf("%d %d %d %d\n",ops[4*i+0],ops[4*i+1],ops[4*i+2],ops[4*i+3]);
  }
  return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

int main(){
    ll k=ii();
    string s=is();
    if(s.length() <= k){
        ose(s);
    }else{
        REP(i,0,k){
            std::cout << s[i];
        }
        ose("...");
    }
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

template<class T> using PQ_G = priority_queue<T, vector<T>, greater<T>>;

int N, M;

bool bfs(vector<vector<int>>& g, int fa, int fb) {
  queue<int> q;
  q.push(0);
  vector<int> vis(N);
  vis[0] = 1;
  while(!q.empty()) {
    int f = q.front(); q.pop();
    rep(i, g[f].size()) {
      if ((f == fa && g[f][i] == fb) || (f == fb && g[f][i] == fa)) continue;
      if (!vis[g[f][i]]) {
        q.push(g[f][i]);
        vis[g[f][i]] = 1;
      }
    }
  }
  int ok = 1;
  rep(i, N) {
    ok &= vis[i];
  }
  return !ok;
}

int main() {
  //50 * 50 * 50 * 50 + 50
  cin >> N >> M;
  vector<vector<int>> g(N);
  rep(i, M) {
    int a, b; cin >> a >> b;
    g[a-1].push_back(b-1);
    g[b-1].push_back(a-1);
  }
  int count = 0;
  rep(fa, N) for (int fb = 0; fb < fa; fb++) {
    count += bfs(g, fa, fb);
  }
  cout << count << "\n";
}


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

int main()
{
	long long N, M,a,b;

	long long money = 0;
	map<long long,long long>shop;

	cin >> N >> M;

	for (long long i = 0; i < N; i++)
	{
		cin >> a >> b;
		if (shop.count(a))
		{
			shop[a] = shop[a] + b;
		}
		else
		{
			shop[a] = b;
		}
	}
	
	for (auto x: shop) 
	{
		if (x.second >= M)
		{
			money += x.first * M;
			std::cout << money;
			return 0;
		}
		else
		{
			money += x.first * x.second;
			M -= x.second;
		}

	}
	
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

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

ll gcd (ll a, ll b){
    if (b==0) return a;
    return gcd(b, a%b);
}

int main(){
    ll N,K;
    cin>>N>>K;
    ll A[N];
    bool k=false;
    rep(i,0,N){
        cin>>A[i];
        if (K<=A[i]) k=true;
    }
    ll g=A[0];
    rep(i,0,N){
        g=gcd(g,A[i]);
    }
    if (K%g==0&&k){
        cout<<"POSSIBLE"<<"\n";
        return 0;
    }
    cout<<"IMPOSSIBLE"<<"\n";
}


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

int main() {
    int n;
    cin >> n;
    if(n > 81){
        goto out;
    }
    for(int i = 1;i <= 9;i++){
        if (n / i < 10) {
            if (n % i == 0) {
                cout << "Yes" << endl;
                exit(0);
            }
        }
    }
    out:
    cout << "No" << endl;
}

Measured memory_bytes: 256
from sys import stdin

n, k = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()

ans = 0
tmp = s[0]
ll = [0]
index = 0 
for i in range(len(s)):
    if tmp == s[i]:
        ll[index] += 1
    else:
        tmp = s[i]
        index += 1
        ll.append(1)

#print(ll)

for i in range(len(ll)):
    ans += ll[i]-1

ans += k*2
ans = min(ans, n-1)

print(ans)


Measured memory_bytes: 45424
def sol(a):
    b=c=0
    for i in a:
        if i>b:
            b=i
        elif i>c:
            c=i
        else:
            return 0
    return 1
n=int(raw_input())
for i in range(n):
    l=map(int,raw_input().split())
    print 'YES' if sol(l) else 'NO'

Measured memory_bytes: 6296
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	if b == gcd(a, b) {
		fmt.Fprintln(writer, -1)
		return
	}
	fmt.Fprintln(writer, a)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 640
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    Node[] ns=new Node[n];
    for(int i=0;i<n;i++){
      ns[i]=new Node();
    }
    for(int i=0;i<n-1;i++){
      int u=sc.nextInt()-1;
      int v=sc.nextInt()-1;
      int w=(sc.nextInt()&1);
      ns[u].add(new Edge(v,w));
      ns[v].add(new Edge(u,w));
    }
    Deque<Node> dq=new ArrayDeque<>();
    ns[0].vid=true;
    dq.addLast(ns[0]);
    while(!dq.isEmpty()){
      Node here=dq.pollFirst();
      for(Edge e:here.es){
        if(!ns[e.t].vid){
          ns[e.t].vid=true;
          ns[e.t].color=((here.color+e.l)&1);
          dq.addLast(ns[e.t]);
        }
      }
    }
    for(int i=0;i<n;i++){
      System.out.println(ns[i].color);
    }
  }
  static class Node{
    List<Edge> es=new ArrayList<>();
    int color;
    boolean vid=false;
    void add(Edge e){
      es.add(e);
    }
  }
  static class Edge{
    int t;
    int l;
    Edge(int to,int len){
      t=to;
      l=len;
    }
  }
}

Measured memory_bytes: 107204
using System;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split();
            int k = int.Parse(input[0]);
            int x = int.Parse(input[1]);

            Console.WriteLine((k * 500 >= x) ? "Yes" : "No");
            
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#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 repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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


int main() {
    ll x; cin >> x;
    ll ans;
    if(x < 600) ans = 8;
    else if(x < 800) ans = 7;
    else if(x < 1000) ans = 6;
    else if(x < 1200) ans = 5;
    else if(x < 1400) ans = 4;
    else if(x < 1600) ans = 3;
    else if(x < 1800) ans = 2;
    else if(x < 2000) ans = 1;

    co(ans);

    return 0;
}




Measured memory_bytes: 3600
import sys
input = sys.stdin.readline

from itertools import permutations


n, m, r = map(int, input().split())
R = list(map(int, input().split()))

D = [[float("inf")] * (n + 1) for _ in range(n + 1)]
for i in range(n + 1):
    D[i][i] = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    D[a][b] = c; D[b][a] = c

for k in range(1, n + 1):
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            D[i][j] = min(D[i][j], D[i][k] + D[k][j])

P = list(permutations(R))

answer = float("inf")
for p in P:
    temporary = 0
    for k in range(r - 1):
        i, j = p[k], p[k + 1]
        temporary += D[i][j]
    answer = min(answer, temporary)

print(answer)


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string a;
  cin >> a;
  ll n = a.size();
  map<ll, ll> cmap;
  REP(i, n)
    cmap[(ll)(a[i]-'a')] += 1;


  ll ans = n*(n-1)/2;
  REP(i, 26)
    ans -= cmap[i]*(cmap[i]-1)/2;

  cout << ans+1 << endl;
  
  
  
}


Measured memory_bytes: 720
<?php



while(fscanf(STDIN, "%d %d %d %d %d %d", $a, $b, $c, $d, $e, $f)){

$x = ($b*$f - $c*$e) / ($b*$d - $a*$e);
$y = ($c - $a*$x)/$b;

echo sprintf("%.3f %.3f\n", $x, $y);

}

Measured memory_bytes: 15312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

//long longのシフト演算には気をつけよう

int main(){
    vector<int> b(3);
    for(int i=0; i<3; i++) cin >> b[i];

    sort(b.begin(), b.end());
    cout << b[0]+b[1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define N 101
using namespace std;

typedef struct{
  int q[10000];
  int head;
  int tail;
}Queue;

//queue
Queue que;
int g[N][N]; 
int n;
int d[N];
bool us[N];
void Enque(int data){
  que.q[que.tail]=data;
  que.tail++;
}

int Deque(void){
  int data;
  data=que.q[que.head];
  que.head++;
  return data;
}

bool isEmpty(){
  if(que.tail-que.head==0)return true;
  else return false;
}

//bfs
void bfs(int s){
  int u,v;
  Enque(s);
  while(true){

    if(isEmpty()==true) {
      break;
    }
    u=Deque();
    //  cout << "u = " << u << endl;
      for(int i=1;i<= n;i++){
 
      if(us[i]==false && g[u][i] == 1){
	v=i;
	//	cout << "i - " << i <<endl;
	us[i]=true;
	d[v]=d[u]+1;
	Enque(v);
      }
    }
  }
}

int main(){

  int n2,data,u;

 //load n
  cin >>n;

  //initialize
  que.tail=0;
  que.head=0;
  for(int i=0;i<N;i++){
    us[i]=false;
    d[i]=-1;
    for(int j=0;j<N;j++){
      g[i][j]=0;
    }
  }

  //load data
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&n2);
    for(int j=0;j<n2;j++){
      scanf("%d",&data);
      g[u][data]=1;
    }
  }
  //execute

  d[1]=0;
  us[1]=true;
  bfs(1);


  //print
  for(int i=1;i<=n;i++){
    printf("%d %d\n",i,d[i]); 
  }

  return 0;
}

Measured memory_bytes: 0
from itertools import combinations_with_replacement as comb

n,m,q = map(int, input().split(' '))
lis = [list(map(int, input().split())) for _ in range(q)]
tes = comb(range(1,m+1),n)
res = 0
for i in tes:
    te = 0
    for a,b,c,d in lis:
        if c == i[b-1] - i[a-1]:
            te += d
    res = max(te,res)
print(res)

Measured memory_bytes: 9124
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
R=range
for i in R(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[n]for i in R(N)]
for i in R(n)[::-1]:A[c[i]].append(i)
B=[0]*N
def P(a,x):
	i=a[-1]
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
for i in A:P(i,1)
t=0
o=[0]*q
for x in Q:
	l=(x>>40)-1
	r=x>>20&N
	i=x&N
	while t<l:b=A[c[t]];P(b,-1);b.pop();P(b,1);t+=1
	while r:o[i]+=B[r];r-=r&-r
	while l:o[i]-=B[l];l-=l&-l
for i in o:print(i)

Measured memory_bytes: 249548
/*  AC祈願アンコウ
   　／￣＼
   ○    ／￣￣￣＼ヘ
    　 /・　 ・　 ＼>   
    ／￣￣￣＼　　  Ｖ| 
   ｜  ―――  ｜      ｜|
    ＼＿＿＿／　　  ∧|
    　　＼　　　　／
    　　　￣￣￣￣
*/

#include <bits/stdc++.h>
using namespace std;
 
#define int ll

typedef int64_t ll;
//static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) signed((a).size())
#define LEN(a) signed((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")

bool solve(const int k,vector<int> a,vector<int> b){
    REP(i,SZ(a)) a[i] %= 1ll<<(k+1ll);
    REP(i,SZ(b)) b[i] %= 1ll<<(k+1ll);

    SORT(b);
    int ret = 0ll;

    REP(i,SZ(a)){
        ret += LB(ALL(b),(1ll<<k+1ll)-a[i]) - LB(ALL(b),(1ll<<k)-a[i])
            +  LB(ALL(b),(1ll<<k+2ll)-a[i]) - LB(ALL(b),(1ll<<k)*3ll-a[i]);
    }

    return ret%2ll;
}

signed main(){
    int n;
    vector<int> a,b;

    cin >> n;

    REP(i,n){
        int tmp;
        scanf("%lld",&tmp);
        a.PB(tmp);
    }
    REP(i,n){
        int tmp;
        scanf("%lld",&tmp);
        b.PB(tmp);
    }

    int ans = 0ll;

    REP(i,30ll){
        if(solve(i,a,b)) ans += 1ll << i;
    }

    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 8580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B, K; cin >> A >> B >> K;
    set<lint> numbers_included;
    range(i, A, min(A + K, B + 1)) numbers_included.emplace(i);
    range(i, max(B - K + 1, A), B + 1) numbers_included.emplace(i);
    for (const auto& num : numbers_included) cout << num << "\n";
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p;
    for(int i = 0;i < n;i++){
        int P;
        cin >> P;
        p.push_back(P);
    }
    /**/
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i = 0;i < k;i++){
        ans += p[i];
    }

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

Measured memory_bytes: 3188
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DTriangles {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> l(n);
      rep(i, n) {
        cin >> l[i];
      }
      sort(all(l));
      ll ans = 0;
      rep(i, n) {
        for(int j=i+1; j<n; j++) {
          auto it = lower_bound(l.begin(), l.end(), l[i]+l[j]);
          int k = distance(l.begin(), it);
          ans += max((k-j-1), 0);
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  DTriangles solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
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;}


int main() {
    ll n, m;
    cin >> n >> m;

    V x(m);
    rep(i, m) cin >> x[i];
    sort(all(x));

    V interval(m-1);
    rep(i, m-1) interval[i] = x[i+1] - x[i];
    sort(all(interval));

    ll ret = 0;
    if (n < m) {
        rep(i, m-n) {
            ret += interval[i];
        }
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k,ans,v[55];
int main(){
        cin >> n >> k;
        for(int i=0;i<n;i++)cin >> v[i];
        for(int i=0;i<n;i++)
                for(int j=i;j<=n;j++){
                        if(i+n-j>min(n,k) )continue;
                        int sum=0,x=k-(i+n-j);
                        set<int> s;
                        for(int p=0;p<i;p++){
                                sum+=v[p];
                                if(v[p]<0)s.insert(v[p]);
                        }
                        for(int p=j;p<n;p++){
                                sum+=v[p];
                                if(v[p]<0)s.insert(v[p]);
                        }
                        for(set<int>::iterator it=s.begin();it!=s.end() and (x--)>0;it++)
                                sum-=*it;
                        ans=max(ans,sum);
                }
        cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int cnt = 0;
		for(int i = 0 ; i < N ; ++i){
			int a = sc.nextInt();
			if(i % 2 == 0){
				if(a % 2 == 1){
					++cnt;
				}
			}
		}
		System.out.println(cnt);
				
	}
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<int> A(n), B(n), C(n-1);
  for (auto &a : A) cin >> a;
  for (auto &b : B) cin >> b;
  for (auto &c : C) cin >> c;

  int res = B[A[0]-1];
  for (int i = 1; i < n; ++i) {
    res += B[A[i]-1];
    if (A[i] == A[i-1]+1) res += C[A[i-1]-1];
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define MAX 100000

int n, m;
int color[MAX];
int d[MAX];
int colorId = 0;
vector<int> G[MAX];
queue<int> queueBfs;


void assignColor() {
  queueBfs.push(0);
  color[0] = colorId;

  while (!queueBfs.empty()) {
    int front = queueBfs.front();

    int next = NIL;
    for (int i = 0; i < G[front].size(); i++) {
      if (color[G[front][i]] == NIL) {
        next = G[front][i];
        queueBfs.push(G[front][i]);
        color[G[front][i]] = colorId;
      }
    }
    queueBfs.pop();

    // NILになっている島を探す
    if (queueBfs.empty()) {
      for (int i = 0; i < n; i++) {
        if (color[i] == NIL) {
          queueBfs.push(i);
          colorId++;
          color[i] = colorId;
          break;
        }
      }
    }

  }
}

int main() {
  scanf("%d %d", &n, &m);
  for ( int i = 0; i < n; i++ ) color[i] = NIL;
  for ( int i = 0; i < m; i++ ) {
    int v1, v2;
    scanf("%d %d", &v1, &v2);
    G[v1].push_back(v2);
    G[v2].push_back(v1);
  }

  // for ( int i = 0; i < n; i++ ) {
  //   for ( int j = 0; j < G[i].size(); j++ ) printf("%d ", G[i][j]);
  //   printf("\n");
  // }

  assignColor();

  int q;
  scanf("%d", &q);
  int v1[q], v2[q];
  for ( int i = 0; i < q; i++ ) {
    scanf("%d %d", &v1[i], &v2[i]);
  }

  for ( int i = 0; i < q; i++ ) {
    if (color[v1[i]] == color[v2[i]]) {
      printf("yes\n");
    } else {
      printf("no\n");
    }
  }

  return 0;
}



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

void Main() {
  int Q;
  cin >> Q;
  int l[Q], r[Q];
  int max_r = 0;
  for (int i = 0; i < Q; i++) {
    cin >> l[i] >> r[i];
    max_r = max(max_r, r[i]);
  }

  int sosu[max_r + 1];
  int like[max_r + 1];
  memset(sosu, 0, sizeof(sosu));
  memset(like, 0, sizeof(like));
  sosu[0] = 0;
  sosu[1] = 0;
  sosu[2] = 1;
  like[0] = 0;
  like[1] = 0;
  like[2] = 0;
  for (int i = 3; i <= max_r; i++) {
    bool s = true;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        s = false;
        break;
      }
    }
    if (s) sosu[i] = 1;
    if (sosu[i] == 1 && sosu[(i + 1) / 2]) like[i] = like[i - 1] + 1;
    else like[i] = like[i - 1];
  }
  // for (int i = 0; i <= max_r; i++) {
  //   cout << i << ": " << sosu[i] << ", " << like[i] <<endl;
  // }

  for (int i = 0; i < Q; i++) {
    cout << like[r[i]] - like[l[i] - 1] << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 2176
import java.util.Scanner;
import java.util.Arrays;

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

        int n = sc.nextInt();
        int[] a = new int[n + 1];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a, 0, n);
        
        int ans = 0;
        for (int i = 0; i < n; i++)
            if (a[i] == a[i + 1])
                i++;
            else
                ans++;

        System.out.println(ans);

    }
}

Measured memory_bytes: 50156
#include <bits/stdc++.h>
#define fastio() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}

using namespace std;
typedef long long ll;

int main() 
{
    fastio();
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<"\n";
	return EXIT_SUCCESS;
}

Measured memory_bytes: 3640
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
int main() {
	ll A, B, C, D;
	ll ans;
	cin >> A >> B >> C >> D;
	ll E, F;
	ll G,H;
	H = A - 1;
	ll tmp;
	ll I = C,J=D;
	ll K = C * J;
	if (C < D) { tmp = C;C = D;D = tmp; }
	ll r= C % D;
	while (r != 0) {
		C = D;
		D = r;
		r = C % D;
	}
	G = K / D;
	E = H - (H / I + H / J - H / G);
	F = B - (B/ I + B/ J - B / G);
	ans = F- E;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
rl() = [parse(Int64, x) for x in split(readline())]

function solve()
    N, = rl()

    r = zeros(Int64, N)
    r[1] = 1
    for p in 2:N
        n = pn = 1
        while pn <= N
            pn *= p
            n += 1
        end
        while true
            pn = div(pn, p)
            n -= 1
            if pn <= 1
                break
            end
            a = 1
            apn = pn
            while apn <= N
                if r[a] > 0 && r[apn] == 0
                    r[apn] = r[a] * n * pn
                end
                a += 1
                apn += pn
            end
        end
    end

    sum(r)
end

println(solve())


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

//二項係数ライブラリ
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//前処理COMinit()忘れずに

int main(){
    int X, Y; cin >> X >> Y;

    int m, n;
    bool flg = false;
    for(int i = 0; i <= Y; i++){
        if(2 * X - 3 * i == Y){
            m = X - 2 * i; n = i;
            flg = true;
            break;
        }
    }

    if(!flg){
        cout << 0 << endl;
        exit(0);
    }

    COMinit();
    cout << COM(m + n, m) % MOD << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
	ll n;
	cin>>n;
	map <string,ll> map;
	while(n--)
	{
		string s;
		cin>>s;
		map[s]++;
	}
	cout<<"AC x "<<map["AC"]<<"\n";
	cout<<"WA x "<<map["WA"]<<"\n";
	cout<<"TLE x "<<map["TLE"]<<"\n";
	cout<<"RE x "<<map["RE"]<<"\n";
}


int main()       
{
  fastio
  ll t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c&&a==c){
        cout << "1" << endl;
    }
    else if(a!=b&&b!=c&&c!=a){
        cout << "3" << endl;
    }
    else {
        cout << "2" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

    ll n;
    cin>>n;
    ll ar[n],br[n],cr[n-1];
    for(ll i=0;i<n;++i){cin>>ar[i];--ar[i];}
    for(ll i=0;i<n;++i){cin>>br[i];}
    for(ll i=0;i<n-1;++i){cin>>cr[i];}
    ll ans=0;
    for(ll i=0;i<n;++i)
    {
        ans+=br[ar[i]];
        if(ar[i]!=0&&i!=0&&ar[i-1]+1==ar[i])
        {
            ans+=cr[ar[i-1]];
        }
    }
    cout<<ans<<endl;

	return(0);
}


Measured memory_bytes: 256
n = int(input())
def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a
# 最小公倍数
def lcm(a,b):
    return a // gcd(a,b) * b

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)
print(ans)


Measured memory_bytes: 2940
#include <vector>
#include <iostream>
using namespace std;
vector<int> graph[200010];
vector<int> ans(200010, 0);

void dfs(int v, int p=-1) {
  for(int u: graph[v]) {
    if(u == p) continue;
    else ans[u] += ans[v];
    dfs(u, v);
  }
}

int main() {
  int N, Q; cin >> N >> Q;
  for(int i = 0; i < N-1; ++i) {
    int a, b; cin >> a >> b; a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  for(int i = 0; i < Q; i++) {
    int p, x; cin >> p >> x; p--;
    ans[p] += x;
  }

  dfs(0);

  for(int i = 0; i < N; i++) {
    cout << ans[i];
    if(i != N-1) cout << " ";
    else cout << endl;
  }
  return 0;
}


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

using namespace std;

using LL = long long;

void solver() {
    int n; cin >> n;
    vector<int> a(n);
    for(int &x : a) cin >> x;

    vector<int> max_so_far(n);

    int mx = a[0];

    for(int i = 0; i < n; ++i) {
        mx = max(mx, a[i]);
        max_so_far[i] = mx;
    }

    LL ans = 0;
    for(int i = n - 1; i >= 0; --i) 
        ans += (max_so_far[i] - a[i]);
    
    cout << ans << '\n';
}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 4764
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: i,n,ans=1
    integer(int64),parameter:: md = 1000000007
    integer(int64), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)

    block; integer:: i1=0, i2=0, i3=0
        do i=1,n
            if (i1 == i2 .and. i2 == i3 .and. a(i) == i1) then
                ans=mod(ans*3, md)
                i1=i1+1
            else if (i1 == i2 .and. a(i) == i1) then
                ans=mod(ans*2, md)
                i1=i1+1
            else if (i2 == i3 .and. a(i) == i2) then
                ans=mod(ans*2, md)
                i2=i2+1
            else
                if (a(i) == i1) then
                    i1=i1+1
                else if(a(i) == i2) then
                    i2=i2+1
                else if (a(i) == i3) then
                    i3=i3+1
                else
                    print'(i0)', 0
                    stop
                end if
            end if
        end do
    end block
    print'(i0)', ans
end program main

Measured memory_bytes: 3920
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;

constexpr int MAX_N = 1e5+100;
int bfs[MAX_N];

int main(){
    int N;cin>>N;
    queue<int> q;
    REP(i,MAX_N){
        bfs[i] = -1;
    }
    bfs[0] = 0;
    q.push(0);
    while(!q.empty()){
        int n = q.front();q.pop();
        for(int pow=1;pow+n<=N;pow*=6){
            if(bfs[n+pow]==-1){
                bfs[n+pow] = bfs[n] + 1;
                q.push(n+pow);
            }
        }
        for(int pow=1;pow+n<=N;pow*=9){
            if(bfs[n+pow]==-1){
                bfs[n+pow] = bfs[n] + 1;
                q.push(n+pow);
            }
        }
    }
    cout << bfs[N];
}



Measured memory_bytes: 768
using System;
using System.Collections.Generic;

namespace abc166_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k,d,a;
            string[] token;

            token = Console.ReadLine().Split();
            n = Convert.ToInt32(token[0]);
            k = Convert.ToInt32(token[1]);
            Dictionary<int, int> dictionary = new Dictionary<int, int>();
            for (int i = 0; i < k; i++)
            {
                d = Convert.ToInt32(Console.ReadLine());
                token = Console.ReadLine().Split();
                for (int j = 0; j < d; j++)
                {
                    a = Convert.ToInt32(token[j]);
                    if (dictionary.ContainsKey(a))
                    {
                        
                    }
                    else
                    {
                        dictionary.Add(a, a);
                    }
                }
            }
            Console.WriteLine(n-dictionary.Count);
        }
    }
}


Measured memory_bytes: 18540
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long l){
    long double p = 1.0 * l / 3;
    printf("%20llf\n", p * p * p);
}


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2000005)
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define max3(x, y, z) max(x, max(y, z))
using namespace std;
typedef pair<ll, int> pii;
typedef pair<string, int> psi;
typedef pair<int, pair<int, int> > piii;
typedef pair<char, int> pci;
typedef pair<int, bool> pib;
ll MOD = 1000000007;

int main() {
    FAST;
    string s1, s2;
    cin >> s1 >> s2;
    cout << s2 << s1 << fim;
}


Measured memory_bytes: 256
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

void solve(vector <ll> &A, int m) {
	int i=2;
	while (i*i<=m && m%i>0) {i++;}
	if (i*i>m) {A[m]=2; return;}
	int l=0;
	int x=m;
	while (m%i==0) {m=m/i; l++;}
	A[x]=A[m]*(l+1);
	return;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll ats=0;
    for (ll i=1;i<=n;i++) {
		ll x=n/i;
		ats+=(i*x*(x+1))/2;
		}
	cout<<ats<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,W;
   cin>>n>>W;
   int w[n],v[n];
   for(int i=0;i<n;i++)
   cin>>w[i]>>v[i];

    int vs=accumulate(v,v+n,0);
    vector<vector<long long int>> dp(n+1,vector<long long int> (vs+1,INT_MAX));
    
    for(int i=0;i<=n;i++)
    dp[i][0]=0;


    for(int i=1;i<=n;i++)
    {
    for(int j=1;j<=vs;j++)
    {
    if(j>=v[i-1])
    {
    dp[i][j]=min(dp[i-1][j],w[i-1]+dp[i-1][j-v[i-1]]);
    }
    else
    dp[i][j]=dp[i-1][j];
    }
    } 
    for(int j=vs;j>0;j--)
    {
    if(dp[n][j]<=W)
    {
    cout<<j;
    break;
    }
    }
    return 0;
}


Measured memory_bytes: 83252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
   
   ll a, b; cin >> a >> b;
   cout << a / b << " " << a % b << " "  << fixed << setprecision(15) << (ld) a / b << endl;

    
}


Measured memory_bytes: 3276