akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	if readI() == readI() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1784
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 1e6+1 , limit = 9*1e18 , MOD=1e9+7;
string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}
int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}

#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    int x,y;
    cin>>x>>y;
    int es = y - 2*x;
    
    
    if(es%2 == 0){
           
         int min1 = x*2;
         int max1 = x*4;
         
         if(y > max1 || y < min1){
             cout<<"No\n";
         }else{
             cout<<"Yes\n";
         }
           
    }else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  string s; cin >> s;
  int n=s.size();
  rep(i,n){
    if(i+1<n&&s[i]==s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
    if(i+2<n&&s[i]==s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
N=int(input())
dp=[[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4) ]for _ in range(N+1)]
P=10**9+7

dp[0][3][3][3]=1

for len in range(N):
    for i in range(4):
        for j in range(4):
            for k in range(4):
                for a in range(4):
                    if j==0 and k==2 and a==1:continue
                    if j==0 and k==1 and a==2:continue
                    if j==2 and k==0 and a==1:continue
                    if i==0 and k==2 and a==1:continue
                    if i==0 and j==2 and a==1:continue
                    dp[len+1][j][k][a]+=dp[len][i][j][k]
                    dp[len+1][j][k][a]%=P

ans=0
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans+=dp[N][i][j][k]
            ans%=P
print(ans)

Measured memory_bytes: 3316
// for(auto it:m)
//     {
//         cout<<it.second;
//     }
// }
 
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
 
 
int main()
{
      int n,ctr=1;
      cin>>n;
      string s;
      cin>>s;
      for(int i=0;i<n-1;i++)
      {
          if(s[i]!=s[i+1])
          {
              ctr++;
          }

      }
      cout<<ctr;
}
 

Measured memory_bytes: 512
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long



int N;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  vector<vector<int>> dp(N + 1,vector<int>(3, 0));
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  for(int i = 0 ; i < N ; i++){
  	cin >> a[i] >> b[i] >> c[i];
  }
  for(int i = 1 ; i <= N; i++){
  	dp[i][0] = max(dp[i - 1][1],dp[i - 1][2]) + a[i - 1];
  	dp[i][1] = max(dp[i - 1][0],dp[i - 1][2]) + b[i - 1];
  	dp[i][2] = max(dp[i - 1][0],dp[i - 1][1]) + c[i - 1];
  }
  cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
  return 0;
} 

Measured memory_bytes: 8064
import java.util.Scanner;
public class Main{
    public static void rotate(long a[], int b, int m, int e){
        long A[] = new long[e-b];
        for(int i = 0 ; i < e-b ; i++)
            A[i] = a[b + (m-b+i)%(e-b)];
        for(int i = 0 ; i < e-b ; i++)
            a[b+i] = A[i];
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a[] = new long[n];
        for(int i = 0 ; i < n ; i++)
            a[i] = sc.nextLong();
        int q = sc.nextInt();
        for(int i = 0 ; i < q ; i++){
            int b = sc.nextInt();
            int m = sc.nextInt();
            int e = sc.nextInt();
            rotate(a,b,m,e);
        }
        for(int i = 0 ; i < n-1 ; i++)
            System.out.print(a[i] + " ");
        System.out.println(a[n-1]);
    }
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

LL N;
map<pair<LL, LL>, int> M;
vector<pair<LL, LL>> V;
vector<LL> X, Y, S, T;

//マンハッタン距離
LL dm(LL x1, LL y1, LL x2, LL y2){
	LL ret = abs(x1 - x2) + abs(y1 - y2);
	return ret;
}

//チェビシェフ距離
LL dc(LL x1, LL y1, LL x2, LL y2){
	LL ret = max(abs(x1 - x2), abs(y1 - y2));
	return ret;
}

// f((x,y)) = (x-y, x+y)と定義するとき、
// dc(f(P), f(Q)) = dm(P, Q);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i=0; i<N; i++){
		LL x, y; cin >> x >> y;
		auto p = make_pair(x, y);
		if(M.count(p) != 0){
			continue;
		}
		M[p] = 1;
		X.push_back(x);
		Y.push_back(y);
		V.push_back(p);
		S.push_back(x-y);
		T.push_back(x+y);
	}
	int m = M.size();
	if(m == 1){
		printf("0\n");
		return 0;
	}

	LL Xm = 0;
	sort(S.begin(), S.end());
	Xm = S[S.size()-1] - S[0];
	LL Ym = 0;
	sort(T.begin(), T.end());
	Ym = T[T.size()-1] - T[0];

	printf("%lld\n", max(Xm, Ym));
	return 0;
}

