akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: String,
    }
    let l = s.len() - 2;
    println!(
        "{}{}{}",
        s.chars().collect::<Vec<_>>()[0],
        l,
        s.chars().collect::<Vec<_>>().last().unwrap()
    );
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int FindSum(int n,int x){
    int i=0;
        for(int m=1;m<=n-2;m++){
            for(int l=m+1;l<=n-1;l++){
                for(int k=l+1;k<=n;k++)
                if(m+l+k==x)i+=1;
            }
        }
    return i;
    }

int main(){
    int n,x;
    while(1){
       cin>>n>>x;
       if(n==0&&x==0)break;
       cout<<FindSum(n,x)<<endl;
}return 0;}


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

using namespace std;

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

    map<int, int> mp;
    while (m--) {
        int a, b;
        cin >> a;
        cin >> b;
        mp[a]++;
        mp[b]++;
    }

    for (auto &x :mp) {
        if ((x.second) % 2 != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

int main(){
    int n;
    cin >> n;
    vi b(n, 100001), a(n+1, 0);
    rep(i, n-1) cin >> b[i];
    
    a[0] = b[0];
    repa(i, 1, n){
        a[i] = min(b[i-1], b[i]);
    }

    int sum = 0;
    rep(i, n) sum += a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  K--;
  if(S.at(K) == 'A'){
  	S.at(K) = 'a';
  }else if(S.at(K) == 'B'){
    S.at(K) = 'b';
  }else if(S.at(K) == 'C'){
  	S.at(K) = 'c';
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
include Math

x, y = 0, 0
s = 90

while true
  d, si = gets.chomp.split(",").map(&:to_f)
  break if d == 0 && si == 0
  x += d * cos(2 * PI * s / 360)
  y += d * sin(2 * PI * s / 360)
  s -= si
end

puts x.truncate
puts y.truncate

Measured memory_bytes: 6180
n = int(input())
m = [[0 for j in range(n + 1)] for i in range(n + 1)]
z = [0] * (n + 1)
for i in range(1, n + 1):
    z[i - 1], z[i] = map(int, input().split())
j = 0
for l in range(2, n + 1):
    for i in range(1, n - l + 2):
        j = i + l - 1
        m[i][j] = int(1e8)
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + z[i - 1] * z[k] * z[j])
print(m[1][n])

Measured memory_bytes: 7744
# https://abc054.contest.atcoder.jp/tasks/abc054_d

N, Ma, Mb = map(int, input().split())
la, lb, lc = [], [], []
for _ in range(N):
    ai, bi, ci = map(int, input().split())
    la.append(ai)
    lb.append(bi)
    lc.append(ci)

sumA = sum(la)
sumB = sum(lb)

Inf = int(1e10)

dp = [[[Inf for _ in range(sumB + 1)] for _ in range(sumA + 1)] for _ in range(N + 1)]
dp[0][0][0] = 0


for i in range(1, N + 1):
    ai, bi, ci = la[i - 1], lb[i - 1], lc[i - 1]

    for j in range(sumA + 1):
        for k in range(sumB + 1):
            dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k])
            if j - ai >= 0 and k - bi >= 0 and dp[i - 1][j - ai][k - bi] != Inf:
                dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - ai][k - bi] + ci)

ans = Inf
for j in range(1, sumA + 1):
    for k in range(1, sumB + 1):
        if Mb * j == Ma * k:
            ans = min(ans, dp[N][j][k])
if ans == Inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 65628
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int N,M,p;
	cin >> N >> M >> p;
	vector<int> s;
	for(int i = 0 ; i < M ; i++){
		int x;
		cin >> x;
		s.push_back((x-p+N)%N);
	}
	sort(s.begin(),s.end());
	int ans = min(s[s.size()-1],N-s[0]);
	for(int i = 0 ; i+1 < s.size() ; i++){
		int a = s[i];
		int b = N - s[i+1];
		ans = min(ans, min(a,b) * 2 + max(a,b) );
	}
	cout << ans*100 << endl;
}

