akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int k = saori.saori_hayami();
		int x = saori.saori_hayami();
		if(500 * k >= x){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
const double eps = 1e-8;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}int n, m, Q, b,c,dd = 0, sx,sy,gx,gy; string s;
const int MOD = 1e9 + 7;
int main(void) {
    int n; string s; cin >> n >> s;
    map<pair<string, string>, int> mp;
    rep(i, (1 << n)) {
        string s2, s1;
        rep(j, n) {
            if (i & (1 << j)) s1 += s[j];
            else s2 += s[j];
        }reverse(ALL(s1)); reverse(ALL(s2));
        mp[{s2, s1}]++;
    }ll ans = 0;
    rep(i, (1 << n)) {
        string s1, s2;
        rep(j, n) {
            if (i & (1 << j)) s1 += s[j + n];
            else s2 += s[j + n];
        }
        ans += mp[{s1, s2}];
    }cout << ans << endl;
}

Measured memory_bytes: 60968
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}
#[allow(unused_imports)]
use std::io::{stdout, Write};
fn main() {
    let (n, m, x) = read_three::<i32>();
    let mut a: Vec<i32> = read_vec();
    let mut b = a.clone();
    let a:Vec<i32> = a.into_iter().filter(|s| *s > x).collect();
    let b:Vec<i32>  =b.into_iter().filter(|s| *s < x).collect();
    let ana = a.len();
    let anb = b.len();
    println!("{}", if ana < anb {ana} else {anb});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
map<string,int> myMap;
int main(){
    int n;
    int Max=0;
    string s;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        myMap[s]++;
        if(myMap[s]>Max)Max= myMap[s];
    }
    map<string,int>::iterator it;
    for(it=myMap.begin();it!=myMap.end();it++)
    {
        if(it->second == Max)cout<<it->first<<endl;
    }
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	cin >> S;

	ll tmp = 0;
	ll res = 0;
	REP(i, S.size()){
		if(S[i]=='W'){
			res += (i-tmp);
			tmp++;
		}
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int gcd(int a, int b);

int main(void){
        int i,j,k;
        int n,sum;

   // printf("%d\n",gcd(1,2));
        sum=0;
        scanf("%d",&n);
        for(i=1;i<=n;i++){
                for(j=1;j<=n;j++){
                        for(k=1;k<=n;k++){
                                sum += gcd(gcd(i,j),k);
                        }
                }
        }
        printf("%d\n", sum);
        return 0;
}

int gcd(int a, int b){
        while(a!=0 && b!=0){
                if(a<b){
                        b = b%a;
                } else {
                        a = a%b;
                }
        }
        return (a+b);
}


Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

    private static Node root = null;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for (int i = 0; i < n; i++) {
            String command = scanner.next();
            switch (command) {
                case "insert":
                    insert(scanner.nextInt());
                    break;
                case "print":
                    print();
                    break;
            }
        }
    }

    private static void insert(int id) {
        if (root == null) {
            root = new Node(id, null);
            return;
        }
        Node current = root;
        Node parent = null;
        while (current != null) {
            parent = current;
            if (id < current.id) {
                current = parent.left;
            } else  {
                current = parent.right;
            }
        }
        Node newNode = new Node(id, parent);
        if (id < parent.id) {
            parent.left = newNode;
        } else {
            parent.right = newNode;
        }
    }

    private static void print() {
        printInOrder(root);
        System.out.print("\n");
        printPreorder(root);
        System.out.print("\n");
    }

    private static void printPreorder(Node node) {
        if (node == null) return;
        System.out.print(" " + node.id);
        printPreorder(node.left);
        printPreorder(node.right);
    }

    private static void printInOrder(Node node) {
        if (node == null) return;
        printInOrder(node.left);
        System.out.print(" " + node.id);
        printInOrder(node.right);
    }

}

class Node {
    int id;
    Node parent;
    Node left = null;
    Node right = null;

    Node(int id, Node parent) {
        this.id = id;
        this.parent = parent;
    }
}



Measured memory_bytes: 212780
dic = dict(I=1, V=5, X=10, L=50, C=100, D=500, M=1000)
while True:
    try:
        nums = list(map(lambda x: dic[x], list(input())))
    except:
        break
    ans = 0
    for i in range(1, len(nums)):
        if nums[i - 1] >= nums[i]:
            ans += nums[i - 1]
        else:
            ans -= nums[i - 1]
    print(ans + nums[-1])