Measured memory_bytes: 25060
#include <algorithm>
#include <iostream>
#include <queue>

using namespace std;

using ll = long long;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

const ll INF = 1LL << 50;

int main() {
    ll N;
    cin >> N;
    ll a[N * 3 + 1];
    for (int i = 1; i <= N * 3; ++i) {
        cin >> a[i];
    }

    ll red[N * 2 + 1];
    red[0] = 0;
    // red[i] = 前半i個からN個選んだ総和の最大値

    GPQ<ll> rque;
    // 大きい方からN個を保持

    for (int i = 1; i <= N; ++i) {
        red[i] = red[i - 1] + a[i];
        rque.push(a[i]);
    }

    // ここから小さいのが切り捨てられる
    for (int i = N + 1; i <= N * 2; ++i) {
        red[i] = red[i - 1] + a[i];
        rque.push(a[i]);
        red[i] -= rque.top();
        rque.pop();
    }

    // aをひっくり返して同じことをする
    reverse(a + 1, a + N * 3 + 1);

    ll blue[N * 2 + 1];
    blue[0] = 0;
    // blue[i] = 後半i個からN個選んだ総和の最小値

    PQ<ll> bque;
    // 小さい方からN個を保持

    for (int i = 1; i <= N; ++i) {
        blue[i] = blue[i - 1] + a[i];
        bque.push(a[i]);
    }

    for (int i = N + 1; i <= N * 2; ++i) {
        blue[i] = blue[i - 1] + a[i];
        bque.push(a[i]);
        blue[i] -= bque.top();
        bque.pop();
    }

    ll ans = -INF;
    for (int i = N; i <= N * 2; ++i) {
        // 前半i個、後半3N - i個の差
        ans = max(ans, red[i] - blue[N * 3 - i]);
    }

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


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

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


int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int is_big = -1;
  int res = 0;
  for (int i = 0; i < n-1; i++) {
    if(is_big == -1){
      if(v[i] == v[i+1]) continue;
      else if(v[i+1] < v[i]) is_big = 0;
      else is_big = 1;
    }else if(is_big == 1 && v[i+1] < v[i]){
      res++;
      is_big = -1;
    }else if(is_big == 0 && v[i+1] > v[i]){
      res++;
      is_big = -1;
    }
  }
  cout << res+1 << endl;
}


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

int main(){
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int n;
	cin >> n;
	for(int a = 1; ; a++){
		if((a * n) % 360 == 0){
			cout << a << '\n';
			break;
		}
	}
}

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

typedef int64_t Int;
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

vector<Int> G[100001];
bool visited[100001];
Int b[100001];
bool check;

int main() {
    Int n, m;
    cin >> n >> m;
    vector<pair<Int, Int>> h(n);
    for (Int i = 0; i < (Int)n; i++) {
        cin >> b[i];
        h[i] = {b[i], i};
    }
    for (Int i = 0; i < (Int)m; i++) {
        Int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    sort(all(h), greater<pair<Int, Int>>());
    Int res = 0;
    for (Int i = 0; i < (Int)n; i++) {
        if (not visited[h[i].second]) {
            visited[h[i].second] = true;
            bool check = true;
            Int hight = h[i].first;
            for (Int j = 0; j < (Int)G[h[i].second].size(); j++) {
                Int to = G[h[i].second][j];
                visited[to] = true;
                if (not(b[to] < hight)) check = false;
            }
            if (check) {
                res++;
                //print(h[i].first, h[i].second);
            }
        }
    }
    print(res);
    return 0;
}

Measured memory_bytes: 11580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        int x = 0;
        int y = 0;
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            Console.WriteLine(Square(read) + " " + Plus(read));
            Console.ReadKey();
        }

        static string Square(string input)
        {
            string xx = "";
            string yy = "";
            int x = 0;
            int y = 0;
            var pos = input.IndexOf(' ');
            var chinput = input.ToCharArray();
            for (int i = 0; i < pos; i++)
            {
                xx += input[i];
            }
            for (int i = pos + 1; i < input.Length; i++)
            {
                yy += input[i];
            }
            Int32.TryParse(xx, out x);
            Int32.TryParse(yy, out y);
            return (x * y).ToString();
        }

        static string Plus(string input)
        {
            string xx = "";
            string yy = "";
            int x = 0;
            int y = 0;
            var pos = input.IndexOf(' ');
            var chinput = input.ToCharArray();
            for (int i = 0; i < pos; i++)
            {
                xx += input[i];
            }
            for (int i = pos + 1; i < input.Length; i++)
            {
                yy += input[i];
            }
            Int32.TryParse(xx, out x);
            Int32.TryParse(yy, out y);
            return ((x + y) * 2).ToString();
        }
    }
}