Measured memory_bytes: 1328
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    sa = input()
    sb = input()
    sc = input()
    s1 = 0
    s2 = 0
    s3 = 0
    nxt = 'a'
    ans = 'A'
    while s1 <= len(sa) and s2 <= len(sb) and s3 <= len(sc):
        if nxt == 'a':
            if s1 >= len(sa):
                ans = 'A'
                break
            nxt = sa[s1]
            s1 += 1
        elif nxt == 'b':
            if s2 >= len(sb):
                ans = 'B'
                break
            nxt = sb[s2]
            s2 += 1
        else:
            if s3 >= len(sc):
                ans = 'C'
                break
            nxt = sc[s3]
            s3 += 1
    print(ans)
    return

if __name__=='__main__':
    main()


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

const int mxN = 3e3 + 5;
double dp[mxN][mxN], a[mxN];

int main() {
	int n;
	scanf("%d", &n);
	dp[0][0] = 1;
	for(int i = 1; i <= n; ++i) {
		scanf("%lf", &a[i]);
		double t = 1 - a[i];
		dp[i][0] = dp[i - 1][0] * t;
		for(int j = 1; j <= i; ++j) {
			dp[i][j] = (double)dp[i - 1][j] * t;
			dp[i][j] += (double)dp[i - 1][j - 1] * a[i];
		}
	}
	double answer = 0;
	for(int i = (n + 1) / 2; i <= n; ++i)
		answer += dp[n][i];
	printf("%0.10f", answer);
}


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

int main() {
    int n;
    cin >> n;
    int w[n];
    for (int i = 0; i < n; i++)
        cin >> w[i];
    
    int ans = 99999999;
    for (int i = 1; i < n; i++) {
        int s1 = 0;
        for (int j = 0; j < i; j++) {
            s1 += w[j];
        }

        int s2 = 0;
        for (int j = i; j < n; j++) {
            s2 += w[j];
        }

        ans = min(ans, abs(s1-s2));
    } 

    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   string a="" ,b="";
   for(int i=1;i<=n;i++)
   {
       string tmp;
       cin>>tmp;
       a+=tmp;
   }
   for(int i=1;i<=n;i++)
   {
       string tmp;
       cin>>tmp;
       b+=tmp;
   }
   //cin>>a>>b;
   string str="";
   for(int i=1;i<=n;i++)
   {
      str+= to_string(i);
   }
   
   int k=0 , p, q;

   do
   {
       k++;
       if(str==a)
       {
           p=k;
       }
       if(str==b)
       {
           q=k;
       }
   } while(next_permutation(str.begin() , str.end()));
   cout<<abs(p-q)<<endl;
}

Measured memory_bytes: 256
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pi pair<int,int>
#define pl pair<long,long>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod (ll)(1e9+7)
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>
#define INF 0x3f3f3f3f
#define mp make_pair

ll dp[1005][1005];

int main()
{
    ll a,b;
    in2(a,b);
    if(a-(2*b) >=0 ) cout<<a-(2*b);
    else cout<<0<<endl;
    return 0;
}

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

using namespace std;
#define lli long long int
vector<lli> V[200005];
lli n,k,dep[200005],nod,cd,vis[200005],ret,cnt;

void dfs(lli node, lli par)
{
  dep[node]=dep[par]+1;
  lli l=V[node].size();
  for(lli i=0;i<l;i++)
  {
    if(dep[V[node][i]]==-1)
    {
      dfs(V[node][i],node);
    }
    else
    {
      if(nod==0)
        nod=V[node][i];
      if(cd==0)
        cd=dep[node]-dep[nod]+1;
      return;
    }
  }
}

void dfs1(lli node)
{
    vis[node]=1;
    lli i,l=V[node].size();
    for(i=0;i<l;i++)
    {
        if(!vis[V[node][i]])
        {
            ++cnt;
            if(cnt==k)
                ret=V[node][i];
            dfs1(V[node][i]);
        }
    }
}

