akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
char s[10];
int  main(){
	long long n;
	cin>>n;
	long long ans=1LL*n/500*1000;
	n%=500;
	ans+=1LL*n/5*5;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    lint x, r, D;
    cin >> r >> D >> x;
    FOR(i, 0, 10) {
        x = r * x - D;
        cout << x << endl;
    }
    return 0;
};


Measured memory_bytes: 256
n = int(input())
ps = tuple(map(int, input().split()))
qs = tuple(map(int, input().split()))

import itertools
arr = []
for i in range(1,n+1):
    arr.append(i)

arr2 = list(itertools.permutations(arr))

nump = arr2.index(ps)
numq = arr2.index(qs)

print(max(nump, numq) - min(nump,numq))

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'

vector<int> adj[(int)300000];
vector<int> deg((int)300000);
vector<int> dp((int)300000);

int ans = 0;

int dfs(int u, int p) {

	if(dp[u] != 0)
		return dp[u];

	for(int v: adj[u]) {
		if(v == p)
			continue;

		dp[u] = max(dp[u], 1 + dfs(v, u));
	}

	return dp[u];
} 

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

  int n, m;

  cin >> n >> m;

  while(m--) {
  	int u, v;

  	cin >> u >> v;

  	adj[u].pb(v);
  	deg[v]++;
  }

  int ans = 0;
  for(int i = 1; i <= n; i++) {
  	if(deg[i] == 0) {
  		ans = max(ans, dfs(i, -1));
  	}
  }

  cout << ans << endl;
}

Measured memory_bytes: 21376
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	if nextInt()+nextInt() >= nextInt() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.*;

public class Main {
    static void answer(boolean ans){
        System.out.println(ans ? "Yes" : "No");
        System.exit(0);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] H = new long[N+1];
        for(int n=1; n<=N; n++) H[n]=sc.nextLong();

        for(int n=1; n<=N; n++){
            if(H[n-1] > H[n]) answer(false);
            if(H[n-1] < H[n]) H[n]--;
        }
        answer(true);
    }
}


Measured memory_bytes: 50196
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

void solve() {
    ll n, i, j, k, ans=0, arr[16], hon[16];
    fo(i,16)arr[i]=hon[i]=0;
    cin>>n;
    fo(i,n) {
        cin>>k;
        fo(j,k) {
            ll x, y;
            cin>>x>>y;
            x--;
            if(y==0)arr[i] = arr[i] | (1<<x);
            else hon[i] = hon[i] | (1<<x);
        }
    }
    Fo(i,1,1<<n) {
        ll x = 0;
        fo(j,n) {
            if((1<<j)&i) {
                x |= arr[j];
            }
        }
        if(i&x)continue;
        bool stat = true;
        fo(j,n) {
            if((1<<j)&i) {
                x = hon[j];
                if((x&i)==x)continue;
                stat = false;
                break;
            }
        }
        if(stat)ans = max(ans, (ll)__builtin_popcount(i));
    }
    cout<<ans;
}

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

Measured memory_bytes: 256
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        a: usize,
        b: usize
    }
    if (a + b) % 2 == 0 {
        println!("{}", (b - a) / 2);
    } else {
        println!("{}", min(a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2));
    }
}


Measured memory_bytes: 4352
<?php
// Your code here!
    $input = fgets(STDIN);//2
    $num = explode(" ",trim(fgets(STDIN)));//12 5
    $count = explode(" ",trim(fgets(STDIN)));//1000 2000
    
    $a = 10000;
    $b = 0;
    
    for($i=0; $i<=(int)($input)-(int)(1); $i++){
        $temp = $num[0] - $count[$i]*0.006;//温度を求めた
        $ondo = abs($num[1] - $temp);
        // var_dump($ondo);//1 5
        if($ondo < $a){
            $b = $i;
            $a = $ondo;
        }
    }
    echo $b+1;
    

Measured memory_bytes: 3956
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    x=II()
    inf=10**9
    st=int(x**0.5)-1
    for i in range(st,inf):
        if(i+1)*i//2>=x:
            print(i)
            break

main()

Measured memory_bytes: 3064
from fractions import gcd

def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    ans = 1 if g % 2 else 2
    while g % 2 == 0:
        g //= 2
    for i in range(3, int(g**0.5) + 1, 2):
        if g % i == 0:
            ans += 1
        while g % i == 0:
            g //= i
    return str(ans + 1) if g > 1 else str(ans)

if __name__ == '__main__':
    print(solve(input()))