Measured memory_bytes: 7416
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W));
  vector<vector<int>> B(H, vector<int>(W));
  int max_diff = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> B[i][j];
      max_diff = max(max_diff, abs(B[i][j] - A[i][j]));
    }
  }
  max_diff *= (H + W);
  vector<vector<vector<bool>>> memo(H, vector<vector<bool>> (W, vector<bool>(max_diff + 1, false)));
  memo[0][0][abs(B[0][0] - A[0][0])] = true;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int diff = B[i][j] - A[i][j];
      for (int k = 0; k <= max_diff; k++) {
        
        if (i > 0) {
          if (k - diff <= max_diff) {
            memo[i][j][k] = (memo[i][j][k] | memo[i - 1][j][abs(k - diff)]);
          }
          if (k + diff <= max_diff)
            memo[i][j][k] = (memo[i][j][k] | memo[i - 1][j][abs(k + diff)]);
        }
        if (j > 0) {
          if (k - diff <= max_diff)
            memo[i][j][k] = (memo[i][j][k] | memo[i][j - 1][abs(k - diff)]);
          if (k + diff <= max_diff)
            memo[i][j][k] = (memo[i][j][k] | memo[i][j - 1][abs(k + diff)]);
        }
        if (i == H - 1 && j == W - 1 && memo[i][j][k]) {
          cout << k << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}

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

int main() {

  long long a, b, k;
  cin >> a >> b >> k;

  if(k <= a) {
    cout << a-k <<" " << b << endl;    
  }
  else if(a+b >= k) {

    cout << 0 << " " << a+b-k << endl;
  }
  else {
    cout << 0 << " " << 0 << endl;
  }
}

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

ll nC2(ll n) {
    return n * (n -1) / 2;
}



int main() {

    int N;
    ll total = 0;

    cin >> N;
    int a[N];
    
    rep(i,N) cin >> a[i];
    
    ll bucket [N+1] = {0};
    
    rep(i,N)  ++bucket[a[i]];
   
    rep(i,N+1) {
        total += bucket[i] * (bucket[i]-1) / 2;
    }

    rep(k,N) {
        ll delta = nC2(bucket[a[k]] - 1) - nC2(bucket[a[k]]);
        ll ans = total + delta;
        cout << ans << endl;
    }

}


Measured memory_bytes: 4864
N, Y = map(int, input().split())

out = '-1 -1 -1'
is_found = False


def price(t_thousand_num, f_thousand_num, thousand_num):
    return t_thousand_num * 10000 + f_thousand_num * 5000 + thousand_num * 1000


def sum_of_bills(t_thousand_num, f_thousand_num, thousand_num):
    return t_thousand_num + f_thousand_num + thousand_num


def is_over(t_thousand_num, f_thousand_num, thousand_num):
    return price(t_thousand_num, f_thousand_num, thousand_num) > Y or \
           sum_of_bills(t_thousand_num, f_thousand_num, thousand_num) > N


def is_match(t_thousand_num, f_thousand_num, thousand_num):
    return price(t_thousand_num, f_thousand_num, thousand_num) == Y and \
           sum_of_bills(t_thousand_num, f_thousand_num, thousand_num) == N


for t_thousand_num in range(N + 1):

    if is_over(t_thousand_num, 0, 0) or is_found:
        break
    elif is_match(t_thousand_num, 0, 0):
        out = '{} {} {}'.format(t_thousand_num, 0, 0)
        break

    for f_thousand_num in range(N + 1):
        thousand_num = N - f_thousand_num - t_thousand_num
        if is_over(t_thousand_num, f_thousand_num, thousand_num) or is_found or thousand_num < 0:
            break
        elif is_match(t_thousand_num, f_thousand_num, thousand_num):
            out = '{} {} {}'.format(t_thousand_num, f_thousand_num, thousand_num)
            is_found = True
            break

print(out)


Measured memory_bytes: 42476
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		String[] a = new String[h];
		for(int n = 0; n < h;n++) {
			a[n] = sc.next();
		}
		
		for(int n = 0; n < w+2; n++)System.out.print("#");
		System.out.println("");
		for(int n = 0; n < h; n++)System.out.println("#"+a[n]+"#");
		for(int n = 0; n < w+2; n++)System.out.print("#");
	}

}


Measured memory_bytes: 23764
#!/usr/bin/env python3
import sys
from fractions import gcd
from functools import reduce

def solve(N: int, X: int, x: "List[int]"):
    dif = []
    for i in range(N):
        dif.append(abs(x[i]-X))
    
    a = reduce(gcd,dif)
    print(a)
    
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 21588
package main

import (
	"fmt"
)