int main()
{
  lli i,u,v;
  cin>>n>>k;
  for(i=1;i<=n;i++)
  {
    cin>>u;
    V[i].push_back(u);
  }
  memset(dep, -1, 8*(n+1));
  dep[1]=0;
  dfs(1,0);
  if(k>=dep[nod])
  {
      k-=dep[nod];
      k%=cd;
  }
  else
  {
      nod=1;
  }
  if(k==0)
    cout<<nod<<"\n";
  else
  {
      dfs1(nod);
      cout<<ret<<"\n";
  }
  return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int x, y;
    cin >> x >> y;

    int arr[] = {0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};

    if (arr[x] == arr[y])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = Counter(a)
ans = 0

def make(x):
    num = 1
    while num <= x:
        num *= 2
    return num

for i in range(n):
    x = make(a[i])
    if cnt[x - a[i]] > 0 and cnt[a[i]] > 0 and x != 2 * a[i]:
        ans += 1
        cnt[x - a[i]] -= 1
        cnt[a[i]] -= 1
    elif x == 2 * a[i] and cnt[a[i]] > 1:
        ans += 1
        cnt[a[i]] -= 2

print(ans)

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

std::vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     
        IsPrime.resize(max+1,true); 
    } 
    IsPrime[0] = false; 
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i)
        if(IsPrime[i]) 
            for(size_t j=2; i*j<=max; ++j) 
                IsPrime[i*j] = false;      
}