Measured memory_bytes: 15944
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll h, nb_monsters = 1, n_coups = 0;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> h;
	
	while(h > 1)
	{
		h /= 2;
		n_coups += nb_monsters;
		nb_monsters *= 2;
	}
	n_coups += nb_monsters;
	
	cout << n_coups << '\n';
	

	
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())

cur  = abs(x)
rem = k

cnt = min(cur // d, k)
cur = cur - d * cnt
rem = rem - cnt

if rem  > 0:
        if rem % 2 == 1:
                cur = cur - d
                
ans = abs(cur)
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    int ans = 0;
    REP(i, n) ans += a[i] - 1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
 
sys.setrecursionlimit(10000)

N,K,L = map(int, input().split())

#print(N,K,L,D,T)

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        #self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        #if self.rank[x] < self.rank[y]:
        #    self.par[x] = y
        #else:
        #    self.par[y] = x
        #    if self.rank[x] == self.rank[y]:
        #        self.rank[x] += 1
        self.par[x] = y
        
    # 同じ集合に属するか判定
    #def same_check(self, x, y):
    #    return self.find(x) == self.find(y)

def execOne(num, uf):
    for _ in range(num):
        d0, d1 = map(int, input().split())
        d0 = d0 - 1
        d1 = d1 - 1
        uf.union(d0, d1)

uf_D = UnionFind(N)
uf_T = UnionFind(N)

execOne(K, uf_D)
execOne(L, uf_T)


pairs = []
for i in range(N):
    pairs.append((uf_D.find(i), uf_T.find(i)))

pairs_count = {}
for p in pairs:
    if not p in pairs_count:
        pairs_count[p] = 1
    else:
        pairs_count[p] += 1

res = [0] * N
for i in range(N):
    res[i] = pairs_count[pairs[i]]
#print(*(res[i] for i in range(N)))
print(" ".join([str(i) for i in res]))

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

#define unit INT_MAX
int N; // 葉の数
vector<int> value; // セグ木,サイズは後。
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
//Write From this Line
// セグ木操作用の関数の定義
void update(int i, int x) { // 葉の i 番目をxに変更
	i += N - 1;
	value[i] = x;
	while (i > 0){
		i = (i - 1) / 2 ;
		value[i] = min(value[i * 2 + 1], value[i * 2 + 2]);
	}
}
int query(int a, int b, int k, int l, int r) { // [a,b)を聞かれている時,kに聞く。k は[l,r)を担当する(rは担当しない
	if(r <= a || b <= l) return unit; // 区間が全くかぶらない
	if(a <= l && r <= b) return value[k]; // 区間が完全にかぶっている。
	else {
		int c1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int c2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(c1, c2);
	}
}

int main()
{
	int n, q;
	cin >> n >> q;
	N = 1;
	while(N < n) N *= 2;
	value = vector<int> (2 * N - 1, unit);
	rep(i,q){
		int query_type;
		cin >> query_type;
		if(query_type == 0) {
			int index, num;
			cin >> index >> num;
			update(index, num);
		} else {
			int l, r;
			cin >> l >> r;
			//cout << query(l, r, 0, 0, N) << endl; BUG
			cout << query(l, r + 1, 0, 0, N) << endl;
		}
	}
}



Measured memory_bytes: 3860
#include<cstdio>
using namespace std;
const int maxn = 100000;
int n, m, qu;
struct node
{
	int nxt;
	int to;
}edge[2 * maxn + 10];
int head[maxn + 10];
int top;
void add_e(const int &u, const int &v)
{
	++top;
	edge[top].nxt = head[u];
	edge[top].to = v;
	head[u] = top;
	return ;
}

int ques[maxn + 10][3];
bool ok[maxn + 10][20];
int q[maxn + 10][3];
int he, ta;
int color[maxn + 10];

void bfs(const int &p)
{
	++ta;
	q[ta][0] = ques[p][0];
	q[ta][1] = ques[p][1];
	q[ta][2] = ques[p][2];
	while(he != ta)
	{
		++he;
		if(ok[q[he][0]][q[he][1]])
			continue;
		if(color[q[he][0]] == 0)
			color[q[he][0]] = q[he][2];
		for(int i = 0; i <= q[he][1]; ++i)
		{
			ok[q[he][0]][i] = 1;
		}
		if(q[he][1] == 0)
			continue;
		for(int i = head[q[he][0]]; i; i = edge[i].nxt)
		{
			if(ok[edge[i].to][q[he][1] - 1])
				continue;
			++ta;
			q[ta][0] = edge[i].to;
			q[ta][1] = q[he][1] - 1;
			q[ta][2] = q[he][2];
			
		}
	}
	return ;
}

int main()
{
	scanf("%d%d", &n, &m);
	int a, b;
	for(int i = 1; i <= m; ++i)
	{
		scanf("%d%d", &a, &b);
		add_e(a, b);
		add_e(b, a);
	}
	scanf("%d", &qu);
	for(int i = 1; i <= qu; ++i)
	{
		scanf("%d%d%d", &ques[i][0], &ques[i][1], &ques[i][2]);
	}
	for(int i = qu; i > 0; --i)
	{
		he = 0;
		ta = 0;
		bfs(i);
	}
	for(int i = 1; i <= n; ++i)
		printf("%d\n", color[i]);
	return 0;
}

Measured memory_bytes: 7168
from collections import deque
import sys
n = int(input())

a = list(map(int,input().split()))
a.sort()
if(a[0] == 0):
    print("0")
    sys.exit()
ans = 1
for i in range(n):

    ans = ans * a[i]
    if(ans > 10**18):
        print("-1")
        sys.exit()
     




print(ans)

Measured memory_bytes: 22348
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, k,sum=0;
	cin >> n >> k;
	int a[n + 10];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < k; i++)
		sum += a[i];
	cout << sum;
	return 0;
}