func main() {
	var X, A, B int
	var ans string
	fmt.Scan(&X, &A, &B)
	
	if -A+B <= 0 {
		ans = "delicious"
	} else if -A+B <= X {
		ans = "safe"
	} else {
		ans = "dangerous"
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	// your code goes here
	char s[4];
	int value=700;
	scanf("%s",s);
	for(int i=0;i<3;i++) {
		if(s[i]=='o') value+=100;
	}
	printf("%d\n",value);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;


int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k>=a){
        if(k>=a+b){
            if(k>=a+b+c){
                ans = a-c;
            }
            else ans =a-((k-a-b));
        }
        else ans = a;
    }
    else ans = k;



    cout << ans << endl;


}

Measured memory_bytes: 3652
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

int main(){
    ll K,N;
    cin>>N>>K;
    set<ll> st;
    for(ll i=0;i<K;i++){
        ll d;
        cin>>d;
        st.insert(d);
    }
    while(1){
        string n=to_string(N);
        bool f=true;
        for(auto c:n){
            if(st.count(c-'0')==1){
                f=false;
                break;
            }
        }
        if(f){
            break;
        }
        N++;
    }
    cout<<N<<endl;
    return 0;
}

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

int main()
{
    long long n,a,b;
    cin >> n >> a >> b;
    if(n > 1 && b >= a || n == 1&& a == b)
        cout << (n-2)*(b-a)+1 <<endl;
    else
        cout << "0" <<endl; 
}

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define enter '\n'
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << enter
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << enter
using std::make_pair;