int main()
{
    long X;
    std::cin >> X;
    sieve(2*X);
    for(long i=X; i<2*X; i++){
        if(IsPrime[i]==true){
            std::cout << i << std::endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [n,m] = nextIntArray()
    let a = nextIntArray()
    for(let i = 0; i<a.length;i++){
        n -= a[i]
    }
    if(n < 0){
        console.log(-1)
        return
    }else {
        console.log(n)
    }

}
Main()


Measured memory_bytes: 30632
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
#define P 1000000007
typedef long long ll;
int n , m;
int dp[12][10];
vi ans;

void solve() {
    cin >> n;
    ans.clear();
    if (n < 10) return void(cout << n << endl);
    int re = 0;
    for (int i = 0; i < 10; ++i) dp[1][i] = 1, re += 1;
    for (int i = 2; i <= 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j) dp[i][j] += dp[i - 1][j - 1];
            if (j != 9) dp[i][j] += dp[i - 1][j + 1];
            if (j) re += dp[i][j];
            if (re > n) {
                re -= dp[i][j];
                ans.pb( j );
                int cur = j;
                for( int t = i - 1 ; t >= 1 ; -- t ) {
                    if( cur && dp[t][cur - 1] + re > n ) { -- cur , ans.pb( cur ); continue; }
                    if( cur ) re += dp[t][cur - 1];
                    if( dp[t][cur] + re > n ) { ans.pb( cur ); continue; }
                    re += dp[t][cur];
                    ++ cur , ans.pb( cur );
                }
                for (int t : ans) printf("%d", t);
                return;
            }
        }
    }

}
signed main() {
//    freopen("2.in","r",stdin);
//    freopen("fuckout","w",stdout);
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


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

#define REP(i, s, n) for (ll i = s; i < n; i++)
#define setarr(arr, v) for (ll i = 0; i < sizeof(arr)/sizeof(arr[0]); ++i) {arr[i] = v;}
#define pvar(x) cout << #x << " = " << x << endl;
#define mset(x, v) memset(x, v, sizeof(x));
#define fi() first
#define se() second
#define pb() push_back
#define be() begin()
#define en() end()
#define len() length()
#define mp(x, y) make_pair(x, y)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<ll> sll;
typedef queue<ll> qll;

#define let auto

template<class U, class V>
ostream& operator<<(ostream& os, const pair<U, V>& p) {os << "(" << p.first << ", " << p.second << ")";return os;}

template<class U, class V>
istream& operator>>(istream& in, pair<U, V>& p) {in >> p.first >> p.second;return in;}

namespace cp {
    template <typename T>
    T min (T first) {return first;}
    template <typename T, typename... Args>
    T min (T first, Args... args) {return std::min (first, min (args...));}

    template <typename T>
    T max (T first) {return first;}
    template <typename T, typename... Args>
    T max (T first, Args... args) {return std::max (first, max (args...));}
};

using cp::min;
using cp::max;

ll n = 3e5 + 100;
const ll N = 2e6;
ll tree[N];

ll range_max (ll l, ll r) { // [l, r)
    ll res = 0;
    for (l += n, r += n; l < r; l>>=1, r >>=1) {
	if (l & 1) {
	    res = max(res, tree[l++]);
	}
	if (r & 1) {
	    res = max (res, tree[--r]);
	}
    }
    return res;
}

void point_update (ll i, ll v) {
    for (tree[i+=n] = v; i > 1; i >>= 1) {
	tree[i>>1] = max(tree[i], tree[i^1]);
    }
}

void solve () {
    ll n, k; cin >> n >> k;
    ll arr[n];
    for (ll i = 0; i < N; i++) {tree[i] = 0;}
    for (ll i = 0; i < n; i++) {
	cin >> arr[i];
    }

    point_update (arr[0], 1);
    ll re = 1;
    for (ll i = 1; i < n; i++) {
	ll res = range_max(max(0ll, arr[i]-k), min ((ll)3e5+1, arr[i]+k+1));
	point_update (arr[i], res+1);
	re = max(re, res+1);
    }

    cout << re << endl;
}


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


Measured memory_bytes: 21592
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
#define INF 1000000000
typedef long long ll;

int G[10][10], d[10], cost[10];
bool visited[10];


void bfs(int x) {
    if(x==1) return;
    
    rep(i,10) d[i]=INF;
    mem( visited, false);
    int u = x;
    d[x] = 0;
    
    while(true){
        
        int minv = INF;
        visited[u] = true;

        for(int i=0; i<10; i++){
            if( d[i]>d[u]+G[u][i] ){
                d[i] = d[u]+G[u][i];
            }
        }
        
        for(int i=0; i<10; i++){
            if( !visited[i] && d[i]<minv ) {
                u = i;
                minv = d[i];
            }
        }
        
        if(u==1) {
            cost[x] = d[u];
            return;
        }
    }
    
}

int main() {
    int H, W;
    
    cin >> H >> W;
    
    rep(i,10)rep(j,10) cin >> G[i][j];
    
    rep(i,10) d[i] = INF;
    
    rep(i,10) bfs(i);
    
    int x, ans=0;
    rep(i,H) {
        rep(j,W){
            cin >> x;
            if(x==-1 || x==1) continue;
            ans += cost[x];
        }
    }
    
    cout1(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int a[200005];
int main() {
  int n;
  cin >> n;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cur ^= a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << (cur ^ a[i]) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 4344
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b; 
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef long long i64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	const int n = read_item();
	vector<int> xs(n);

	for(auto i : range(n)) {
		xs[i] = read_item();
	}

	int ans = 100000000;

	for(int p = 0; p <= 100; p++) {
		int a = 0;
		for(auto x : xs) {
			const int d = x - p;
			a += d * d;
		}
		ans = min(ans, a);
	}

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

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
  
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, m;
  cin >> n >> m;
  
  vector<bool> not_broken(n+1, true);
  rep(i, 0, m) {
    ll a;
    cin >> a;
    not_broken[a] = false;
  }
  
  vector<ll> dp(n+1, 0);
  dp[0] = 1;
  rep(i, 0, n) {
    if(not_broken[i+1]) {
      dp[i+1] += dp[i];
      dp[i+1] %= 1000000007;
    }
    if(i+2 <= n and not_broken[i+2]) {
       dp[i+2] += dp[i];
       dp[i+2] %= 1000000007;
    }
  }
  
  cout << dp[n] << "\n";
}

Measured memory_bytes: 1024
/*input
10000 1
*/

#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>

using namespace std;

void run() {
	int a, b;
	cin >> a >> b;
	cout << (a + b - 1) / b << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	//cin >> t;
	while(t--) {
		run();
	}
}


Measured memory_bytes: 256
const long long MOD = 1000000007;
#include <bits/stdc++.h>
using namespace std; void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> void vecout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}

template <std::uint_fast64_t Modulus> class modint {
public:
  ll a;
  constexpr modint(const ll x = 0) noexcept : a(x % Modulus) {}
  constexpr ll &value() noexcept { return a; }
  constexpr const ll &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    ll exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

void solve(){
	ll L,R; cin>>L>>R;
	auto dp=make_v(61,2,2,2,modint<MOD>(0));
	dp[60][0][0][0]=modint<MOD>(1);
	for(ll i=59;i>=0;--i){
		ll lb=L>>i&1, rb=R>>i&1;
		rep(j,2)rep(k,2)rep(s,2){
			rep(x,2)rep(y,2){
				ll nj=j,nk=k,ns=s;
				if(x>y) continue;
				// j:L<=X
				if(!j && lb>x) continue;
				if(lb<x) nj=1;
				// k:Y<=R
				if(!k && y>rb) continue;
				if(y<rb) nk=1;
				// s:MSB
				if(!s && x!=y) continue;
				if(x==1 && y==1) ns=1;
				dp[i][nj][nk][ns]+=dp[i+1][j][k][s];
			}
		}
	}
	modint<MOD> ans=0;
	rep(j,2)rep(k,2)rep(s,2) ans+=dp[0][j][k][s];
	cout<<ans.a<<"\n";
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N, X; cin >> N >> X;
    vi m(N); REP(i, N) cin >> m[i];
    int sum = 0, min = INF;
    REP(i, N)
    {
        sum += m[i];
        if(min > m[i]) min = m[i];
    }
    X -= sum;
    cout << N + X / min << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
S = gets.chomp.chars
ans = true
S.each.with_index do |ch, i|
  i += 1
  if i.odd?
    ans = false unless ['R', 'U', 'D'].include?(ch)
  else
    ans = false unless ['L', 'U', 'D'].include?(ch)
  end
end
puts(ans ? 'Yes' : 'No')


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

int N, M;
vector<int> L;
vector<int> R;

int main() {
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        int l, r;
        cin >> l >> r;
        L.emplace_back(l);
        R.emplace_back(r);
    }

    int card_min = 1;
    int card_max = N;
    for(int i = 1; i <= M; i++) {
        if(card_min < L[i - 1]) card_min = L[i - 1];
        if(card_max > R[i - 1]) card_max = R[i - 1];
    }
    cout << max(0, card_max - card_min + 1) << endl;
    return 0;
}

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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


const int N = 1e5+100, lim = 22;

vector<int> g[N];
int dp[N];

void dfs(int u, int p) {
    vector<int> cnt(lim);
    for(int v : g[u]) {
        if(v == p) continue;
        dfs(v, u);
        int x = dp[v];
        for(int k = 0; k < lim; k++) {
            if((x >> k) & 1) cnt[k]++;
        }
    }
    int t = 0;
    int mask = 0;
    for(int k = lim-1; k >= 0; k--) {
        if(cnt[k] >= 2) {
            t = k+1;
            break;
        }
    }
    for(int k = t; k < lim; k++) {
        if(cnt[k] == 0) {
            mask |= (1<<k);
            for(int kk = k+1; kk < lim; kk++) {
                if(cnt[kk]) {
                    mask |= (1<<kk);
                }
            }
            break;
        }
    }
    dp[u] = mask;
}


int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, -1);
//
//    for(int i = 1; i <= n; i++){
//        cout << i << " -> " << dp[i] << endl;
//    }
//

    int mask = dp[1];
    int msb = -1;
    for(int k = 0; k < lim; k++) {
        if((mask >> k) & 1) {
            msb = k;
        }
    }
    cout << msb << endl;
}





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

int main(){
  int H,N,MAX=0;
  cin>>H>>N;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    MAX+=A;
  }

  if(MAX>=H){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

return 0;
}


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

const int BIT_SZ = 60;
struct BitMatrix {
    int N, SZ;
    vector<bitset<BIT_SZ>> val;
    BitMatrix(int n = 1, int sz = BIT_SZ) : N(n), SZ(sz), val(n) { }
    bitset<BIT_SZ>& operator[](int i) { return val[i]; }
};
int gauss_jordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = A.SZ - 1; col >= 0; --col) {
        if (is_extended && col == A.SZ - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.N; ++row) {
            if (A[row][col]) { pivot = row; break; }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.N; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int main() {
    int n; cin >> n;
    vector<long long> a(n);
    for (auto &ai: a) cin >> ai;
    long long odd = 0;
    for (int i = 0; i < n; i++) odd ^= a[i];
    BitMatrix A(n);
    for (int d = 0; d < BIT_SZ; d++) {
        if (odd >> d & 1) continue;
        for (int i = 0; i < n; i++) if (a[i] >> d & 1) A[i][d] = 1;
    }
    gauss_jordan(A);
    bitset<BIT_SZ> even = 0;
    for (int i = 0; i < n; i++) even ^= A[i];
    cout << odd + even.to_ullong() * 2 << endl;
    return 0;
}

Measured memory_bytes: 1792
#import pysnooper
import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy

setrecursionlimit(10**6)

n=int(stdin.readline().rstrip())
v=sorted([int(i) for i in stdin.readline().rstrip().split()])
now=(v[0]+v[1])/2
for i in range(2,n):
    now=(now+v[i])/2
print(now)

Measured memory_bytes: 38640
// ABC156C - Rally

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

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

	vector<int> X(N);
	for (int i = 0; i < N; i++) {
		cin >> X.at(i);
	}

	int minimum = 100000000, temp_min;
	for (int i = 1; i <= 100; i++) {
		temp_min = 0;
		for (int j = 0; j < N; j++) {
			temp_min += (X.at(j) - i) * (X.at(j) - i);
		}
		minimum = min(minimum, temp_min);
	}

	cout << minimum << endl;
}


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

int main(int argc, char const *argv[])
{
    int a, *Fibonacci;
    cin >> a;
    Fibonacci = (int *)malloc((a+1) * sizeof(int));
    Fibonacci[0] = Fibonacci[1] = 1;
    for(int i=2; i<=a; ++i) {
        Fibonacci[i] = Fibonacci[i-1] + Fibonacci[i-2];
    }
    cout << Fibonacci[a] << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    int min=1001,max=-1,t;
    while(n--){
        scanf("%d",&t);
        if(t<min) min=t;
        if(t>max) max=t;
    }
    printf("%d\n",max-min);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
typedef pair<double, double> P;
double nijo(P p) {
    double x, y;
    tie(x, y) = p;
    return x * x + y * y;
}
P calc(P p1, P p2, P p3) {
    double x1, x2, x3, y1, y2, y3;
    tie(x1, y1) = p1;
    tie(x2, y2) = p2;
    tie(x3, y3) = p3;
    P ret;
    double a, b, c, d;
    a = x1 - x2;
    b = y1 - y2;
    c = x2 - x3;
    d = y2 - y3;
    ret.first = d * (nijo(p1) - nijo(p2)) - b * (nijo(p2) - nijo(p3));
    if (a * d != b * c)
        ret.first /= 2 * (a * d - b * c);
    else
        ret.first = INF;
    ret.second = -c * (nijo(p1) - nijo(p2)) + a * (nijo(p2) - nijo(p3));
    if (a * d != b * c)
        ret.second /= 2 * (a * d - b * c);
    else
        ret.first = INF;
    return ret;
}
double dist(P a, P b) {
    double ax, ay, bx, by;
    tie(ax, ay) = a;
    tie(bx, by) = b;
    return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}
int main() {
    int n;
    cin >> n;
    vector<P> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;
    double ans = INF;
    rep(i, n) rep(j, i) rep(k, j) {
        double cx, cy;
        tie(cx, cy) = calc(p[i], p[j], p[k]);
        double r = sqrt((cx - p[i].first) * (cx - p[i].first) +
                        (cy - p[i].second) * (cy - p[i].second));
        bool ok = 1;
        rep(l, n) {
            ok &= dist(make_pair(cx, cy), p[l]) <= r + 0.0000001;
        }
        if (ok) chmin(ans, r);
    }
    rep(i, n) rep(j, i) {
        double cx, cy;
        cx = (p[i].first + p[j].first) / 2;
        cy = (p[i].second + p[j].second) / 2;
        double r = sqrt((cx - p[i].first) * (cx - p[i].first) +
                        (cy - p[i].second) * (cy - p[i].second));
        bool ok = 1;
        rep(l, n) {
            ok &= dist(make_pair(cx, cy), p[l]) <= r + 0.0000001;
        }
        if (ok) chmin(ans, r);
    }
    cout << fixed << setprecision(20) << ans << endl;
}

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

int main() {
    int n, alice = 0, bob = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end(), greater<int>());
    rep(i, n) {
        if(i % 2) bob += a.at(i);
        else alice += a.at(i);
    }
    cout << alice - bob << endl;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
	int a;
	cin>>a;
	cout<<(a+(a*a)+(a*a*a))<<"\n";		
}

int main()
{
// #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
// #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3616
#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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int D, N; cin >> D >> N;
    int seed = pow(100, D);

    cout << ((N == 100)? seed*101 : seed*N) << endl;
}

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

using namespace std;

#define forn(i, n) for (int64_t i = 0; i < (int64_t) (n); ++i)
#define endl '\n'

template<typename T> void _dbg(const char*_s,T _h) { cerr<<_s<<" = "<<_h<<"\n"; }

template<typename T, typename... Ts> void _dbg(const char*_s,T _h,Ts... _t) {
    for(int _b=0;((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',';)cerr<<*_s++;
    cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);
}

#define int long long

#ifdef LOCAL
    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
    #define dbg(...)
#endif

const int N = 500 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;

bool read() {
    if (!(cin >> n >> m))
        return false;

    return true;
}

void solve() {
    multiset<int> kek;

    forn (i, n) {
        int x;
        cin >> x;
        kek.insert(x);
    }

    forn (i, m) {
        auto x = *kek.rbegin();
        kek.erase(--kek.end());
        x /= 2;
        kek.insert(x);
    }

    int sum = 0;

    forn (i, n) {
        sum += *kek.begin();
        kek.erase(kek.begin());
    }
    
    cout << sum << endl;
}

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

    while (read())
        solve();

    return 0;
}



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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;
    int N, M;
    cin >> N >> M;
    scc_graph graph(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        graph.add_edge(a, b);
    }
    auto res = graph.scc();
    printf("%zu\n", res.size());
    for(auto v : res) {
        printf("%zu%c", v.size(), (v.size() == 0) ? '\n' : ' ');
        for(int i = 0; i < int(v.size()); ++i) {
            printf("%d%c", v[i], (i != v.size() - 1) ? ' ' : '\n');
        }
    }

    return 0;
}