Measured memory_bytes: 5304
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N; ll A[3005], DP[3005][3005];

ll Calc(int turn, int L, int R){
  if (DP[L][R] != 1e18) return DP[L][R];
  if (L == R){
    if (turn % 2 == 0) return DP[L][R] = A[L];
    else return DP[L][R] = -1 * A[L]; 
  }

  if (turn % 2 == 0){
    ll ans = max(A[L] + Calc(turn + 1, L + 1, R), A[R] + Calc(turn + 1, L, R - 1));
    return DP[L][R] = ans;
  }else{
    ll ans = min(-1 * A[L] + Calc(turn + 1, L + 1, R), -1 * A[R] + Calc(turn + 1, L, R - 1));
    return DP[L][R] = ans;
  }
}

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
  fill((ll*)DP, (ll*)(DP + N), 1e18);
  printf("%lld\n", Calc(0, 0, N - 1));
  return 0;
}


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

using namespace std;

int main() {
   string s, t;
   cin >> s >> t;
   s += t;
   int a = 0;
   for (int i = 0; s[i]; i++) {
    a = a * 10 + (s[i] - '0');
   }
   int b = sqrt(a);
   if (b * b == a)
        puts("Yes");
   else
        puts("No");
   return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.*;
//https://qiita.com/p_shiki37/items/3902f4e3adc3aeb382f1

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long K = Long.parseLong(sc.next());
        int Q = Integer.parseInt(sc.next());
        Long A[] = new Long[N];
        for (int i=0; i<N; i++) {
            A[i] = 0L;
        }
        for (int i=0; i<Q; i++) {
            int a = Integer.parseInt(sc.next()) - 1;
            A[a]++;
        }
        sc.close();

        PrintWriter out = new PrintWriter(System.out);
        for (int i=0; i<N; i++) {
            if (K + A[i] > Q) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
        out.flush();
    }
}

Measured memory_bytes: 47128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int a=0;
  cin >> N;
  vector<int> h(N);//height
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  if(N==1){
    cout << "Yes" << endl;
  }
  else{
    for(int i=0;i<N-1;i++){
      if(h.at(i) < h.at(i+1)){
        a=0;
        if(i==N-2){
          cout << "Yes" << endl;
        }
      }
      else if(h.at(i) == h.at(i+1)){
        if(i==N-2){
          cout << "Yes" << endl;
        }
      }
      else{
        if(a==1){
          cout << "No" << endl;
          break;
        }
        else{
          if(h.at(i)-1 == h.at(i+1)){
            if(i==N-2){
              cout << "Yes" << endl;
            }
            else{
              a=1;
            }
          }
          else{
            cout << "No" << endl;
            break;
          }
        } 
      }
    }
  }
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

int main(){
    ll N,K;
    cin >> N >> K;
    if(N <= K){
        cout << min(abs(N - K),N) << endl;
    }else{
        ll n = N % K;
        cout << min(abs(n - K),n) << endl;
    }
}


Measured memory_bytes: 256
x1, y1, x2, y2 = (int(v) for v in input().split())
xd, yd = x2-x1, y2-y1

xd, yd = -yd, xd
x3, y3 = x2+xd, y2+yd
xd, yd = -yd, xd
x4, y4 = x3+xd, y3+yd
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, T; cin >> N >> T;
  int x=1001, count=0;
  vector<int> c(N);
  vector<int> t(N);
  for (int i=0; i<N; i++) {
    cin >> c[i] >> t[i];
    if (t[i]<=T){
      x=min(x,c[i]);
      count++;
    }
  }
    if(count!=0)
      cout << x;
  else
    cout << "TLE";
}


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

const int INF = 1e9;

int n, dp[100005];
vector<int> A;