template < typename T >
inline T read( )
{
 T x = 0;
 char ch = gc( );
 bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int N = 1001, mod = 1e9 + 7;
 int h, w, ch, cw, sh, sw, dx[ 4 ] = { 0, 0, 1, -1 }, dy[ 4 ] = { 1, -1, 0, 0 }, mx[ N ][ N ];
 bool ok[ N ][ N ];
 std::deque < pair < int, int > > Q;
 void Fakemain( )
 {
  IOS;
  cin >> h >> w >> ch >> cw >> sh >> sw;
  char c;
  For( i, 1, h ) For( j, 1, w )
   cin >> c,
   ok[ i ][ j ] = c == '.';
  if( !ok[ ch ][ cw ] )
  {
   cout << -1;
   return;
  }
  memset( mx, 63, sizeof mx );
  mx[ ch ][ cw ] = 0;
  Q.push_back( make_pair( ch, cw ) );
  while( !Q.empty( ) )
  {
   auto fr = Q.front( );
   Q.pop_front( );
   int x = fr.first, y = fr.second;
   For( i, 0, 3 )
   {
    int _x = x + dx[ i ], _y = y + dy[ i ];
    if( _x <= h && _x >= 1 && _y <= w && _y >= 1 && ok[ _x ][ _y ] && mx[ x ][ y ] < mx[ _x ][ _y ] )
    {
     mx[ _x ][ _y ] = mx[ x ][ y ];
     Q.push_front( make_pair( _x, _y ) );
    }
   }
   For( i, -2, 2 )
   {
    For( j, -2, 2 )
    {
     int _x = x + i, _y = y + j;
     if( _x <= h && _x >= 1 && _y <= w && _y >= 1 && ok[ _x ][ _y ] && mx[ x ][ y ] + 1 < mx[ _x ][ _y ] )
     {
      mx[ _x ][ _y ] = mx[ x ][ y ] + 1;
      Q.push_back( make_pair( _x, _y ) );
     }
    }
   }
  }
  cout << ( mx[ sh ][ sw ] == 0x3f3f3f3f ? -1 : mx[ sh ][ sw ] );
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

Measured memory_bytes: 8496
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int H1,M1,H2,M2,K;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H1>>M1>>H2>>M2>>K;
	M1+=H1*60;
	M2+=H2*60;
	cout<<M2-M1-K<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int N, M, X,res = 1e9;
int a[16][17];
int c[16];
void dfs(int book, int val, int flag, vector<int> cur)
{
	if (book > N)
		return;
	if (flag)
		for (int i = 1; i <= M; i++)
		{
			cur[i] += a[book][i];
		}
	bool curFlag = 0;
	for (int i = 1; i <= M; i++)
	{
		if (cur[i] < X)
		{
			curFlag = 1;
			break;
		}
	}
	if (!curFlag)
		res = min(val, res);
	dfs(book + 1, val + c[book+1], 1, cur);
	dfs(book + 1, val,0, cur);
}
int main() {
	cin >> N >> M >> X;
	for (int i = 1; i <= N; i++)
	{
		cin >> c[i];
		for (int j = 1; j <= M; j++)
		{
			cin >> a[i][j];
		}
	}
	vector<int> cur(17, 0);
	dfs(0,0,0,cur);
	if (res == 1e9)
	{
		cout << -1 << endl;
		return 0;
	}
	cout << res << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef pair<ld, ld> pld;

const int sigma = 26;
const int inf = 1e9;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	//ifstream cin("input.txt");
	//freopen("input.txt", "r", stdin);
	//ofstream cout("output.txt");

	string s;
	cin >> s;
	int n = sz(s);

	vector<vector<int> > occ(sigma);
	for (int i = 0; i < n; ++i) {
		occ[s[i] - 'a'].pb(i);
	}

	vector<int> dp(n + 1, inf);
	vector<char> first(n + 1);

	dp[n] = 1;
	first[n] = 0;

	for (int i = n - 1; i >= 0; --i) {
		for (int c = 0; c < sigma; ++c) {
			int p = lower_bound(all(occ[c]), i) - occ[c].begin();
			int len = 1;
			if (p == sz(occ[c])) {
				len = 1;
			} else {
				len = 1 + dp[occ[c][p] + 1];
			}
			if (len < dp[i]) {
				dp[i] = len;
				first[i] = c;
			}
		}
	}

	int i = 0;
	while (i <= n) {
		int c = first[i];
		cout << char(c + 'a');
		int p = lower_bound(all(occ[c]), i) - occ[c].begin();
		if (p == sz(occ[c])) {
			break;
		}
		i = occ[c][p] + 1;
	}
	cout << "\n";

}


Measured memory_bytes: 2452
n = gets.to_i
hash_xy = {}
n.times do |i|
  hash_xy[i + 1] = gets.split.map(&:to_i)
end

arrays = (1..n).to_a
distance = 0
arrays.permutation do |order|
key_first = order.first
  order.each do |key|
    if key == key_first
      $key_before = key.to_i
    else
      x = hash_xy[key][0] - hash_xy[$key_before][0]
      y = hash_xy[key][1] - hash_xy[$key_before][1]
      $key_before = key
      distance += Math.sqrt(x**2 + y**2)
    end
  end
end

def factorial(number)
  if number.zero?
    1
  else
    number * factorial(number - 1)
  end
end

p distance / factorial(n)

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in range(x, 0, -1):
        if M%i == 0:
            print(i)
            break

Measured memory_bytes: 3060
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#include<memory>
#define FOR(i,R) for(int i=0;i<R;i++)
#define ZERO(a) memset(a,0,sizeof(a))
using namespace std;
typedef pair<int,int> P;

const int INF=10000;

char maze[1024][1024];
int H,W,N;
int sx,sy;
int gx,gy;

int e[16][3];
int d[1024][1024];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int bfs(){
	queue<P> que;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)d[i][j]=INF;
	que.push(P(sx,sy));
	d[sx][sy]=0;
	
	while(que.size()){
		P p=que.front(); que.pop();
		if(p.first==gx&&p.second==gy)break;
		for(int i=0;i<4;i++){
			int nx=p.first+dx[i],ny=p.second+dy[i];
			if(0<=nx&&nx<H&&0<=ny&&ny<W&&maze[nx][ny]!='X'&&d[nx][ny]==INF){
				que.push(P(nx,ny));
				d[nx][ny]=d[p.first][p.second]+1;
			}
		}
	}
	return d[gx][gy];
}

int main(){
	int i,j,k=0,t=0;
	cin>>H>>W>>N;
	FOR(i,H)FOR(j,W){
		cin>>maze[i][j];
		if(maze[i][j]=='S'){
			sx=i;sy=j;
		}else if('0'<=maze[i][j]&&maze[i][j]<='9'){
			k=maze[i][j]-'0';
			e[k][0]=i;e[k][1]=j;
		}
	}
	
	FOR(i,N){
		if(i==0){
			gx=e[1][0];
			gy=e[1][1];
		}else{
			sx=e[i][0];
			sy=e[i][1];
			gx=e[i+1][0];
			gy=e[i+1][1];
		}
		t+=bfs();
	}
	cout<<t<<endl;
}

Measured memory_bytes: 6308
def gcd(a,b):
    if b==0: 
        return a
    return gcd(b,a%b)

a,b,k = map(int,input().split())
x = gcd(a,b)
list_num = []
for i in range(1,x+1):
    if x % i == 0:
        list_num.append(i)
list_num = sorted(list_num,reverse=True)
print(list_num[k-1])

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        x: i64,
        a: [i64; n],
    }

    let r = if x > a.iter().sum() {
        n - 1
    } else {
        let mut a = a;
        a.sort();
        a.iter()
            .scan(0, |s, b| {
                *s = *s + b;
                Some(*s)
            }).filter(|&s| s <= x)
            .count()
    };

    println!("{}", r);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    int cnt = 1, maxh;
    int n; cin >> n;
    vector<int> h(n); rep(i,n) cin >> h[i];

    maxh = h[0];

    for(int i = 1; i < n; i++){
        if(h[i] >= maxh){
            cnt++;
            maxh = h[i];
        }
    }

    put(cnt);
}