Measured memory_bytes: 40124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication24
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int a = int.Parse(Console.ReadLine());
                if (a == 0)
                    break;
                int[] b = new int[a];
                int c, d, e, f, g, h, i;
                c = d = e = f = g = h = i = 0;
                for (int j = 0; j < a; j++)
                {
                    b[j] = int.Parse(Console.ReadLine());
                    if (b[j] < 10)
                        c++;
                    else if (b[j] < 20)
                        d++;
                    else if (b[j] < 30)
                        e++;
                    else if (b[j] < 40)
                        f++;
                    else if (b[j] < 50)
                        g++;
                    else if (b[j] < 60)
                        h++;
                    else if (b[j] > 59)
                        i++;
                }
                Console.WriteLine(c);
                Console.WriteLine(d);
                Console.WriteLine(e);
                Console.WriteLine(f);
                Console.WriteLine(g);
                Console.WriteLine(h);
                Console.WriteLine(i);
            }

            }
        }
    }

Measured memory_bytes: 16804
function Main(input) {
	var S = input.split("\n")
	switch (S[0]) {
		case "Sunny":
			console.log("Cloudy");
			break;
		case "Cloudy":
			console.log("Rainy");
			break;
		case "Rainy":
			console.log("Sunny");
			break;
	}
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 23092
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    String op = sc.next();
    int b = sc.nextInt();
    if(op.equals("+")){
      System.out.println(a + b);
    }else{
      System.out.println(a - b);
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int X; cin >> X;
	cout << 10 - (X / 200) << endl;
}

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


Measured memory_bytes: 3644
d,e=[input().split()for _ in'12'];e[3:5]=e[4],e[3]
t=0
for p in('012345','152304','215043','310542','402351','513240'):
 f=[d[int(j)]for j in p];f[3:5]=f[4:2:-1]
 if f[0]==e[0]:
  f=f[1:5]*2
  for j in range(4):
   if f[j:j+4]==e[1:5]:t=1
print(('No','Yes')[t])



Measured memory_bytes: 5604
s = str(input())
ans = 0
for i in range(2**(len(s) - 1)):
    l = s[0]
    for j in range(len(s)-1):
        if (i >> j) & 1:
            l += "+"
        l += s[j+1]
    ans += eval(l)#eval関数は文字列を数式としてその解を返す
print(ans)

Measured memory_bytes: 9004
#include<iostream>
using namespace std;
const int N=2e5+5;
int a[N]={0},n,x,res,i;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x;
		a[x]++;
	}
	for(i=1;i<100000;i++)res=max(res,a[i-1]+a[i]+a[i+1]);
	cout<<res;
}

Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