Measured memory_bytes: 3652
def c_factors_of_factorial(N):
    def exponential_list(n):
        # ret[k]: n!を素因数分解したときのkの指数
        ret = {}
        for j in range(2, n + 1):
            current = j
            ret[j] = 0
            for k in range(2, j + 1):
                while current % k == 0:
                    ret[k] += 1
                    current //= k
            if ret[j] == 0:
                ret.pop(j)
        return ret

    exp_list = exponential_list(N)
    ans = 1
    for e in exp_list.values():
        ans *= e + 1
        ans %= 10**9 + 7
    return ans

N = int(input())
print(c_factors_of_factorial(N))

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define int long long


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

    int h,w; cin >> h >> w;
    vector<vector<char> > s(h+2,vector<char>(w+2));
    for(int i = 1;i < h+1;i ++){
        for(int j = 1;j < w+1;j ++){
            cin >> s.at(i).at(j);
        }
    }

    vector<vector<int> > t(h+2,vector<int>(w+2,10000));
    t.at(0).at(1) = 0;

    for(int i = 0;i < 1000;i ++){
        for(int j = 1;j < h+1;j ++){
            for(int k = 1;k < w+1;k ++){
                if(s.at(j).at(k) == '.'){
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j).at(k-1)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j).at(k+1)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j-1).at(k)+1);
                    t.at(j).at(k) = min(t.at(j).at(k),t.at(j+1).at(k)+1);
                }
            }
        }

    }

    int count = 0;
    for(int i = 1;i < h+1;i ++){
        for(int j = 1;j < w+1;j ++){
            if(s.at(i).at(j) == '.') count ++;
        }
    }

    if(t.at(h).at(w) == 10000){
        cout << -1 << endl;
    }else{
        cout << count - t.at(h).at(w) << endl;
    }

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int H, N; cin >> H >> N;
    vector<pair<int,int>> AB(N);

    for(int i=0; i<N; i++){
        cin >> AB.at(i).first >> AB.at(i).second;
    }
    sort(AB.begin(), AB.end());

    int maxa = AB.at(N-1).first;
    vector<int> dp(H+maxa+1,1e9);
    dp.at(0) = 0;
    
    for(int i=1; i<=H+maxa; i++){

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

            if(AB.at(j).first <= i){

                dp.at(i) = min(dp.at(i), dp.at(i-AB.at(j).first)+AB.at(j).second);

            }

        }

    }

    int ans = 1e9;
    for(int i=H; i<=H+maxa; i++){
        ans = min(ans, dp.at(i));
    }

    cout << ans << endl;
    
    /*
    vector<vector<int>> dp(10000,vector<int>(10000));

    int ans = 1e9;

    for(int i=0; i<N; i++){
        if(AB.at(i).first >= H){
            ans = min(ans,AB.at(i).second);
        }else{
            dp.at(0).at(AB.at(i).first) = AB.at(i).second;
        }
    }

    for(int i=0; AB.at(0).first * i <= H; i++){

        for(int j=AB.at(0).first*(i+1); j<H; j++){

            if(dp.at(i).at(j) != 0 && dp.at(i).at(j) < ans){

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

                    if(j + AB.at(k).first >= H){
                        ans = min(ans,dp.at(i).at(j) + AB.at(k).second);
                    }else{
                        if(dp.at(i+1).at(j + AB.at(k).first) != 0){
                            dp.at(i+1).at(j + AB.at(k).first) = min(dp.at(i+1).at(j + AB.at(k).first), dp.at(i).at(j) + AB.at(k).second);
                        }else{
                            dp.at(i+1).at(j + AB.at(k).first) = dp.at(i).at(j) + AB.at(k).second;
                        }
                    }
                }

            }

        }
        

    }

    cout << ans << endl;
    */

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	
	printf("%s\n", std::string(s.size(), 'x').c_str());
	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 N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] X = new int[N];
		for(int i = 0; i < Q; i++)
			X[sc.nextInt()-1]++;
		for(int i = 0; i < N; i++) {
			if(K-Q+X[i] > 0)
				System.out.println("Yes");
			else
				System.out.println("No");
		}

	}

}