Measured memory_bytes: 256
S = input()
L = ['dream', 'dreamer', 'erase', 'eraser']
for i in range(len(L)):
    L[i] = L[i][::-1]
S = S[::-1]
T = ''
for s in S:
    T += s
    for i in L:
        if T == i:
            T = ''
if T == '':
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3188
#define _ 2<<17
struct T{int a,b;}A[_];long P[_],M=1e9+7,F[_],I[_]={1},X;i,j,k,t;c(a,b)struct T*a,*b;{t=a->a-b->a?:a->b-b->b;}p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}main(s){for(;++X<_;)I[X]=p(s=F[X]=X*s%M,M-2);for(k=A;~scanf("%d",k);k+=4)i++-1||gets(P);for(qsort(A,i/=2,8,c);j<i;P[j++]=X)for(X=f(s=A[k=j].a-=1,t=A[j].b-=1);k--;)X=t<A[k].b?X:(X-f(s-A[k].a,t-A[k].b)*P[k]%M+M)%M;printf("%d",X);}

Measured memory_bytes: 8444
#include<iostream>
using namespace std;
int main()
{
  int a;
  cin >> a;
  switch (a%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
      break;
  }
}

Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	scanf("%d %d",&a ,&b);
	
	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}
	
	return (0);
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)
#define db(a) cout << a<< endl;
int main(){
    long long H,W;
    cin >>H>>W;
    long long a = 1000000000;
    for (int i=0;i<2;i++){
        for (int j = W;j>0;j--){
            long long b = H/2;
            long long c = W-j;
            a= min(max({H*j,c*b,c*(H-b)})-min({H*j,c*b,c*(H-b)}),a);
            a= min(max({H*j,(c/2)*H,(W-j-(c/2))*H})-min({H*j,(c/2)*H,(W-j-(c/2))*H}),a);
        }
        swap(H,W);
    }
    cout <<a<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL a, b;

int main()
{
	in >> a >> b;
	out << (a*b % 2 ? "Odd" : "Even") << std::endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n,k=map(int,input().split())
    lst=sorted(list(map(int,input().split())))
    
    left=0
    right=lst[-1]
    while right-left>1:
        mid=(right+left)//2
        sm=0
        for x in lst:
            sm+=(x-1)//mid
        
        if sm<=k:
            right=mid
        else : left=mid
    print(right)

main()

Measured memory_bytes: 30912
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <string>
#include <cstring>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>
#include <tuple>

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int a, b ,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>

using namespace std;

static const int MAX = 100;

int bubbleSort(int A[], int N);
void output(int A[], int N);

int main() {

	int A[MAX], N;
	int ans;

	//input
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	ans = bubbleSort(A, N);
	cout << ans << endl;
	return 0;
}

int bubbleSort(int A[], int N) {
	int count = 0;
	int flag = 1;
	int tmp;
	while (flag) {
		flag = 0;
		for (int j = N - 1; j > 0; j--) {
			if (A[j] < A[j - 1]) {
				tmp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = tmp;
				count++;
				flag = 1;
			}
		}
	}
	output(A, N);
	return count;
}

void output(int A[], int N) {
	for (int i = 0; i < N - 1; i++)
	{
		cout << A[i] << " " << flush;
	}
	cout << A[N - 1] << endl;
}


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

int maxtime(int n) {
  n = (n + 9) / 10 * 10;
  return n;
}
int re(int n) {
  n = maxtime(n) - n;
  return n;
}

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int ans = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e)
    - max({re(a), re(b), re(c), re(d), re(e)});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int r,c,i,j,k;
  long matrix[101][101]={0};

  scanf("%d %d",&r,&c);

  for(i=0;i<r;i++){
    matrix[i][c]=0;
    for(j=0;j<c;j++){
      scanf("%ld",&matrix[i][j]);
      matrix[i][c]=matrix[i][c]+matrix[i][j];
      matrix[r][j]=matrix[r][j]+matrix[i][j];
      matrix[r][c]=matrix[r][c]+matrix[i][j];

    }
  }
/*
  for(j=0;j<=c;j++){
    matrix[r][c]=0;
    for(i=0;i<r;i++){
      matrix[r][j]=matrix[r][j]+matrix[i][j];
    }
  }
*/
  for(i=0;i<=r;i++){
    for(j=0;j<c;j++) printf("%ld ",matrix[i][j]);
    printf("%ld\n",matrix[i][c]);
  }


  return 0;
}