int dp[2][2019];
int main(){
  std::string S;
  std::cin >> S;
  int n = S.length();
  int value = int(S[0])-int('0');
  dp[0][value]=1;
  long long ans = 0;
  for (int i=1; i<n; i++){
    int value = int(S[i])-int('0');
    dp[i%2][value]=1;
    for (int j=0; j<2019; j++){
      if (dp[(i+1)%2][j]!=0){
        dp[i%2][(j*10+value)%2019] += dp[(i+1)%2][j];
      }
    }
    ans += dp[i%2][0];
    for (int j=0; j<2019; j++){
      dp[(i+1)%2][j]=0;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3352
#include<stdio.h>
int main(void)
{
	int K,A,B,flg,i;
	scanf("%d %d %d",&K,&A,&B);
	flg=0;
	for(i=A;i<=B;i++){
		if(i%K==0){
			flg=1;
		}
	}
	if(flg==1){
		printf("OK\n");
	}
	else{
		printf("NG\n");
	}
	return 0;
}


Measured memory_bytes: 1628
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(i<10)ans++;
		if(100<=i&&i<=999)ans++;
		if(10000<=i&&i<=99999)ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  for (auto x = 1; x <= 50000; x++) {
    if (floor(x * 1.08) == n) {
      cout << x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

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

using namespace std;

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

// a^n mod を計算する
long int modpow(long int a, long int n, long int mod) {
    long int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

long int modcomb(long int a, long int b, long int mod){
    long int res = 1;
    for(long int i = a; i > a - b; i--){
        res *= i % mod;
        res %= mod;
    }
    res %= mod;
    for(long int i = 1; i <= b; i++){
        long int i_inv = modpow(i, mod - 2, mod);
        res *= i_inv % mod;
        res %= mod;
    }
    res %= mod;
    // cout << res << endl;
    return res;
}


int main(){
    long int n, m, k;
    cin >> n >> m >> k;
    const long int mod = 1000000007;
    long int x = 0;
    long int y = 0;
    for (long int i = 1; i <= n - 1; i++){
        x += (n - i) * (m * m) * i;
        x %= mod;
    }
    for (long int i = 1; i <= m - 1; i++){
        y += (m - i) * (n * n) * i;
        y %= mod;
    }
    long int ans = x + y;
    ans %= mod;
    ans *= modcomb(n * m - 2, k - 2, mod);
    ans %= mod;
    cout << ans << endl;
}


Measured memory_bytes: 256