Measured memory_bytes: 61484
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int h, a; cin >> h >> a;
  if(h%a) cout << 1 + h / a << "\n";
  else cout << h / a << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
main()
{
    int N,d[50],i,m=0,n;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&d[i]);
    }
    for(i=0;i<N;i++)
    {
        for(n=0;n<N;n++)
        {
            if(n!=i)
            m+=d[i]*d[n];
        }
    }
    printf("%d",m/2);
    return 0;
}


Measured memory_bytes: 128
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<ll> vll;
//typedef vector<vll > vvll;
tdv(string, vs)

#define mod99 998244353

#define SIZE 5
const char STR[SIZE+1]="MARCH";


int main(int argc, const char * argv[]) {
    int N,M;
    cin>>N>>M;
    
    int k[10],p[10];
    int s[10][10];
    repi0(i, M){
        cin>>k[i];
        repi0(j, k[i]){
            int s1;
            cin>>s1;
            --s1;
            s[i][j]=s1;
        }
    }
    repi0(i, M){
        cin>>p[i];
    }
    
    int cnt=0;
    REPI0(sw1,l, 1<<N){
        bool flg=true;
        repi0(i, M){
            int num=0;
            repi0(j, k[i]){
                num^=(sw1>>s[i][j])&1;
            }
            if(num!=p[i]){
                flg=false;
                break;
            }
        }
        if(flg){
            ++cnt;
        }
    }
    cout<<cnt<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll c, n, m;
vector<pair<int, int>> ps;

int dp[10101][10101] = {0};
int main() {
  cin >> c >> n >> m;
  ps.resize(n);
  for (int i = 0; i < n; i++)
    cin >> ps[i].first >> ps[i].second;
  sort(ps.begin(), ps.end());
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < c; j++) {
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      if (j + 1 - ps[i].first >= 0)
        dp[i + 1][j + 1] =
            max(dp[i + 1][j + 1], dp[i][j + 1 - ps[i].first] + ps[i].second);
    }
  }

  for (int i = 1; i <= m; i++) {
    cout << dp[n][c / i] * i << endl;
  }

  return 0;
}