Measured memory_bytes: 2748
//Catchharsh
#include<bits/stdc++.h>
#define ll long long int 
#define ld long double
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define see(x) cout<<#x<<" = "<<x<<endl
const ll MOD = 1e9+7;
const ll INF = 1011111111;
const ll LLINF = 1000111000111000111LL;
const ld EPS = 1e-10;
const ld PI = 3.14159265358979323;
using namespace std;
ll power (ll base,ll exponent)
{
    ll ans=1;
    //base%=MOD;
    //exponent%=(MOD-1);
    while(exponent!=0)
    {
      if(exponent&1) ans=(1LL*ans*base);
      base=(1LL*base*base);
      exponent>>=1;
    }
    return ans;
}

int32_t main()
{   
     IOS;
     
     ll n,m,i,j,k;
     set<string> s;
     cin>>n;
     string x;
     for(i=0;i<n;i++)
     {
      cin>>x;
      s.insert(x);
     }
     cout<<(ll)s.size();
     
     cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';             
}

Measured memory_bytes: 19420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int ans = 1;
		//int x = n;


		while(k <= n) {
			n = n / k ;
			ans++;
		}

		System.out.println(ans);

		scanner.close();

	}

}


Measured memory_bytes: 35840
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,c,ans=0;
    cin>>n>>c;

    vector<vvi> rec(c+1);
    rep(i,n){
        lli s,t,c;
        cin>>s>>t>>c;
        if(rec[c].size()==0){
            vi  x={s,t};
            rec[c].push_back(x);
        }
        else{
            unsigned int si=rec[c].size();
            si--;
            if(rec[c][si][1]==s){
                rec[c][si][1]=t;
            }
            else{
                vi x={s,t};
                rec[c].push_back(x);
            }
        }
    }
        vi ttc(2200000,0);
    rep(j,c+1){
            vi tt(2200000,0);
            rep(k,rec[j].size()){
                tt[rec[j][k][0]*2-1]+=1;
                tt[rec[j][k][1]*2]-=1;
            }
        for(int i=1;i<2200000;i++){
        tt[i]+=tt[i-1];
    }
    rep(k,2200000){
        if(tt[k]>0)ttc[k]++;
    }
    rep(i,2200000){
        ans=max(ans,ttc[i]);
    }

    }

    out(ans);
}

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

long labs(long l){
  if(l<0)return -l;
  else return l;
}