signed main(){
  
  cin>>n;
  
  A.push_back(1);

  for(int i=6;i<=n;i*=6) A.push_back(i);
  
  for(int i=9;i<=n;i*=9) A.push_back(i);

  for(int i=0;i<100005;i++) dp[i] = INF;
  
  dp[0] = 0;
  
  for(int i=0;i<30;i++){
    
    for(int j=0;j<100005;j++){
      
      if( j + A[i] >= 100005 ) continue;
      
      dp[j+A[i]] = min( dp[j+A[i]], dp[j] + 1 );
      
    }
    
  }
  
  cout<<dp[n]<<endl;
    
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll N;
ll A[200010];
bool B[2000010];

int main(){
   cin >> N;
   rep(i,N) cin >> A[i];
   sort(A,A+N);
   ll ans = 0;
   rep(i,N){
      if(!B[A[i]] && A[i+1] != A[i]) ans++;
      for(ll j = 1;j * A[i] <= A[N-1];j++){
         B[A[i] * j] = 1;
      }
   }
   cout << ans << endl;
}


Measured memory_bytes: 6156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF -1e16

#define nax 200005

void solve(){
	string s,t;
	cin>>s>>t;
	int cnt=0;
	rep(i,0,sz(s)){
		if(s[i]!=t[i])
			cnt++;
	}
	cout<<cnt<<endl;

}

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3760
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> P;
lli MOD = 1000000007;
lli sum(lli a)
{
    return a * (a + 1) / 2;
}

int main()
{
    lli n;
    cin >> n;
    lli up = n, low = 0;
    while (up - low > 1) {
        lli mid = (up + low) / 2;
        if (sum(mid) >= n) {
            up = mid;
        } else {
            low = mid;
        }
    }
    lli s = sum(up) - n;
    for (int i = 1; i <= up; i++) {
        if (i == s)
            continue;
        cout << i << endl;
    }
}


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

using namespace std;

using ll = long long;

struct Point {
    int x, y;
    Point(int _x, int _y) : x(_x), y(_y) {}
    Point() {}
    Point operator+(const Point &rhs) {
        return Point(this->x + rhs.x, this->y + rhs.y);
    }
    Point operator-(const Point &rhs) {
        return Point(this->x - rhs.x, this->y - rhs.y);
    }
};
inline Point Rotate90(const Point &p) {
    return Point(-p.y, p.x);
}

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

    vector<Point> p(4);
    for (int i = 0; i < 2; ++i)
        cin >> p[i].x >> p[i].y;

    for (int i = 2; i < 4; ++i)
        p[i] = Rotate90(p[i - 1] - p[i - 2]) + p[i - 1];

    for (int i = 2; i < 4; ++i)
        cout << p[i].x << ' ' << p[i].y << (i == 3 ? '\n' : ' ');

    return 0;
}


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