Measured memory_bytes: 397732
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int h,w;
    std::cin >> h>>w;
    vvector(c,char,h,w,'0');
    reprep(i,j,h,w)std::cin >> c[i][j];
    vvector(hi,int,h,w,0);
    vvector(wi,int,h,w,0);
    rep(i,h){
        if(c[i][0]=='#')wi[i][0]=0;
        else wi[i][0]=1;
    }
    rep(i,w){
        if(c[0][i]=='#')hi[0][i]=0;
        else hi[0][i]=1;
    }
    rep(i,h){
        rrep(j,1,w){
            if(c[i][j]=='#')wi[i][j]=0;
            else wi[i][j]=wi[i][j-1]+1;
        }
    }
    rep(j,w){
        rrep(i,1,h){
            if(c[i][j]=='#')hi[i][j]=0;
            else hi[i][j]=hi[i-1][j]+1;
        }
    }
    
    rep(j,w){
        rrep(i,1,h){
            if(hi[h-i][j]!=0&&hi[h-i-1][j])hi[h-i-1][j]=hi[h-i][j];
        }
    }
    rep(i,h){
        rrep(j,1,w){
            if(wi[i][w-j]!=0&&wi[i][w-j-1]!=0)wi[i][w-j-1]=wi[i][w-j];
        }
    }
    int ans=0;
    reprep(i,j,h,w)ans=max(ans,hi[i][j]+wi[i][j]);
    std::cout << ans-1 << std::endl;
}




Measured memory_bytes: 37632
from math import sqrt
n = int(input())
town = []
for i in range(n):
    town.append([int(i) for i in input().split()])
distance = 0
for i in range(n):
    for j in range(i + 1, n):
        distance += sqrt((town[i][0] - town[j][0])**2 + (town[i][1] - town[j][1])**2)
distance *= (2 / n)
print(distance)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
      int n,m;
      double b;
      cin>>n>>m;
      int a[n],sum=0,ans=0;
      for(int i=0;i<n;i++)
      {
      	cin>>a[i];
      	sum+=a[i];
	  }
	  b=(double)sum/4/m;
	  for(int i=0;i<n;i++)
	  {
	  	if(a[i]>=b)ans++;
	  }
	  if(ans>=m)cout<<"Yes";
	  else cout<<"No";
}


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

struct Node {
    int key;
    struct Node *rig, *lef, *parent;
};

struct Node *root,*NIL;

void insert(int);
void inorder(struct Node *);
struct Node * find(struct Node *,int k);
void preorder(struct Node *);


int main(){
    int n,i,x;
    char input[6];
    char inse[7] = "insert";
    char prin[7] =  "print";
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%s",input);
        if(input[0] == 'f'){
            scanf("%d",&x);
            struct Node *t = find(root,x);
            if(t != NIL) printf("yes\n");
            else printf("no\n");
        }else if(strcmp(input,inse) == 0){
            scanf("%d",&x);
            insert(x);
        }else if(strcmp(input,prin) == 0){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        }
    return 0;
    }

void insert(int k){
    struct Node *y = NIL;
    struct Node *x = root;
    struct Node *z;
    
    z = (struct Node *)malloc(sizeof(struct Node));
    z->key = k;
    z->lef = NIL;
    z->rig = NIL;
    
    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->lef;
        }else {
            x = x->rig;
        }
    }
    
    z->parent = y;
    if(y == NIL){
        root = z;
    }else {
        if(z->key < y->key){
            y->lef = z;
        }else{
            y->rig = z;
        }
    }
}

void inorder(struct Node *u){
    if(u == NIL) return;
    inorder(u->lef);
    printf(" %d",u->key);
    inorder(u->rig);
}

struct Node * find(struct Node *u,int k){
    while(u != NIL && k != u->key){
        if(k < u->key ) u = u->lef;
        else u = u->rig;
    }
    return u;
}

