akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
//#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N = 2e5 + 50;
ll mod = 998244353;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}
bool ispal(string k) {
    cout << k << " ";
    for(int i = 0; i < k.size(); i++) {
        if(k[i] == k[k.size() - i - 1])
            continue;
        return false;
    }
    return true;
}
int grid[1001][1001];
int f[1001][1001], f2[1001][1001];;
int cuts(int mask, int k, int h, int w) {
  // h-1 bits
  vector<int> cuts;
  for (int i = 0; i < h - 1; ++i)
    if (mask & (1 << i))
      cuts.push_back(i);
  cuts.push_back(10);
  vector<int> pieces(cuts.size());
  int c(0);
  
  for (int j = 0; j < w; ++j) {
    int x(0);
    for (int i = 0; i < h; ++i)
      pieces[i == cuts[x] ? (x++) : x] += grid[i][j];
    
    bool test(true);
    for (int n = 0; n < pieces.size(); ++n) {
      if (pieces[n] > k) {
        c++;
        pieces.clear();
        pieces.resize(cuts.size());
        x = 0;
        
        for (int i = 0; i < h; ++i) {
          if (pieces[x] == k && grid[i][j]) return -1;
          pieces[i == cuts[x] ? (x++) : x] += grid[i][j];
        }
      }
    }
  }
  
  return c;
}
int main() {
    io();
    int h, w, k;
    cin >> h >> w >> k;
    string s[h];

    for(int i = 0; i < h; i++) {
        cin >> s[i];
        int sum = 0;
        for(int j = 0; j < w; j++) {
            sum += (s[i][j] == '1');
            f[i][j] = sum;
            grid[i][j] = (s[i][j] == '1');
        }

        
    }

    int h1 = h - 1;
    int ans = 1e9;
    for(int mask = 0; mask < (1 << h1); mask++) {
        int t = cuts(mask, k, h, w);
        ans = min(ans, t == -1 ? h + w - 2 : __builtin_popcount(mask) + t);

    }
    cout << ans;
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 2e5 + 10;
int F[N], G[N], A[N];

int64 comb(int n, int m) {
  if (n < m) return 0;
  return (int64)F[n] * G[m] % MOD * G[n - m] % MOD;
}

void init(int n) {
  A[1] = 1;
  for (int i = 2; i < n; ++i) {
    A[i] = (MOD - MOD / i) * (int64)A[MOD % i] % MOD;
  }
  F[0] = G[0] = 1;
  for (int i = 1; i < n; ++i) {
    F[i] = (int64)F[i - 1] * i % MOD;
    G[i] = (int64)G[i - 1] * A[i] % MOD;
  }
}

int main() {
  init(N);
  int H, W, n;
  scanf("%d%d", &H, &W);
  scanf("%d", &n);
  vector<ii> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    --a[i].first; --a[i].second;
  }
  sort(a.begin(), a.end());
  vector<int> dp(n);
  --H; --W;
  int ret = comb(H + W, H);
  for (int i = 0; i < n; ++i) {
    dp[i] = comb(a[i].first + a[i].second, a[i].first);
    for (int j = 0; j < i; ++j) {
      if (a[j].second > a[i].second) continue;
      int cur = comb(a[i].first - a[j].first + a[i].second -
                     a[j].second,a[i].first - a[j].first) * dp[j] % MOD;
      dp[i] = (dp[i] + MOD - cur) % MOD;
    }
    int cur = dp[i] * comb(H - a[i].first + W - a[i].second, H - a[i].first) % MOD;
    ret = (ret + MOD - cur) % MOD;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 2688
while True:
  a,b = map(int, input().split())

  if a == 0 & b == 0:
    break

  for i in range(a):
    for j in range(b):
      if i % 2 == 0:
        if j % 2 == 0:
          print("#", end = "")
        else:
          print(".", end = "")
      else:
        if j % 2 == 0:
          print(".", end = "")
        else:
          print("#", end = "")

    print()

  print()


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


int main() {
  int W,H,N;
  cin >> W>>H>>N;
  vector<int>x(N),y(N),a(N);
  int wmax=W;
  int wmin=0;
  int hmax=H;
  int hmin=0;
  rep(i,N){
    cin>>x.at(i)>>y.at(i)>>a.at(i);
    if(a.at(i)==1){
      wmin=max(wmin,x.at(i));
    }
    else if(a.at(i)==2){
      wmax=min(wmax,x.at(i));
    }
    else if(a.at(i)==3){
      hmin=max(hmin,y.at(i));
    }
    else if(a.at(i)==4){
      hmax=min(hmax,y.at(i));
    }
  }
  
 int ans=max(0,wmax-wmin)*max(0,hmax-hmin);
 cout<<ans<<endl;
  
}

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

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



using namespace std;

const ll MOD = 1e9 + 7;

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

    vector<bool> a(n+1, true);
    int prev = -1;
    rep(i, m) {
        int tmp;
        cin >> tmp;
        a[tmp] = false;
    }

    vector<int> dp(n+1, 0);
    dp[0] = 1;
    if (a[1]) dp[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (a[i - 1]) dp[i] += dp[i - 1];
        if (a[i - 2]) dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string s;cin>>s;
  int ans=0,cnt=0;
  rep(i,s.size()){
    if(s[i]=='R')cnt++;
    if(s[i]=='S')cnt=0;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static String S;
    static String T;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        S = sc.next();
        T = sc.next();
        System.out.println( solve() ? "Yes" : "No" );
    }


    static boolean solve() {
        if( S.equals(T) ) return true;

        int n = S.length();
        for (int i = 0; i < n; i++) {
            S = (S.substring(1) + S.charAt(0));
            if( S.equals(T) ) return true;
        }
        return false;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;
        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }
        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


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


const int MOD = 1000000007;

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

int n;
int arr[105];
int sum;

void Input() {

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

        cin >> arr[i];
    }
}

void Solve() {

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

        for(int j = i+1; j < n; j++) {

            sum += arr[i] * arr[j];
        }
    }

    cout << sum << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();
  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll a, b; cin >> a >> b;
	cout << a/__gcd(a, b)*b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  for(auto& xi: x){
    cin >> xi;
  }
  vector<int> origin;
  origin.reserve(n);
  copy(x.begin(), x.end(), back_inserter(origin));
  
  sort(x.begin(), x.end());
  int l = x[n/2-1];
  int r = x[n/2];
  for(int i = 0; i < n; ++i){
    int cur = origin[i];
    if(cur <= l){
      cout << r << endl;
    }else{
      cout << l << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int a[10]={0,0,1,2,0,1,2,0,1,2};

int main(void) {
    int i,j;
    string s;
    while(cin >> s, s!="#"){
        int ans = INF;
        int n = s.size();
        rep(x,2){//右足、左足
            int t = 0;
            int f = x;
            int p = f?5:-1;//0 or 1 or 2
            rep(i,n){
                if(f == 0){//右足
                    if(a[s[i]-'0'] < p)t++;
                    else f = 1 - f;
                }else{//左足
                    if(p < a[s[i]-'0'])t++;
                    else f = 1 - f;
                }
                p = a[s[i]-'0'];
            }
            ans = min(ans, t);
        }
        cout << ans << endl;
  }
}



Measured memory_bytes: 3148
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)



int main() {
	int n, i = 0,ans=1,m;
	cin >> n;
	vector <int>a(n),k(1000000,0);
	rep(i, n) {
		cin >> a.at(i);
	}
	m = a.at(0);
	if (ans >= n) {
		cout << -1 << endl;
		return 0;
	}
	if (m == 2) {
		cout << ans << endl;
		return 0;
	}
	while (1) {
		m = a.at(m - 1);
		ans++;
		
		if (ans>=n) {
			cout << -1 << endl;
			return 0;
		}
		if (m == 2) {
			cout << ans << endl;
			return 0;
		}
		
	}	
	return 0;
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        Arrays.sort(v);
        double v0 = v[0];
        for (int i = 1; i < n; i++) {
            v0 = (v0 + v[i]) / 2;
        }
        System.out.println(v0);
    }
}


Measured memory_bytes: 23636
#include <stdio.h>

int main() {
    long long a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    
    long long max = 0;
    
    max = a * c;
    
    if (a * d > max)
        max = a*d;
    if (b*c > max)
        max = b*c;
    if (b*d > max)
        max = b*d;
        
    printf("%lld\n", max);
    

    return 0;
}


Measured memory_bytes: 1736
import std.algorithm;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


void main() {
    auto input = readln.chomp.split.map!(to!long);
    auto r = input.front;
    input.popFront;
    auto D = input.front;
    input.popFront;
    auto x = input.front;
    input.popFront;

    iota(10).each!(_ => writeln(x = r * x - D));
}


Measured memory_bytes: 256
n = int(input())
dl = list(map(int, input().split()))
dl_s = sorted(dl)

abc = 0
arc = 0
count = 0
for i in range(n // 2):
    if dl_s[i] < dl_s[-(i+1)]:
        abc = dl_s[i]
        arc = dl_s[-(i+1)]
        count += 1

if count == n//2:
    print(arc - abc)
else:
    print(0)


Measured memory_bytes: 14428
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int N=20005;
const int M=10000005;

std:: vector <int> vec[2];

struct edge {int x,y,next;} e[N*2];

int link[N],vis[N],a[M];
int ls[N],p[M/10],edCnt;

bool np[M];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void add_edge(int x,int y) {
	e[++edCnt]=(edge) {x,y,ls[x]}; ls[x]=edCnt;
	e[++edCnt]=(edge) {y,x,ls[y]}; ls[y]=edCnt;
}

void pre(int n) {
	np[1]=1;
	rep(i,2,n) {
		if (!np[i]) p[++p[0]]=i;
		for (int j=1;i*p[j]<=n;++j) {
			np[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
}

int find(int x,int id) {
	for (int i=ls[x];i;i=e[i].next) {
		if (vis[e[i].y]==id) continue;
		vis[e[i].y]=id;
		if (!link[e[i].y]||find(link[e[i].y],id)) {
			link[e[i].y]=x;
			return 1;
		}
	}
	return 0;
}

int main(void) {
	int n=read(),mx=0;
	rep(i,1,n) {
		int x=read();
		a[x]=1;
		mx=std:: max(mx,x);
	}
	pre(mx+1);
	rep(i,1,mx+1) if (a[i]!=a[i-1]) {
		vec[i&1].push_back(i);
	}
	int ta=vec[0].size(),tb=vec[1].size();
	for (int i=0;i<ta;++i) {
		for (int j=0;j<tb;++j) {
			int d=abs(vec[0][i]-vec[1][j]);
			if (!np[d]&&(d&1)) {
				add_edge(i+1,j+1+ta);
			}
		}
	}
	int ans=0;
	rep(i,1,ta) ans+=find(i,i);
	ta-=ans,tb-=ans;
	ans+=(ta/2)*2+(tb/2)*2;
	if ((ta&1)||(tb&1)) ans+=3;
	printf("%d\n", ans);
	return 0;
}

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

int main(void){

  string str;
  cin >> str ;

  int i = 0;
  while(str[i] != '\0'){
    
    i ++ ;
    
  }

  cout << str[0] << i-2 << str[i-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
surfaceArea :: Double -> Double -> Double
surfaceArea x h = x^2 + 2*x* sqrt ((x/2)^2 + h^2 )

solve :: [Double] -> [Double]
solve [] = []
solve [_] = []
solve (0:0:_) = []
solve (x:y:r) = surfaceArea x y : solve r

main = getContents >>= mapM_ print . solve . map read . lines

Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
// #define mod 1000000007
#define ll long long int

vector<vector <ll>>v;
// vector<vector <ll>>dp;
ll dp[1005][10005] = {};
bool compare(vector<ll>&a,vector<ll>&b){
ll w1 = a[0],s1=a[1],w2=b[0],s2=b[1];
return w1+s1 > w2+s2;
}
void solve(){
ll n;cin>>n;
v.resize(n,vector<ll>(3));
// dp.resize(1001,vector<ll>(10001,0));
for(ll i=0;i<n;i++){
cin>>v[i][0]>>v[i][1]>>v[i][2];
}
sort(v.begin(),v.end(),compare);
    for(int j = 0; j <= 10000; j++)
    {
        if(v[0][1] >= j)
            dp[0][j] = v[0][2];
        else dp[0][j] = 0;
    }

for(int i = 1; i < n; i++)
{
    for(int j = 0; j <= 10000; j++)
    {
        ll op1 = dp[i-1][j];
        ll op2 = (v[i][1] >= j) ? (v[i][2] + ((j + v[i][0] > 10000)?0:dp[i-1][j+v[i][0]])) : 0;
        dp[i][j] = max(op1, op2);
    }
}
cout<< dp[n-1][0]<<endl;


}

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


Measured memory_bytes: 81812
import sys
from heapq import heappush,heappop

n,m = map(int,input().split())
ab = []
for line in sys.stdin:
    a,b = map(int,line.split())
    if a <= m:
        ab.append((a,b))
ab.sort()

stock = []
ans = 0
for i in range(1,m+1):
    while ab and ab[0][0] <= i:
        a,b = ab.pop(0)
        heappush(stock,-b)
    if stock:
        ans += -heappop(stock)

print(ans)

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    long long ans = 0;
    long long count = 0;
    for(int i = 0; i < n;i ++){
        if(s[i] == 'W'){
            ans += count;
        }else{
            count++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define re register int
using namespace std;
int n,m,d[15][15],f[110][110];
int main(){
	scanf("%d%d",&n,&m);
	for(re i=1;i<=n;i++)
	for(re j=1;j<=m;j++)scanf("%d",&d[i][j]);
	for(re i=0;i<=100;i++){
		for(re j=0;j<=100;j++){
			for(re k=1;k<=n;k++){
				for(re l=1;l<=m;l++){
					f[i][j]=max(f[i][j],d[k][l]-i*k-j*l);
				}
			}
		}
	}
	for(re i=1;i<=n;i++){
		for(re j=1;j<=m;j++){
			int now=0x3f3f3f;
			for(re k=0;k<=100;k++){
				for(re l=0;l<=100;l++){
					now=min(now,f[k][l]+i*k+j*l);
				}
			}
			if(now!=d[i][j]){
				printf("Impossible");
				return 0;
			}
		}
	}
	printf("Possible\n202 10401\n");
	for(int i=1;i<=100;i++)printf("%d %d X\n",i,i+1);
	for(int i=102;i<202;i++)printf("%d %d Y\n",i,i+1);
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			printf("%d %d %d\n",i+1,202-j,f[i][j]);
		}
	}
	printf("1 202");
	return 0;
}

Measured memory_bytes: 384
Sa = input()

Sb = input()

Sc = input()

turn = 0

d = {'a':0, 'b':1 , 'c':2}

while(1):
	if turn == 0:
		if len(Sa) == 0:
			print("A")
			break
		card = Sa[0]
		turn = d[card]
		Sa = Sa[1:]
		
	if turn == 1:
		if len(Sb) == 0:
			print("B")
			break
		card = Sb[0]
		turn = d[card]
		Sb = Sb[1:]
		
	if turn == 2:
		if len(Sc) == 0:
			print("C")
			break
		card = Sc[0]
		turn = d[card]
		Sc = Sc[1:]
		
	

Measured memory_bytes: 3064
N, M, C = map(int, input().split())
b = list(map(int, input().split()))
a = []
for i in range(N):
        a.append(list(map(int, input().split())))

cnt = 0
for i in range(N):
    s = 0
    for j in range(M):
        s += a[i][j] * b[j]

    s = s + C
    if s > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int K;
VI ans;


void dfs(int k, int x){
    ans.pb(x);
    if(k == 0) return;
    if(x%10 == 0) dfs(k-1, x*10), dfs(k-1, x*10+1);
    else if(x%10 == 9) dfs(k-1, x*10+8), dfs(k-1, x*10+9);
    else repe(y, -1, 1) dfs(k-1, x*10+x%10+y);
}


signed main(){
    cin >> K;

    repe(i, 1, 9) dfs(11, i);

    sort(ALL(ans));
    UNIQUE(ans);

    cout << ans[K-1] << endl;

    return 0;
}

Measured memory_bytes: 18792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e18
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> P;
const int mod = 1000000007;


signed main(){

    int n, m;
    cin >> n;
    vector<string> u(n);
    rep(i, n)cin >> u[i];
    bool now = false; // true -> open, false -> close
    cin >> m;
    rep(i, m){
        string s;
        cin >> s;
        bool f = true;
        rep(j, n)if(u[j] == s)f = false;
        if(f){
            cout << "Unknown " << s << endl;
            continue;
        }
        if(now){
            cout << "Closed by " << s << endl;
            now = false;
        }
        else{
            cout << "Opened by " << s << endl;
            now = true;
        }
    }
}


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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i,n){
        int p;
        cin >> p;
        if(p != i+1) cnt++;
    }
    if(cnt == 2 || cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;
vector<long long int> fac;
long long int mypow(long long int a, long long int b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	long long int res = mypow(a, b / 2);
	res = res * res % mod;
	if (b % 2 == 1) res = res * a % mod;
	return res;
}

long long int myc(long long int a, long long int b) {
	return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

int main() {
	long long int n, k;
	cin >> n >> k;
	fac.push_back(1);
	for (int i = 1; i <= n + 1; i++) {
		fac.push_back(fac.back() * i % mod);
	}
	for (int i = 1; i <= k; i++) {
		if (n - k - (i - 1) < 0) {
			cout << 0 << endl;
			continue;
		}
		cout << myc(k - 1, i - 1) * myc(n - k - (i - 1) + i, i) % mod << endl;
	}
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <map>
#include <vector>
#include <string.h>

#define N 200200
#define M 1000100
#define ll long long

typedef struct trie{
  int cnt[26]{};
  int nxt[26]{};
}trie;

std::vector<trie> tree;

int acnt[30];
int gc = 1;

int insert(std::vector<int> &astr){
  int akt = 0;  
  int anxt = 0;
  int res = 0;
  for(int i = 0;i<astr.size();i++){
    if(i == astr.size()-1)res = akt;
    int ac = astr[i];
    if(tree[akt].nxt[ac]){
      anxt = tree[akt].nxt[ac];
    }else{
      trie tmp;
      tree.push_back(tmp);
      tree[akt].nxt[ac] = gc;
      anxt = gc;
      gc++;
    };
    for(int j = 0;j<30;j++){
      if(acnt[j]){
        tree[akt].cnt[j]++;
      };  
    };
    acnt[ac]--;
    akt = anxt;
  };
  return res;
};

char str[M];

std::vector<int> nstr;
int lst[N];
std::vector<int> rr;

int main(void){
  int n;
  scanf("%d",&n);
  trie tt;
  tree.push_back(tt);
  for(int i = 0;i<n;i++){
    scanf("%s",str);  
    int m = strlen(str);
    nstr.clear();
    for(int j = 0;j<30;j++)acnt[j] = 0;
    for(int j = m-1;j>=0;j--){
      acnt[str[j] - 'a']++;
      nstr.push_back(str[j] - 'a');  
    };
    rr.push_back(insert(nstr));
    lst[i] = nstr[nstr.size()-1];
  };
  ll ans = 0;
  for(int i = 0;i<n;i++){
    int node = rr[i];  
    int ch = lst[i];
    ans += (tree[node].cnt[ch]-1);
  };
  printf("%lld\n",ans);
  return 0;
};



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

vector<int64_t> numbers(100, -1);

int64_t lucas_number(int n)
{
  if (numbers[n] != -1)
    return numbers[n];

  if (n == 0)
    return 2;

  if (n == 1)
    return 1;

  numbers[n] = lucas_number(n - 1) + lucas_number(n - 2);
  return numbers[n];
}

int main()
{
  int N;
  cin >> N;
  cout << lucas_number(N) << endl;
}


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

int main(void) {
    vector<int> minus;
    vector<int> plus;
    int n;
    scanf("%d\n",&n);
    for(int i=1;i<=n;i++) {
        int x;
        scanf("%d",&x);
        minus.push_back(i-x);
        plus.push_back(i+x);
    }
    sort(minus.begin(),minus.end());
    sort(plus.begin(),plus.end());
    long long ret=0;
    for(int i=0;i<plus.size();i++) {
        ret+=upper_bound(minus.begin(),minus.end(),plus[i])-lower_bound(minus.begin(),minus.end(),plus[i]);
    }
    printf("%lld",ret);
}

Measured memory_bytes: 5064
list = map(int,raw_input().split())
W = list[0] 
H = list[1] 
x = list[2]
y = list[3]
r = list[4]

if x-r < 0:
    print "No"
elif x + r > W:
    print "No"
elif y-r < 0:
    print "No"
elif y+r > H:
    print "No"
else:
    print "Yes"

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

using namespace std;

const int N = 1005;
const int MASK = 1 << 15;

int n, m, box[N];
long long cost[N], dp[N][MASK];

long long fun(int pos, int mask) {
  if (mask == (1 << n) - 1) {
    return 0;
  }
  if (pos == m) {
    return mask == (1 << n) - 1 ? 0 : 1e9;
  }
  long long &tmp = dp[pos][mask];
  if (tmp != -1) {
    return tmp;
  }
  tmp = 1e9;
  tmp = min(tmp, cost[pos] + fun(pos + 1, mask | box[pos]));
  tmp = min(tmp, fun(pos + 1, mask));
  return tmp;
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> cost[i] >> x;
    while (x--) {
      int y;
      cin >> y;
      box[i] |= (1 << (y - 1));
    }
  }
  memset(dp, -1, sizeof dp);
  long long ans = fun(0, 0);
  if (ans == 1e9) ans = -1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 257536
import math
N = int(input())
S = 0
S += N*(N+1)//2 #3つ同じ
for i in range(1,N+1): #(i,i,j),(j,j,i)なるペア(i != j)
    for j in range(1,N+1):
        if i != j:
            S += 3*math.gcd(i,j)
if N >= 3: #(i,j,k)
    for k in range(3,N+1):
        for j in range(2,k):
            for i in range(1,j):
                S += 6*math.gcd(math.gcd(i,j),k)
print(S)

Measured memory_bytes: 9220
Imports System
Imports System.Text.RegularExpressions

Module Program
    Sub Main(args As String())

        Dim sInputA As String() = Console.ReadLine().Split(" ")
        Dim sInputB As String() = Console.ReadLine().Split(" ")

        Dim resultA() As Integer = Array.ConvertAll(Of String, Integer)(sInputA, AddressOf Integer.Parse)
        Dim resultB() As Integer = Array.ConvertAll(Of String, Integer)(sInputB, AddressOf Integer.Parse)


        Array.Sort(resultB)

        Dim sum As Integer

        For i = 0 To resultA(1) - 1
            sum += resultB(i)
        Next

        Console.WriteLine(sum)

  
    End Sub
End Module


Measured memory_bytes: 27828
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n,s;
	cin>>n;
	rep(i,0,n){
		cin>>s;
		o("Case "<<i+1<<":");
		rep(j,0,10){
			s=s*s/100;
			s%=10000;
			printf("%d\n",s);
		}
	}
}

Measured memory_bytes: 1192
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const pos = (x, y) => {
    return { x : x, y : y};
};

const div = (p1, p2, n) => {
    if (n === 0) return [];
    const cos = Math.cos(Math.PI / 3.0);
    const sin = Math.sin(Math.PI / 3.0);

    const s = pos((2 * p1.x + p2.x) / 3, (2 * p1.y + p2.y) / 3);
    const t = pos((p1.x + 2 * p2.x) / 3, (p1.y + 2 * p2.y) / 3);
    const u = pos( (t.x - s.x) * cos - (t.y - s.y) * sin + s.x
                 , (t.x - s.x) * sin + (t.y - s.y) * cos + s.y
                 );
    
    return div(p1, s, n - 1)
               .concat(s)
               .concat(div(s, u, n - 1))
               .concat(u)
               .concat(div(u, t, n - 1))
               .concat(t)
               .concat(div(t, p2, n - 1));
};

const solve = (n) => {
    if (n === 0) return [pos(0.0, 0.0), pos(100.0, 0.0)];
    return [pos(0.0, 0.0), ...div(pos(0.0, 0.0), pos(100.0, 0.0), n), pos(100.0, 0.0)];
};
solve(parseInt(line[0]))
    .forEach(p => {
        console.log(p.x.toFixed(8), p.y.toFixed(8));
    });


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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<pair<ll,pair<ll,ll> > > rl;
    REP(i,n){
        string s;
        cin >> s;
        ll l=0LL,r=0LL;
        for(char c : s){
            if(c=='('){
                r++;
            }else{
                if(r>0LL){
                    r--;
                }else{
                    l++;
                }
            }
        }
        pair<ll,pair<ll,ll> > rli;
        if(l==0&&r==0){

        }else if(l==0LL){
            rli = make_pair(0,make_pair(l,r));
        }else if(r==0LL){
            rli = make_pair(4,make_pair(l,r));            
        }else if(r>=l){
            rli = make_pair(1,make_pair(l,r));
        }else{
            rli = make_pair(3,make_pair(-l,r));            
        }
        rl.pb(rli);
    }
    sort(ALL(rl));
    ll now = 0;
    if(rl[0].se.fi>0||rl.back().se.se>0){
        cout << "No" << endl;
        return 0;
    }
    ll nn = (ll)rl.size();
    REP(i,nn){
        ll l = rl[i].se.fi;
        ll r = rl[i].se.se;
        if(l<0) l = -l;
        now -= l;
        if(now<0){
            cout << "No" << endl;
            return 0;
        }
        now += r;
    }
    if(now==0){
        cout << "Yes" << endl;
    }else{ 
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 27772
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define pf printf
#define sc scanf
#define maxsize 200000
#define lb cout<<endl;
#define F first
#define S second
#define print(i) cout<<i<<endl
#define print1(i,j) cout<<i<<" "<<j<<endl
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll a[maxsize],b[maxsize],c[maxsize];
ll n;
ll dp[maxsize][3];



ll power(ll x, ll  y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y%2 == 0) 
        return power(x, y/2)*power(x, y/2); 
    else
        return x*power(x, y/2)*power(x, y/2); 
} 

int main()
{
	IOS
	
	/*#ifndef ONLINE_JUDGE   
	    freopen("in.txt", "r", stdin);
	    freopen("out.txt", "w", stdout);
	#endif*/

	cin>>n;

	rep(i,n)
	{
		cin>>a[i]>>b[i]>>c[i];
	}

	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];

	rep1(i,n-1)
	{
		dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);

	}

	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;




	/*#ifndef ONLINE_JUDGE
    	cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif*/

    return 0;
}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int[] a = new int[n];
		for(int i= 0; i<n; i++){
			a[i] = sc.nextInt();
		}
		int pos = -1;
		for(int i=0; i<n-1; i++){
			if(a[i] + a[i+1] >= l){
				System.out.println("Possible");
				pos = i;
				break;
			}
		}
		if(pos == -1){
			System.out.println("Impossible");
		}else{
			for(int i=0; i<pos; i++){
				System.out.println(i+1);
			}
			for(int i=n-2; i>pos; i--){
				System.out.println(i+1);
			}
			System.out.println(pos+1);
		}
	}

}


Measured memory_bytes: 52620
#include <iostream>
#include <string>
#define llint long long
#define inf 1e18

using namespace std;

string s;
bool flag[4];

int main(void)
{
	cin >> s;
	
	llint ans = 0, dir = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'R'){
			dir = (dir+1)%4;
			if(dir == 0){
				if(flag[1] && flag[2] && flag[3]) ans++;
			}
			else{
				flag[dir] = true;
			}
		}
		else{
			dir = (dir+3)%4;
		}
		if(dir == 0){
			flag[0] = flag[1] = flag[2] = flag[3] = false;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3216
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fast();
    int n,d;
    cin>>n>>d;
    cout<<ceil((double(n)/(2*d+1)));
	return 0;
}


Measured memory_bytes: 256
N=int(input())

num=N//3
ama=N%3

def con(x,y):
    a=1
    b=1
    if y==0:
        return 1
    else:
        for i in range(y):
           a*=x-i 
        for j in range(y):
            b*=y-j
        return a//b
if ama==0:
    ans=1
elif ama==1:
    ans=num
else:
    ans=num*(num-1)//2+num

#print(ans)

for i in range(1,num):
    M=num-i
    R=ama+i*3
    ans+=con(R+M-1,M-1)
    #print(ans,R+M-1,M-1)
    
    
print(ans%(10**9+7))

Measured memory_bytes: 9212
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

typedef struct test {
  i32 b, l, u;
} test;

i64 eval (i32 x, test t) {
  return x <= t.b ? (i64) x * t.l : (i64) t.b * t.l + (i64) (x - t.b) * t.u;
}

typedef struct node_full {
  i64 val;
  i32 index;
} node;

int cmp_node (const void *a, const void *b) {
  i64 d = ((node *)a)->val - ((node *)b)->val;
  return d == 0 ? 0 : d > 0 ? -1 : 1;
}

#define MAX(a, b) ((a) > (b) ? (a) : (b))

i64 calc (i64 m, test *t, node *p, i32 n, i32 x) {
  if (m < x) {
    i64 sum = 0;
    i64 max = 0;
    for (i32 i = 0; i < n; ++i) {
      sum -= (i64) t[i].b * t[i].l;
      max = MAX(max, eval (m, t[i]));
    }
    return sum + max;
  }
  static uint8_t *used = NULL;
  if (used == NULL) {
    used = (uint8_t *) calloc (n, sizeof (uint8_t));
  }
  i64 sum = 0;
  for (i32 i = 0; i < n; ++i) {
    sum -= (i64) t[i].b * t[i].l;
    used[i] = 0;
  }
  i64 buf = 0;
  i32 swap = 0;
  for (i32 i = 0; m >= x; ++i, m -= x) {
    buf += p[i].val;
    used[p[i].index] = 1;
    swap = i + 1;
  }
  i64 max = buf;
  for (i32 i = 0; i < n; ++i) {
    if (used[i]) {
      max = MAX(max, buf - eval (x, t[i]) + eval (m, t[i]) + eval (x, t[p[swap].index]));
    } else {
      max = MAX(max, buf + eval (m, t[i]));
    }
  }
  return max + sum;
}

void run (void) {
  i32 n, x;
  scanf ("%" SCNi32 "%" SCNi32, &n, &x);
  test *t = (test *) calloc (n, sizeof (test));
  node *p = (node *) calloc (n, sizeof (node));
  for (i32 i = 0; i < n; ++i) {
    i32 b, l, u;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &b, &l, &u);
    t[i] = (test) {b, l, u};
    p[i] = (node) {eval (x, t[i]), i};
  }
  qsort (p, n, sizeof (node), cmp_node);
  i64 left = -1;
  i64 right = (i64) x * n;
  while (right - left > 1) {
    i64 m = (left + right) / 2;
    if (calc (m, t, p, n, x) >= 0) {
      right = m;
    } else {
      left = m;
    }
  }
  printf ("%" PRIi64 "\n", right);
}

int main (void) {
  run();
  return 0;
}


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

using namespace std;
using ll = long long;

int dp[100000 + 1];

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

    set<int> a;
    for (int i = 0; i < M; ++i) {
        int t;
        cin >> t;
        a.insert(t);
    }

    dp[0] = 1;
    dp[1] = 1;

    for (int i = 2; i <= N; ++i) {
        if (a.count(i - 1) == 0) {
            dp[i] += dp[i - 1];
            dp[i] %= 1000000007;
        }
        if (a.count(i - 2) == 0) {
            dp[i] += dp[i - 2];
            dp[i] %= 1000000007;
        }
    }

    cout << dp[N] << endl;
    
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define MAX 105
#define INFTY INT_MAX

int n, G[MAX][MAX];

void dijkstra() {
    int d[MAX], color[MAX];
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = 0;
    }
    d[0] = 0;
    while (1) {
        int u = -1;
        int minv = INFTY;
        for (int i = 0; i < n; i++) {
            if (color[i] != 1 && d[i] < minv) {
                minv = d[i];
                u = i;
            }
        }
        if (minv == INFTY)
            break;
        color[u] = 1;
        for (int v = 0; v < n; v++) {
            if (color[v] != 1 && G[u][v] != INFTY) {
                if (d[u] + G[u][v] < d[v])
                    d[v] = d[u] + G[u][v];
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i << " " << d[i] << endl;
    }
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            G[i][j] = INFTY;
        }
    }
    int k, v, c;
    for (int i = 0; i < n; i++) {
        cin >> k >> k;
        while (k--) {
            cin >> v >> c;
            G[i][v] = c;
        }
    }
    dijkstra();
    return 0;
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 100000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main()
{
    int i, j, n, k, h[max], cnt=0, g[max];
    
    scanf("%d", &n);
    for (i=0; i<n; i++) {
        scanf("%d", &h[i]);
    }
    
    for (i=0; i<n; i++) {
        g[h[i]-1]=i+1;
    }
    
    for (i=0; i<n; i++) {
        printf("%d ", g[i]);
    }
    
    return 0;
}



Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cout << ", "; cetak(v...);}
 
#define debug(x...) cout << '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())


const int MOD = 1e9 + 7;

int add(int x, int y){
    int ret = x + y;
    if(ret >= MOD) ret -= MOD;
    return ret;
}
int sub(int x, int y){
    int ret = x - y;
    if(ret < 0) ret += MOD;
    return ret;
}
int mul(int x, int y){
    return (long long)x * y % MOD;
}


const int mx = 1e5 + 10;

void solve(){
    int n;
    cin >> n;
    vector<int> l(n), r(n);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        l[i] = a - b;
        r[i] = a + b;
    }
    vector<int> ve(n);
    iota(ALL(ve), 0);
    sort(ALL(ve), [&](int i, int j){
        return r[i] < r[j];
    });
    int sampai = -2e9;
    int ans = 0;
    for(int i : ve){
        if(sampai > l[i]) continue;
        sampai = r[i];
        ans += 1;
    }
    cout << ans << endl;
}

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


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

int main() {
  int n;
  cin >> n;
  int a[n];
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }

  double sum = 0.0;
  for ( int i = 0; i < n; i++ ) {
    sum += 1.0/a[i];
  }

  printf("%.14f\n", 1.0/sum);
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto S = cast(char[])readln.chomp;
  auto N = readln.chomp.to!int;

  void solve() {
    bool inverted = false;
    char[200000] head;
    char[200000] tail;
    int num_head;
    int num_tail;

    foreach(_; 0..N) {
      byte queryType; readf(" %d", &queryType);

      if (queryType == 1) {
        inverted ^= true;
        continue;
      }

      byte forHead;
      char toAppend;
      readf(" %d %c\n", &forHead, &toAppend);

      if ((forHead == 1) ^ inverted) {
          tail[num_tail++] = toAppend;
      } else {
          head[num_head++] = toAppend;
      }
    }

    if (inverted) {
      auto reversed_head = head[0..num_head];
      reversed_head.reverse();
      S.reverse();
      writeln( reversed_head ~ S ~ tail[0..num_tail]);
    } else {
      auto reversed_tail = tail[0..num_tail];
      reversed_tail.reverse();
      writeln(reversed_tail ~ S ~ head[0..num_head]);
    }
  }

  solve();
}


Measured memory_bytes: 1432
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
 
l = [[] for i in range(n+1)]
for a, b in ab:  
    l[a].append(b)
    l[b].append(a)

value = [0 for i in range(n+1)]
for p, x in px:
    value[p] += x

stack = [1]
flag = [False]*(n+1)
while stack:
    v = stack.pop()
    flag[v] = True
    for e in l[v]:
        if flag[e]:
            continue
        value[e] += value[v]
        stack.append(e)
        
print(*value[1:])


Measured memory_bytes: 125260
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = list(s())
T = list(s())
l1 = len(S)
l2 = len(T)
Flag =  0
for i in range(l1-l2+2):
    if S[i:i+l2] == T:
        Flag = 1
        break
if Flag == 1:
    for i in range(l1):
        if S[i] == '?':
            S[i] = 'a'
    print(''.join(S))
    exit()
for i in range(l1-l2,-1,-1):
    s = S[i:i+l2]
    Flag = 1
    for j in range(l2):
        if s[j] != T[j] and s[j] != '?':
            Flag = 0
            break
    if Flag:
        for j in range(i,i+l2):
            if S[j] == '?':
                S[j] = T[j-i]
        for i in range(l1):
            if S[i] == '?':
                S[i] = 'a'
        print(''.join(S))
        exit()
print('UNRESTORABLE')

Measured memory_bytes: 9948
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	if(n == 2) {
		if(s[0] == s[1]) printf("%d %d\n", 1, 2);
		else printf("%d %d\n", -1, -1);
		return 0;
	}
	rep(i, n-2) {
		char c1 = s[i];
		char c2 = s[i+1];
		char c3 = s[i+2];
		if (c1 == c2 || c2 == c3 || c3 == c1) {
			printf("%d %d\n", i+1, i+3);
			return 0;
		}
	}
	printf("%d %d\n", -1, -1);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#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;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}
int gcd(ll(a), ll(b)) {
	ll q = a;
	ll w = b;
	ll e = q;
	while (q % w != 0) {
		e = q % w;
		q = w;
		w = e;
	}
	return w;

}





int main() {
	ll r,D,x;
	cin >> r>>D>>x;
	rep(i, 10) {
		x = r * x - D;
		cout << x << endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	  #define endl "\n"
	  #define ll long long int
	  #define mod 1000000007
	  #define inf 1000000000000000001;
	  using namespace std;
	  int main()
	  {
	    //  #ifndef ONLINE_JUDGE
	    //  // for getting input from input.txt
	    //  freopen("input.txt", "r", stdin);
	    //  // for writing output to output.txt
	    //  freopen("output.txt", "w", stdout);
	    // #endif
	    std::ios::sync_with_stdio(false);
	    cin.tie(NULL);
	    char a;
	    cin>>a;
	    if(a >=65 && a <= 90){
	    	cout<<"A"<<endl;
	    }
	    else{
	    	cout<<"a"<<endl;
	    }
	    return 0;
	  }


Measured memory_bytes: 3636