int main() {
  string s;
  cin>>s;
  long long int k;
  cin>>k;
  
  for(int i=0;i<s.size();i++){
    if(s.at(i)!='1'){
      if(i>0&&i>=k){
        cout<<"1"<<endl;
      }
      else{
        cout<<s.at(i)<<endl;
      }
      return 0;
    }
  }
    cout<<"1"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
typedef vector<long long> vec;
typedef vector<vec> mat;

long long n;
long long H, W, M;

//A*B
mat mul(mat &A, mat &B){
  mat C(A.size(), vec(B[0].size(), 0));
  REP(i, A.size())
    REP(k, B.size())
      REP(j, B[0].size())
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
  return C;
}

//A^n
mat pow(mat A, long long n){
  mat B(A.size(), vec(A.size()));
  REP(i, A.size())
    B[i][i] = 1;
  while(n > 0){
    if(n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}

void solve(long long a, long long b, long long c, vector<long long> &S){
  mat A(H, vec(W));
  FOR(i, 1, H) A[i][i - 1] = a;
  REP(i, H) A[i][i] = b;
  FOR(i, 1, H) A[i - 1][i] = c;
  A = pow(A, n);
  REP(i, S.size()){
    int tmp = 0;
    REP(j, W) tmp = (tmp + S[j] * A[i][j]) % M;
    if(i != 0) cout <<" ";
    cout <<tmp;
  }
  cout <<endl;
}

int main() {
  long long N, A, B, C, T;
  while(cin >>N >>M >>A >>B >>C >>T && N){
    vector<long long> S(N);
    REP(i, N) cin >>S[i];
    H = W = N;
    n = T;
    solve(A, B, C, S);
  }
  return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int a[20];
LL pow(LL a,LL b)
{
    LL ans=1;
    while(b>0)
    {
        if(b%2==1)
            ans=ans*a;
        a=a*a;
        b/=2;
    }
    return ans;
}
int slove(int n,int k)
{
    double ans=0;
    for(int i=1; i<=n; i++)

    {

        for(int j=0; 1; j++)
        {
            if(i*a[j]>=k)
            {
                double sum=n*a[j];
                double k=1.0;
                sum=k/sum;
                ans+=sum;
                break;
            }
        }
    }
    printf("%.10f\n",ans);
}
int main()
{
    for(int i=0; 1; i++)
    {
        a[i]=pow(2,i);
        if(a[i]>100000)
            break;
    }
    int n,k;
    while(scanf("%d%d",&n,&k)!=EOF)
    {
        slove(n,k);
    }
}


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

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

  int i = 0;
  while (i < s.size()) {
    if (s.at(i) == '1') {
      i++;
    }
    else break;
  }

  if (k-1 >= i) {
    cout << s.at(i) << endl;
  }
  else {
    cout << '1' << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        

        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int A = int.Parse(str[0]);
            int P = int.Parse(str[1]);

            int pie = 0;

            pie = (A * 3 + P) / 2;

            Console.WriteLine(pie);

        }
    }
}

Measured memory_bytes: 11092
/*
Written by Kabir Kanha Arora
@kabirkanha
 */

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        long K = scanner.nextLong();
        long[] arr_A = new long[N];
        long[] arr_B = new long[M];
        for (int i = 0; i < N; ++i) {
            arr_A[i] = scanner.nextLong();
        }
        for (int i = 0; i < M; ++i) {
            arr_B[i] = scanner.nextLong();
        }
        int cnt = 0;
        long sum = 0;
        for (int i = 0; i < N; ++i) {
            if (sum + arr_A[i] > K)
                break;
            sum += arr_A[i];
            cnt++;
        }
        int marker = cnt - 1;
        int j = 0;
        for (; j < M; ++j) {
            if (sum + arr_B[j] > K)
                break;
            sum += arr_B[j];
            cnt++;
        }
        int max = cnt;
        for (int i = marker; i >= 0; --i) {
            sum -= arr_A[i];
            --cnt;
            while (j < M && sum + arr_B[j] <= K) {
                sum += arr_B[j];
                ++j;
                ++cnt;
                max = Math.max(max, cnt);
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 62552
import Data.Char
import Data.List
import System.IO
import Control.Applicative
import Control.Monad
-- https://hoogle.haskell.org で関数検索

{- お客様の中でHaskellを書ける方はいらっしゃいますか？
    と、Haskellの例がなくて困っていたところを @tanakh さんに助けて頂きました。本当にありがとうございました。-}
main :: IO ()
main = do
    n <- read <$> getLine
    putStrLn (show $ (div n  2) + (mod n 2))
 
 
 
 
 
 
 
 
same3 [a,b,c]
    | a==b && b==c = True
    | otherwise         = False       
       
diff3 [a,b,c] 
    | a==b = False
    | b==c = False
    | c==a = False
    | otherwise = True

yesno cond x 
    | cond x      = putStrLn "Yes"
    | otherwise = putStrLn "No"
    
    
    
{-

(+) 3 $ (*) 4 4
-> 19
pure (+) <*> (Just 1) <*> ( Just 3)
-> Just 4

main = do 
    [a,b] <- getIntegerList 
    print $ (a*(a-1)+b*(b-1)) `div` 2
    -- / じゃなくて'div' ！！！！！

main = do
    s <- getLine    
    samecoffee s

samecoffee [x,y,a,b,c,d] 
    | a==b && c==d = do putStrLn "Yes"
    | otherwise         = do putStrLn "No"
samecoffee s = do putStrLn ""
         
putStrLn $ (show c) ++ " " ++ (show a) ++ " " ++ (show b)


main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- スペース区切り整数の入力
    [b, c] <- getIntegerList

    --[b, c] <- map read . words <$> getLine
    -- 文字列の入力
    s <- getLine
    -- 出力
    putStrLn $ show (a + b + c) ++ " " ++ s
-}

-- レイアウト規則

fac 0 = 1
fac n = n * fac (n-1)

-- FileName   : 164a
-- CreatedDate: 2020-04-26 20:56:13

--------------------------------------------  https://atcoder.jp/contests/abc164/submissions/12342628

getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine


base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]



















Measured memory_bytes: 508
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
map<ll, ll> mp;
ll ans;


int main() {
	scanf("%lld %lld", &N, &M);
	data[0] = 0;
	fi(i, 0, N, 1) {
		scanf("%lld", &arr[i]);
		data[i + 1] = data[i] + arr[i];
	}
	mp[0] = 1;
	fi(i, 1, N + 1, 1) {
		cerr << data[i] << " ";
	}
	fi(i, 1, N + 1, 1) {
		ans += mp[data[i] % M];
		mp[data[i] % M]++;
	}
	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vector<pair<ll, ll>> food(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        food[i] = make_pair(a, b);
    }
    sort(all(food));  // かかる時間について昇順ソートするとfood[k]を最後に食べるときfood[k+1]以降は食べないことがいえる

    vvl dp(n+1, vl(t));  // dp[i+1][j] : i番目(iは0-index)までの料理をかかる時間がj以下となるように食べたときの美味しさの合計の最大値
    rep(i, n) {
        rep(j, t) {
            if(j >= food[i].first) {
                dp[i+1][j] = max(dp[i][j], dp[i][j - food[i].first] + food[i].second);
            }
            else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    ll ans = 0;
    rep(k, n) {  // 最後に食べる料理をfood[k]とする
        chmax(ans, dp[k][t-1] + food[k].second);
    }

    out(ans);
    re0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++) cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long cnt = 0;

	for (auto e : b) {
		long long aBegin = lower_bound(a.begin(), a.end(), e) - a.begin();
		long long cBegin = c.end() - upper_bound(c.begin(), c.end(), e);
		cnt += aBegin * cBegin;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 1408
N = int(input())
A, B = map(int, input().split()) 
P = [int(n) for n in input().split()]

Q1 = len([n for n in P if n <= A])
Q2 = len([n for n in P if n > A and n <=B])
Q3 = len([n for n in P if n > B])

print(min(Q1,Q2,Q3))

Measured memory_bytes: 3064
import java.awt.geom.*;
import java.io.*;
import java.util.*;


public class Main {
	//2352 start
	
	int [] vx = {0,1,0,-1};
	int [] vy = {-1,0,1,0};
	int w,h;
	
	class State {
		int x,y,dir,step;

		public State(int x, int y, int dir, int step) {
			this.x = x;
			this.y = y;
			this.dir = dir;
			this.step = step;
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			h = sc.nextInt();
			w = sc.nextInt();
			long l = sc.nextLong();
			if((h|w|l) == 0) break;
			
			boolean [][] isNG = new boolean[h][w];
			int sx = -1, sy = -1, sd = -1;
			for(int i = 0; i < h; i++){
				String s = sc.next();
				for(int j = 0; j < w; j++){
					char c = s.charAt(j);
					if(c == '#'){
						isNG[i][j] = true;
					}
					
					if(Character.isLetter(c)){
						sx = j;
						sy = i;
						if(c == 'N'){
							sd = 0;
						}
						if(c == 'E') sd = 1;
						if(c == 'S') sd = 2;
						if(c == 'W') sd = 3;
						
					}
				}
			}
			LinkedList<State> open = new LinkedList<Main.State>();
			open.add(new State(sx, sy, sd, 0));
			int INF = 1 << 24;
			int [][][] close = new int[h][w][4];
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w;j++){
					Arrays.fill(close[i][j], INF);
				}
			}
			close[sy][sx][sd] = 0;
			ArrayList<State> steplist  = new ArrayList<Main.State>();
			steplist.add(new State(sx, sy, sd, 0));
			int c = 1 << 24;
			int offset = 0;
			while(! open.isEmpty()){
				State now = open.removeFirst();
				int xx=-1, yy=-1, nd = -1;
				for(int i = 0; i < 4; i++){
					xx = now.x + vx[(now.dir + i) % 4];
					yy = now.y + vy[(now.dir + i) % 4];
					if(! isOK(xx,yy)) continue;
					if(isNG[yy][xx]) continue;
					nd = (now.dir + i) % 4;
					break;
				}
				
				if(close[yy][xx][nd] != INF){
					c = now.step +1 - close[yy][xx][nd];
					l = l - close[yy][xx][nd];
					offset =  close[yy][xx][nd];
				}
				else if(now.step + 1 == l){
					steplist.add(new State(xx, yy, nd, now.step + 1));
				}
				else{
					open.add(new State(xx, yy, nd, now.step + 1));
					close[yy][xx][nd] = now.step + 1;
					steplist.add(new State(xx, yy, nd, now.step + 1));
				}
				
			}
			int rotate = (int) (l % c);
			State res = steplist.get(rotate + offset);
			int x = res.x + 1;
			int y = res.y + 1;
			char [] table = {'N','E','S','W'};
			char dir = table[res.dir];
			System.out.println(y + " " + x + " " + dir);
		}
	}

	private boolean isOK(int xx, int yy) {
		if(0 <= xx && xx < w && 0<= yy && yy < h){
			return true;
		}
		return false;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 14000
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	ll mod = 1e9+7;

	void solve(){
		

		ini(n);
		vi a(n);
		vi a1(n,0);
		int tmp  = 0;
		FOR(i,0,n){
			in(a[i]);
			tmp+=a[i];
		}
		a1[n-1] = a[n-1];
		for (ll i1 = n-2; i1 >=0; i1--)
		{
			a1[i1]+=a[i1];
			a1[i1]+=a1[i1+1];
		}
		
		int tmp1 = 0;
		FOR(i,0,n){
			tmp1+=(a1[i]-a[i])%mod*a[i];
			tmp1%=mod;
		}
		FOR(i,0,n){
			// out(a1[i]);
		}
		out(tmp1%mod);
		
			
			
			


				
		


		
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;
const int MAX_V = 523;//0000;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const ull BS1 = 10000019ULL;
const int INF = (1 << 29);

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

inline void fastScan(int &x){
    bool negative = false;
    register int c = getchar();
    x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-'){
        negative = true;
        c = getchar();
    }
    for(   ; (c > 47 && c < 58); c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(negative)
        x = -x;
}

int fx[] = {1,-1,0,0};
int fy[] = {0,0,-1,1};

int n, m;
int par[N];

struct Edge {
    int u, v, cost;
    Edge(){}
    Edge(int _u, int _v, int _cost){
        u = _u; v = _v; cost = _cost;
    }
}eg[N * 5];

struct Point {
    int x, y, pos;
}point[N];

bool x_as(Point A, Point B){
    if(A.x == B.x){
        return A.y < B.y;
    }
    return A.x < B.x;
}

bool y_as(Point A, Point B){
    if(A.y == B.y){
        return A.x < B.x;
    }
    return A.y < B.y;
}

bool cost_as(Edge A, Edge B){
    return A.cost < B.cost;
}

int _find(int r){
    if(par[r] == r) return r;
    return par[r] = _find(par[r]);
}

int main(){
    fastScan(n);
    for(int i = 1; i <= n; i++){
        fastScan(point[i].x);
        fastScan(point[i].y);
        point[i].pos = i;
    }
    sort(point + 1, point + n + 1, x_as);
    for(int i = 2; i <= n; i++){
        eg[++m] = Edge(point[i - 1].pos, point[i].pos, abs(point[i - 1].x - point[i].x));
        eg[++m] = Edge(point[i - 1].pos, point[i].pos, abs(point[i - 1].y - point[i].y));
    }
    sort(point + 1, point + n + 1, y_as);
    for(int i = 2; i <= n; i++){
        eg[++m] = Edge(point[i - 1].pos, point[i].pos, abs(point[i - 1].x - point[i].x));
        eg[++m] = Edge(point[i - 1].pos, point[i].pos, abs(point[i - 1].y - point[i].y));
    }
    for(int i = 1; i < N; i++){
        par[i] = i;
    }
    sort(eg + 1, eg + m + 1, cost_as);
    ll ans = 0;
    for(int i = 1; i <= m; i++){
        int U = _find(eg[i].u), V = _find(eg[i].v);
        if(U != V){
            ans += 1ll * eg[i].cost;
            par[U] = V;
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<ll> p(a), q(b), r(c);

	rep(i, a)
		cin >> p[i];
	rep(i, b)
		cin >> q[i];
	rep(i, c)
		cin >> r[i];

	sort(p.begin(), p.end(), greater<ll>());
	sort(q.begin(), q.end(), greater<ll>());
	sort(r.begin(), r.end(), greater<ll>());

	vector<ll> ans1(x);
	vector<ll> ans2(y);

	for (int i = 0; i < x; i++)
	{
		ans1[i] = p[i];
	}
	for (int i = 0; i < y; i++)
	{
		ans2[i] = q[i];
	}

	reverse(ans1.begin(), ans1.end());
	reverse(ans2.begin(), ans2.end());

	ll red = 0, bl = 0;



	for (int i = 0; i < c; i++)
	{
		if (ans1[min(red,x-1)] < ans2[min(bl,y-1)] && red<x)
		{
			if (ans1[red] < r[i])
			{
				ans1[red] = r[i];
				red++;
			}
		}
		else
		{
			if (ans2[min(bl,y-1)] < r[i] && bl<y)
			{
				ans2[bl] = r[i];
				bl++;
			}
		}
	}

	ll sum = 0;
	rep(i, x)
		sum += ans1[i];
	rep(i, y)
		sum += ans2[i];
	cout << sum << endl;
	return 0;
}

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

using namespace std;

typedef long long int64;

int64 get(int64 val)
{
  return (val * 3 + (val + 7) * 3 + (val + 14) * 3);
}

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

  int ret = 0;

  int sum = (N - 2) / 11;
  int height = (N - 2) % 11;

  for(int i = 0; i < 11; i++) {
    int sub = 0;
    for(int j = 1; j < 6; j++) {
      ret += (get(i * 7 + j + 1) % 11 == K) * sum;
    }

  }
  for(int i = 0; i < height; i++) {
    for(int j = 1; j < 6; j++) {
      ret += (get(i * 7 + j + 1) % 11 == K);
    }
  }

  cout << ret << endl;
}


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

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    int N, M, sum = 0;
    cin >> N >> M;
    //処理
    rep(i, M) {
        int a;
        cin >> a;
        sum += a;
        if (sum > N) {
            cout << "-1" << endl;
            return 0;
        }
    }
    //出力処理
    cout << N - sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
using namespace std;
int a[100010];

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=1;i<=k;i++)
        ans+=a[i];
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static final long MOD = 1_000_000_007;

	public static void main(String[] args) {
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		long[][] dp = new long[N][N];
		dp[0][0] = 1;
		for (int i = 0; i < N - 1; i++) {
			long sum = 0;
			if (S[i] == '<') {
				for (int j = 0; j <= i; j++) {
					sum += dp[i][j];
					if (sum >= MOD) sum -= MOD;
					dp[i + 1][j + 1] = sum;
				}
			} else {
				for (int j = i; j >= 0; j--) {
					sum += dp[i][j];
					if (sum >= MOD) sum -= MOD;
					dp[i + 1][j] = sum;
				}
			}
		}
		long ans = 0;
		for (int i = 0; i < N; i++) {
			ans += dp[N - 1][i];
		}
		System.out.println(ans % MOD);
	}
}

Measured memory_bytes: 129876
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n,m,l,d[305][305],ans[305][305];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>l;
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
            d[i][j]=l+1;
    }
    rep(i,0,m)
    {
        ll u,v,c;
        cin>>u>>v>>c;
        d[u][v]=min(d[u][v],c);
        d[v][u]=min(d[v][u],c);
    }
    rep(k,1,n+1)
    {
        rep(i,1,n+1)
        {
            rep(j,1,n+1)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
        }
    }
    rep(i,1,n+1)
    {
        rep(j,1,n+1)
        {
            if(d[i][j]<=l)
                ans[i][j]=0;
            else
                ans[i][j]=M;
        }
    }
    rep(k,1,n+1)
    {
        rep(i,1,n+1)
        {
            rep(j,1,n+1)
                ans[i][j]=min(ans[i][j],ans[i][k]+ans[k][j]+1);
        }
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll u,v;
        cin>>u>>v;
        if(ans[u][v]!=M)
            cout<<ans[u][v]<<"\n";
        else
            cout<<-1<<"\n";
    }
}


Measured memory_bytes: 2048
N = int(input())
S =  input()
ans = S.count("R") * S.count("G") * S.count("B")
for i in range(N-2):
    r = S[i]
    for j in range(i+1,N-1):
        g = S[j]
        if r == g:
            continue
        k = 2*j - i
        if k >= N:
            continue
        b = S[k]
        if r != b and g != b:
            ans -= 1
print(ans)

Measured memory_bytes: 9204
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    L = I()
    print(L ** 3 / 27)

if __name__ == '__main__':
    main()

Measured memory_bytes: 76576
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
typedef long long LL;
const int N=100005;
int h[N],ne[N<<1],to[N<<1],w[N<<1],col[N];
int n,m,tot,c1,c2,flag,js[5];LL ans;
void add(int x,int y,int z) {to[++tot]=y,ne[tot]=h[x],h[x]=tot,w[tot]=z;}
int dfs(int x,int cc) {
	col[x]=cc,++js[cc],++c1;
	for(RI i=h[x];i;i=ne[i]) {
		if(w[i]==1) ++c2;
		int nxt=(cc+w[i])%3==0?3:(cc+w[i])%3;
		if(!col[to[i]]) dfs(to[i],nxt);
		else if(col[to[i]]!=nxt) flag=1;
	}
}
int main()
{
	int x,y;
	n=read(),m=read();
	for(RI i=1;i<=m;++i) x=read(),y=read(),add(x,y,1),add(y,x,-1);
	for(RI i=1;i<=n;++i) {
		if(col[i]) continue;
		c1=c2=js[1]=js[2]=js[3]=flag=0;
		dfs(i,1);
		if(flag) ans+=1LL*c1*c1;
		else if(js[1]&&js[2]&&js[3])
			ans+=1LL*js[1]*js[2]+1LL*js[2]*js[3]+1LL*js[3]*js[1];
		else ans+=c2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll x=a[0],y=a[1];
    vector<ll> vx,vy;
    for(int i=1;i*i<=x;i++){
        if(x%i==0){
            vx.pb(i);
            vx.pb(x/i);
        }
    }
    for(int i=1;i*i<=y;i++){
        if(y%i==0){
            vy.pb(i);
            vy.pb(y/i);
        }
    }
    sort(be(vx));
    sort(be(vy));
    era(vx);
    era(vy);
    ll ans=0;
    bool maki;
    for(int i=0;i<vx.size();i++){
        maki=false;
        for(int j=0;j<n;j++){
            if(a[j]%vx[i]){
                if(maki){
                    break;
                }
                else{
                    maki=true;
                }
            }
            if(j==n-1){
                ans=max(ans,vx[i]);
            }
        }
    }
    for(int i=0;i<vy.size();i++){
        maki=false;
        for(int j=0;j<n;j++){
            if(a[j]%vy[i]){
                if(maki){
                    j=n;
                }
                else{
                    maki=true;
                }
            }
            if(j==n-1){
                ans=max(ans,vy[i]);
            }
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#define MAXN 500010
#define LL long long
using namespace std;

const long double eps=1e-8;

int n;
LL V,px[MAXN];
long double py[MAXN];
pair<LL,long double> Q[MAXN];
int head=1,tail=1;

long double getK(pair<LL,long double> t1,pair<LL,long double> t2){
	return (t2.second-t1.second)/(t2.first-t1.first);
}

void insert(LL x,long double y){
	pair<LL,long double> pt(x,y);
	while(tail-head>=1 && getK(pt,Q[tail])<getK(Q[tail],Q[tail-1])) Q[tail--];
	Q[++tail]=pt;
}

void cut(LL x){
	while(Q[head].first>x){
		pair<LL,long double> temp=Q[head++];
		if(Q[head].first<x){
			long double ty=Q[head].second+getK(Q[head],temp)*(x-Q[head].first);
			Q[--head]=make_pair(x,ty);
		}
	}
}

int main(){
#ifdef DEBUG
	freopen("F.in","r",stdin);
#endif
	scanf("%d%d",&n,&V);
	for(int i=1;i<=n;i++){
		double temp;
		scanf("%lf%d",&temp,px+i);
		py[i]=temp*px[i];
	}
	Q[1]=make_pair(0,0);
	for(int i=1;i<=n;i++){
		cut(Q[tail].first+V-px[i]);
		insert(Q[tail].first-px[i],Q[tail].second-py[i]);
		double ans=(Q[head].second-Q[tail].second)/V;
		printf("%.7lf\n",ans);
	}
}



Measured memory_bytes: 36352
import static java.util.Arrays.deepToString;

import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	Map<Long, Integer> memo = new HashMap<Long, Integer>();
	public void run() {
		int[][] init = new int[][] {{0,1,2,3},{4,5,6,7}};
		memo.put(h(init), 0);
		Queue<int[][]> q = new ArrayDeque<int[][]>();
		q.add(init);
		int[] dr = {0, 1, 0, -1};
		int[] dc = {1, 0, -1, 0};
		for (;!q.isEmpty();) {
			int[][] cur = q.poll();
			int cur_cost = memo.get(h(cur));
			for (int i = 0; i < 2; i++) for (int j = 0; j < 4; j++) {
				if (cur[i][j] == 0) {
					for (int k = 0; k < 4; k++) {
						int ni = i + dr[k];
						int nj = j + dc[k];
						if (0 <= ni && ni < 2 && 0 <= nj && nj < 4) {
							int[][] b = {cur[0].clone(),cur[1].clone(),};
							int t = b[i][j];
							b[i][j] = b[ni][nj];
							b[ni][nj] = t;
							
							long h = h(b);
							if (!memo.containsKey(h)) {
								memo.put(h, cur_cost + 1);
								q.add(b);
							}
						}
					}
				}
			}
		}
		
		for (;sc.hasNext();) {
			int[][] a = new int[2][4];
			for (int i = 0; i < 2; i++) for (int j = 0; j < 4; j++) a[i][j] = sc.nextInt();
			System.out.println(memo.get(h(a)));
		}
	}
	long h(int[][] a) {
		long h = 0;
		for (int i = 0; i < 2; i++) for (int j = 0; j < 4; j++) h = h * 8 + a[i][j];
		return h;
	}
	int[][] r(long h) {
		int[][] a = new int[2][4];
		for (int i = 1; i >= 0; i--) for (int j = 3; j >= 0; j--) {
			a[i][j] = (int)(h & 7);
			h >>= 3;
		}
		return a;
	}
	
}

Measured memory_bytes: 43856