int main(){
  int t1, t2;
  long a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  int t=t1+t2;
  long amb1, amb2;
  amb1=(a1-b1)*t1;
  amb2=(a2-b2)*t2;
  cerr << amb1 << ' ' << amb2 << endl;
  if(amb1+amb2==0){
    cout << "infinity";
    return 0;
  }
  if(amb1/labs(amb1)==(amb1+amb2)/labs(amb1+amb2)){
    cout << 0;
    return 0;
  }
  if((amb1+amb2)/labs(amb1+amb2)==1){
    amb1=-amb1;
    amb2=-amb2;
  }
  long n=amb2/(amb1+amb2)+1;
  cerr << n << endl;
  long ret = (n-1)*2-1;
  if(amb2%(amb1+amb2)==0)ret--;
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
<?php
  $s = trim(fgets(STDIN));
  $a[] = $s;
  $i=0;
  while(1){
    if($a[$i]%2==0){
      $cal = $a[$i]/2;
      if(in_array($cal,$a)){
        echo ($i+2)."\n";
        exit;
      }
      $a[] = $cal;
    }else{
      $cal = $a[$i]*3+1;
      if(in_array($cal,$a)){
        echo ($i+2)."\n";
        exit;
      }
      $a[] = $cal;
    }
    $i++;
  }

Measured memory_bytes: 4604
n, m = (int(i) for i in input().split())  
a = [[int(i) for i in input().split()] for i in range(n)] 
dic = {}
lis = []

a.sort()
ans = 0
for x in a:
  if x[1] >= m:
    ans += x[0] * m
    break
  else:
    ans += x[0] * x[1]
    m -= x[1]

print(ans)

Measured memory_bytes: 60504
#include<iostream>

using namespace std;

int main(){

	int n;
	int i;
	int x;

	cin >> n;
	for(i=3;i<=n;i++){
		x = i;
		if(x%3==0){
		cout << " " <<  i;
		}else{
			while(x != 0){
				if(x%10 == 3){
					cout << " " << i;
					break;
				}
				x/=10;
			}
		}
	}

	cout << endl;


	return 0;

}

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

int main(){
  int N;
  cin >> N;
  
  int amari,answer;
  amari = N%1000;
  if (amari == 0)
    answer = 0;
  else
    answer = 1000-amari;
  cout << answer << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long ll;

int K;

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int maxnum = 0;
    int currsum = 0;
    for (int i = 0; i < 3; i++) {
        int a; cin >> a;
        maxnum = max(maxnum,a);
        currsum += a;
    }
    currsum -= maxnum;
    cin >> K;
    currsum += maxnum * (1 << K);
    cout << currsum << '\n';



    return 0;
}


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

class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
using edges = vector<edge>;
using graph = vector<edges>;
void readgraph(graph &g, size_t E, bool D, bool C, bool Z){ // E:num_of_edges, D:directed, C:costed, Z:already 0-indexed
	for(size_t i=0; i<E; ++i){
		edge e(1, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		if(!Z){
			--e.from;
			--e.to;
		}
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
class tree{
public:
	Int n;
	Int root;
	graph g;
	vector<Int> parent;
	vector<vector<Int>> child;

	tree(Int _n) : n(_n) {root = -1; parent.resize(n, -1); child.resize(n);}
	tree(Int r, vector<Int> p) : n(p.size()), root(r), parent(p) {}
	tree(graph _g) : n(_g.size()), g(_g) {}

	void set_root(Int r){
		root = r;
		parent.resize(n, -1);
		parent[r] = r;
		child.resize(n, vector<Int>());
		queue<Int> q;
		q.push(r);
		while(!q.empty()){
			Int p = q.front(); q.pop();
			for(auto i:g[p]){
				Int t = i.to;
				if(parent[t] == -1){
					parent[t] = p;
					child[p].push_back(t);
					q.push(t);
				}
			}
		}
	}
	void find_children(Int r){
		root = r;
		child.resize(n, vector<Int>());
		for(int i=0; i<n; ++i)
			if(parent[i] != i)
				child[parent[i]].push_back(i);
	}
};
class graph_util{
public:
	static void rec_dfs(graph &g, tree &t, vector<Int> &ord, vector<Int> &low, Int &cnt, Int v, Int p){
		t.parent[v] = p;
		ord[v] = cnt;
		++cnt;
		low[v] = ord[v];
		for(auto i:g[v]){
			Int to = i.to;
			if(ord[to] == -1){
				rec_dfs(g, t, ord, low, cnt, to, v);
				low[v] = min(low[v], low[to]);
			}else if(p != to){
				low[v] = min(low[v], ord[to]);
			}
		}
	}
	static tree build_dfs_tree(graph &g, Int s, vector<Int> &ord, vector<Int> &low){
		tree t(g.size());
		ord.resize(g.size(), -1);
		low.resize(g.size(), g.size());
		Int cnt = 0;
		rec_dfs(g, t, ord, low, cnt, s, s);
		t.find_children(s);
		return t;
	}
	static vector<Int> find_articulation_point(tree &dfs_tree, vector<Int> &ord, vector<Int> &low){
		vector<Int> res;
		if((Int)dfs_tree.child[dfs_tree.root].size() > 1) res.push_back(dfs_tree.root);
		for(Int i=0; i<(Int)ord.size(); ++i){
			if(i == dfs_tree.root) continue;
			for(auto j:dfs_tree.child[i]){
				if(ord[i] <= low[j]){
					res.push_back(i);
					break;
				}
			}
		}
		return res;
	}
	static vector<pair<Int, Int>> find_bridge(tree &dfs_tree, vector<Int> &ord, vector<Int> &low){
		vector<pair<Int, Int>> res;
		for(Int i=0; i<(Int)ord.size(); ++i){
			if(i == dfs_tree.root) continue;
			Int p = dfs_tree.parent[i];
			if(ord[p] < low[i]) res.push_back(make_pair(p, i));
		}
		return res;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, m; cin >> n >> m;
	graph g(n);
	readgraph(g, m, false, false, false);
	vector<Int> ord, low;
	tree dfs_tree(graph_util::build_dfs_tree(g, 0, ord, low));
	vector<pair<Int, Int>> bridges(graph_util::find_bridge(dfs_tree, ord, low));
	cout << bridges.size() << "\n";
}

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

using namespace std;

typedef long long ll;
const ll modl = 1e9 + 7;

ll dp[10005][100][2];

ll solve(string& K, int D, int pos, int d, bool restr) {
	if (dp[pos][d][restr] != -1) return dp[pos][d][restr];
	ll ans = 0;
	int mx = (restr) ? K[pos] - '0' : 9;
	int l = K.length();
	if (pos == --l) {

		for (int i = 0; i <= mx; i++) {
			if (i % D == d)
				ans++;
		}
		return dp[pos][d][restr] = ans % modl;

	}

	for (int i = 0; i <= mx; i++) {
		ans = (( ans + solve(K, D, pos + 1, (D + d - i % D) % D, restr && (i == mx))) % modl);
	}

	return dp[pos][d][restr] = ans % modl;
}

int main() {

	memset(dp, -1, sizeof dp);

	string K;
	int D;

	cin >> K;
	cin >> D;


	cout << ((modl + solve(K, D, 0, 0, true) - 1) % modl);
	return 0;
}


Measured memory_bytes: 20392
#a-kenkenlace
n,a,b,c,d=map(int,input().split())
s=input()
s="X"+s+"X"
#i伴目からj番目までに置いて000となることがありうるかということを分析する関数
def judge1(a,b):
    flag=False
    counterx=0
    countero=0
    for i in range(a,b+1):
        if s[i]=="." and s[i-1]=="." and s[i+1]==".":
            flag=True
            break
    return flag
def judge2(a,b):
    flag=True
    for i in range(a-1,b-1):
        if s[i]=="#" and s[i+1]=="#":
            flag=False
            break
    return flag
if c<d:
    if judge2(a,c) and judge2(b,d):
        print("Yes")
    else:
        print("No")
elif d<c:
    if judge1(b,d) and judge2(a,c):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3644
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll>a(n);
    k = (n*(n-1))/2 -k+1;
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ok = (1LL<<60);// K ko yori sukunai
    ll ng = -(1LL<<60);//K ko yori ooi 
    while(ok-ng > 1){
        ll mid = (ok+ng)/2;
        ll cnt = 0;
        rep(i,n){
            if(a[i]==0){
                if(mid <=0){
                    cnt += n-1-i;
                }
            }else if(a[i]<0){
                ll c = mid/a[i];
                ll tt = c;
                for(int j=-1;j<=1;j++){
                    if((tt+j)*a[i]>=mid){
                        c = tt+j;
                    }
                }
                // c 以下
                cnt += upper_bound(a.begin()+i+1,a.end(),c)-(a.begin()+i)-1;
            }else{
                ll c = mid/a[i];
                ll tt = c;
                for(int j=-1;j<=1;j++){
                    if((tt+j)*a[i]>=mid){
                        c = tt+j;
                        break;
                    }
                }
                // c以上
                cnt += a.end() - lower_bound(a.begin()+i+1,a.end(),c);
            }
        }
        if(cnt >=k){
            ng = mid;
        }else{
            ok = mid;
        }
    }
    cout << ng << endl;
    return 0;
}

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

#define N 123456

bool prime[(N+1)*2];
int main(void) {
  prime[0] = prime[1] = true;
  for (int i = 2; i*i <= 2*N; i++) {
    if (!prime[i]) {
      for (int j = 2; i*j <= 2*N; j++) {
        prime[i*j] = true;
      }
    }
  }

  int n;
  while(cin >> n, n) {
    int ret = 0;
    for (int i = n+1; i <= 2*n; i++) {
      if (!prime[i])
        ret++;
    }
    cout << ret << endl;
  }

  return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = a + b, y = c + d;
  if (x == y)
    cout << "Balanced" << endl;
  else if (x < y)
    cout << "Right" << endl;
  else
    cout << "Left" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,p,q,r,i;
    while(scanf("%d%d",&a,&b)!=EOF){
        if(a<b){
            p=a;
            a=b;
            b=p;
        }
        p=a;
        q=b;
        r=(p%q);
        while(r!=0){
            p=q;
            q=r;
            r=(p%q);
        }
        printf("%d %d\n",q,(a/q)*b);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
string s;
/******* define variable end *******/
int solve() {
	cin >> s;
	ll count = 0;
	ll ans = 0;
	REP(i, 3){
		if(s.substr(i, 1) == "R"){
			count++;
		}else{
			count = 0;
		}
		if(count > ans){
			ans = count;
		}
	}
	cout << ans << endl;
	return 0;
}
int main() {
	// clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 3652