void preorder(struct Node *u){
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->lef);
    preorder(u->rig);
}



Measured memory_bytes: 20512
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> b[i];
    c[0] = a[0];
    c[n-1] = b[n-1];
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1]){
            if(c[i] && c[i]!=a[i]){
                cout << 0 << endl;
                return 0;
            }else c[i] = a[i];
        }else if(c[i]>a[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    if(a[n-1]!=b[0]){
        cout << 0 << endl;
        return 0;
    }
    if(b[n-1]!=c[n-1]){
        cout << 0 << endl;
        return 0;
    }
    for(int i=n-2;i>=0;i--){
        if(b[i]>b[i+1]){
            if(c[i] && b[i]!=c[i]){
                cout << 0 << endl;
                return 0;
            }else c[i] = b[i];
        }else if(c[i]>b[i]){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(int i=0;i<n;i++){
        if(c[i]==0){
            ans *= min(a[i],b[i]);
            ans %= mod;
        }
    }
    cout << ans%mod << endl;
}


Measured memory_bytes: 2688
INF = 10 ** 18


H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

dp = [[INF] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(H + 1):
        if j < AB[i][0]:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][0] + AB[i][1])
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - AB[i][0]] + AB[i][1])
    
print (dp[N][H])

# for d in dp:
#     print (d)

Measured memory_bytes: 119388
sx, sy, tx, ty = list(map(int, input().split()))

# UURDDLLUUURRDRDDDLLU
result = ""
result += "R" * (tx - sx) + "U" * (ty - sy) + "L" * (tx - sx) + "D" * (ty - sy)
result += "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
result += "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"

print(result)



Measured memory_bytes: 3060
import math
from functools import reduce

K = int(input())
sum = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        AB_gcd = math.gcd(a, b)
        for c in range(1, K+1):
            sum += math.gcd(AB_gcd, c)

print(sum)

Measured memory_bytes: 9580
n = int(input())
suits = ["S", "H", "C", "D"]
card_list = list()

for i in suits:
    for j in range(1, 14):
        card = (i + " " + str(j))
        card_list.append(card)

for k in range(n):
    cards = input()
    if cards in card_list:
        card_list.remove(cards)

for l in card_list:
    print(l)



Measured memory_bytes: 5592
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = lines[0]

    return (n, )


def solve(n, ):

    
    total = sum([int(e) for e in n])

    result = 'No' 
    #if sum(a) % 9 == 0:
    if total % 9 == 0:
        result = 'Yes'


    return result 


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

int main() {
  int R;
  cin >> R;
  if(R<1200){
    cout << "ABC" << endl;
  }else if(R<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}


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


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a > b) swap(a, b);
    if(b > c) swap(b, c);
    if(a > b) swap(a, b);
    
    cout<<a<<" "<<b<<" "<<c<<endl;
    
    return 0;
    
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    int n;
    cin >> n;
    vit a(n + 5, INF);
    rep(i, n){
      cin >> a[i];
    }
    sort(all(a));
    int sum = 0, ans = 0;
    rep(i, n){
      sum ++;
      if(a[i] != a[i + 1]){
	if(sum >= a[i]){
	  ans += sum - a[i];
	} else {
	  ans += sum;
	}
	sum = 0;
      }
    }
    cout << ans << '\n';
    return 0;
}


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

int main(){
    string s1, s2, s3;
    cin >> s1;
    cin >> s2;
    cin >> s3;
    cout << s1[0] << s2[1] << s3[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int inf=1e8;
struct edge{
    int to,cap,cost,rev;
};
typedef vector<edge> ve;
typedef vector<ve> vve;
class MCF{    //Minimum Cost Flow
public:
    int n;
    vve G;
    vi h,dist,prev,pree;
    MCF(int size){
        n=size;
        G=vve(n);
        h=dist=prev=pree=vi(n);
    }
    void add_edge(int s,int t,int ca,int co){
        edge e={t,ca,co,(int)G[t].size()};
        G[s].pb(e);
        edge ee={s,0,-co,(int)G[s].size()-1};
        G[t].pb(ee);
    }
    int mcf(int s,int t,int f){
        int out=0;
        h=vi(n);
        while(f>0){
            priority_queue<pii,vector<pii> >q;
            dist=vi(n,inf);
            dist[s]=0;
            q.push(pii(0,s));
            while(!q.empty()){
                pii p=q.top();q.pop();
                int v=p.second;
                if(dist[v]<-p.first)continue;
                rep(i,G[v].size()){
                    edge &e=G[v][i];
                    if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
                        dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
                        prev[e.to]=v;
                        pree[e.to]=i;
                        q.push(pii(-dist[e.to],e.to));
                    }
                }
            }
            if(dist[t]==inf)return -1;
            rep(i,n)h[i]+=dist[i];
            int d=f;
            for(int v=t;v!=s;v=prev[v])d=min(d,G[prev[v]][pree[v]].cap);
            f-=d;
            out+=d*h[t];
            for(int v=t;v!=s;v=prev[v]){
                edge &e=G[prev[v]][pree[v]];
                e.cap-=d;
                G[v][e.rev].cap+=d;
            }
        }
        return out;
    }
};
signed main(){
    //n個のレポート, m人の友だち
    
    int n,m,k; cin >> n >> m >> k;
    vector<vector<int>>v(m+1,vector<int>(n));
    rep(i,m+1)rep(j,n) cin >> v[i][j];
    vector<int>frd;
    frd.push_back(n);
    rep(i,m){
        int tmp; cin >> tmp;
        frd.push_back(tmp);
    }
    MCF fl(n+m+5);
    //fl.add_edge(int s, int t, int cap, int cost)
    int source = n+m+5 - 2;
    int sink = n+m+5-1;
    int fri = source-1;
    int msl = fri - 1;
    fl.add_edge(msl, sink, n, 0);
    fl.add_edge(fri, sink, n-k, 0);
    //各レポートに辺を貼る
    rep(i,n)fl.add_edge(source,i, 1, 0);
    rep(i,n)rep(j,m+1){
        fl.add_edge(i,n+j,1, 1000-v[j][i]);
    }
    rep(i,m+1){
        fl.add_edge(n+i, (i!=0?fri:msl),frd[i],0);
    }
    cout << 1000*n-fl.mcf(source, sink, n) << endl;
}



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

int main(){
  int N,M; cin >> N >> M;
  vector<vector<int>> v(N+1);
  for(int i=0;i<M;i++){
    int a,b; cin >> a >> b;
    v[a].push_back(b);
  }
  
  for(auto c:v[1]){
    for(auto d:v[c]){
      if(d==N){
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
  }
  
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 8576
import scala.util.Random

object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val rule = Array.tabulate(n){_ ⇒ readLine.trim}
  if (rule.exists(!_.contains('x'))) {
    val hand = rule.indices.find(!rule(_).contains('x')).get
    for (_ ← 0 until 1000){
      println(hand + 1)
      readInt
    }
  }else {
    val scores = rule.map(_.count(_ == 'o'))
    for (i ← rule.indices.tail) scores(i) += scores(i - 1)
    val sum = scores.last
    val random = new Random()
    for (_ ← 0 until 1000) {
      val next = lowerBound(scores, random.nextInt(sum))
      println(next + 1)
      readInt
    }
  }
  def lowerBound(array: Array[Int], target: Int): Int = {
    var left = 0
    var right = array.length - 1
    while (left < right){
      val mid = (left + right) / 2
      if (array(mid) < target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 45412
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
local function tostringx(o)if type(o) == 'table' then local keys = {}for k in pairs(o) do table.insert(keys, k) end table.sort(keys)local inside = {}for i=1,#keys do local k = keys[i]local v = o[k]if type(k) == 'string' then k = string.format('%q', k)end table.insert(inside, '['..k..'] = ' .. tostringx(v))end return '{' .. table.concat(inside, ', ') .. '}'else if type(o) == 'string' then o = string.format('%q', o)end return tostring(o)end end
----
local N = read.n()
local A = read.N(N)
local t = array(2)
for i=1,N do
    t[i][i] = A[i]
end
local function rec(i, j)
    if t[i][j] then
        return t[i][j]
    end
    local ri = A[j] - rec(i, j-1)
    local le = A[i] - rec(i+1, j)
    local ret = math.max(ri, le)
    t[i][j] = ret
    return ret
end
print(rec(1, N))

Measured memory_bytes: 82688