akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// macros
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
  cerr << ' ' << head;
  debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(nullptr);
      cout << fixed << setprecision(20);
    }
} iosetup;


int main() {
  double n;
  cin >> n;
  vector< pair<int,int> > vec(n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i].first >> vec[i].second;
  }
  long double sum = 0;
  sort(vec.begin(), vec.end());
  do {
    for (int i = 0; i < n - 1; ++i) {
      sum += sqrt(pow(vec[i].first - vec[i+1].first, 2) + pow(vec[i].second - vec[i+1].second, 2));
    }
  } while (next_permutation(vec.begin(), vec.end()));
  ll x = n;
  for (int j = 2; j < n; ++j) {
    x *= j;
  }
  cout << sum / x << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int A = sc.nextInt();
			int B = sc.nextInt();
			if (A == 0) break;
			int N = sc.nextInt();
			boolean[][] stop = new boolean[B + 1][A + 1];
			for (int i = 0; i < N; ++i) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				stop[y - 1][x - 1] = true;
			}
			int[][] dp = new int[B + 1][A + 1];
			dp[0][0] = 1;
			for (int i = 0; i < B; ++i) {
				for (int j = 0; j < A; ++j) {
					if (!stop[i + 1][j]) dp[i + 1][j] += dp[i][j];
					if (!stop[i][j + 1]) dp[i][j + 1] += dp[i][j];
				}
			}
			System.out.println(dp[B - 1][A - 1]);
		}
	}
}

Measured memory_bytes: 12000
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
a = 0
for i in range(N):
    b = 0
    for j in range(M):
        b = b + B[j]*A[i][j]
    if b > -C:
        a = a+1


print(a)

Measured memory_bytes: 3060
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int h, w, l;
		cin >> h >> w >> l;
		if (h == 0) return;
		map<tuple<int, int, int>, int> loops;
		vector<string> inputs;
		REP(i, h) {
			string s;
			cin >> s;
			inputs.push_back(s);
		}
		tuple<int, int, int> now;
		string s = "NESW";
		int dx[4] = { -1,0,1 ,0 };
		int dy[4] = { 0,1,0,-1 };
		REP(i,h) {
			REP(q, w) {
				REP(j, 4) {
					if (s[j] == inputs[i][q]) {
						now = make_tuple(i, q, j);
					}
				}
			}
		}
		int cnt = 0;
		while (cnt != l) {
			if (loops.find(now) != loops.end()) {
				int hoge = (l - cnt - 1) / (cnt - loops[now]);
				if(hoge > 0)
				cnt += hoge * (cnt - loops[now]);
			}
			loops[now] = cnt;
			while (true) {
				int x = get<0>(now) + dx[get<2>(now)];
				int y = get<1>(now) + dy[get<2>(now)];
				if (x >= 0 && x < h && y >= 0 && y < w) {
					if (inputs[x][y] != '#') {
						get<0>(now) = x;
						get<1>(now) = y;
						break;
					}
				}
				get<2>(now)++;
				get<2>(now) %= 4;
			}
			cnt++;
		}
		cout << get<0>(now) + 1 << " " << get<1>(now) + 1 << " " << s[get<2>(now)] << endl;
	}
}
#undef int

int main() {
	solve();
}


Measured memory_bytes: 3420
N=int(input())
a=list(map(int,input().split()))

cum=[0]
for i in range(N):
  cum.append(cum[-1]+a[i])
  
ans=10**20
for i in range(1,N):
  tmp = abs(cum[-1]-cum[i]-cum[i])
  ans = min(ans, tmp)
  
print(ans)

Measured memory_bytes: 30516
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
    int N;
    std::cin >> N;
    std::vector<std::vector<int>> A(N, std::vector<int>(2));
    for (int i=0; i<N; ++i){
        std::cin >> A.at(i).at(0);
        A.at(i).at(1) = i + 1;
    }

    std::sort(A.begin(), A.end());

    for (int i=0; i<N-1; ++i) {
        std::cout << A.at(i).at(1) << " ";
    }
    std::cout << A.at(N - 1).at(1) << std::endl;

    return 0;
}


Measured memory_bytes: 8680
n = gets.to_i
a = gets.split(" ").map(&:to_i)
b = gets.split(" ").map(&:to_i)
c = gets.split(" ").map(&:to_i)

last_d_num = -1
satis = 0
n.times do |n|
    d_num = a[n] - 1
    if a[n].to_i == last_d_num + 1
        cus = c[d_num-1].to_i
    else
        cus = 0
    end
    satis = satis + b[d_num].to_i + cus
    last_d_num = a[n].to_i
end

puts satis

Measured memory_bytes: 1788
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	string s1, s2;
	int i;
	cin >> s1 >> s2;

	if (s1.size() > s2.size()) {
		cout << "GREATER" << endl;
	}
	else if (s1.size() < s2.size()) {
		cout << "LESS" << endl;
	}	  
	else {
		for (i = 0; i < s1.size(); i++) {
				if (s1[i] - '0' > s2[i] - '0') {
					cout << "GREATER" << endl;
					break;
				}else if(s1[i]-'0' < s2[i]-'0'){
					cout << "LESS" << endl;
					break;
				}
		}
		if (i == s1.size())
			cout << "EQUAL" << endl;
	}
  
return	0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(b-a == c-b){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}

Measured memory_bytes: 3636
N = int(input())
dp = [0 for i in range(N+1)]
dp[1] = 1
roku = 0
kyu = 0
for i in range(2, N+1):
    if i == 6**(roku+1):
        roku += 1
    if i == 9**(kyu+1):
        kyu += 1
    kouho = [1]
    for j in range(roku):
        kouho.append(6**(j+1))
    for j in range(kyu):
        kouho.append(9**(j+1))
    size = len(kouho)

    small = 1000000
    for j in range(size):
        if dp[i - kouho[j]] + 1 < small:
            small = dp[i - kouho[j]] + 1
    dp[i] = small
print(str(dp[N]))

Measured memory_bytes: 3992
#!/usr/bin/env python3

class Combination():
    # コンストラクタ
    def __init__(self, N:int, P:int):
        self.N = N
        self.P = P

        # fact[i] = (i! mod P)
        self.fact = [1, 1]   
        # factinv[i] = ((i!)^(-1) mod P)
        self.factinv = [1, 1]
        # factinv 計算用
        self.inv = [0, 1] 

        for i in range(2, N+1):
            self.fact.append((self.fact[-1] * i) % P)
            self.inv.append((-self.inv[P % i] * (P // i)) % P)
            self.factinv.append((self.factinv[-1] * self.inv[-1]) % P)
    
    # nCk (mod P)   (ただし、n<=N)
    def getComb(self, n:int, k:int):
        if (k < 0) or (n < k):
            return 0
        k = min(k, n - k)
        return self.fact[n] * self.factinv[k] % self.P * self.factinv[n-k] % self.P

n,k = map(int,input().split())
MOD = 10**9 +7

COMB = Combination(n,MOD)

ans = 0
for i in range(min(n, k+1)):
    ans += COMB.getComb(n,i) * COMB.getComb(n-1,i)
    ans %= MOD

print(ans)

Measured memory_bytes: 26896
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int A, B;
string S;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>A>>B>>S;
    int mode = 0;
    REP(i,0,S.size()){
        if(mode == 0){
            if((!isdigit(S[i]) && i < A) || A < i){
                cout<<"No"<<endl;
                return 0;
            }
            if(S[i] == '-' && i == A){
                mode = 1;
            }
        }else if(mode == 1){
            if(!isdigit(S[i])){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int n;
  int map[200];
  map['A'] = 1;
  map['2'] = 2;
  map['3'] = 3;
  map['4'] = 4;
  map['5'] = 5;
  map['6'] = 6;
  map['7'] = 7;
  map['8'] = 8;
  map['9'] = 9;
  map['T'] = 10;
  map['J'] = 10;
  map['Q'] = 10;
  map['K'] = 10;

  cin>>n;
  while( n --> 0){
    int sum = 0;
    bool ace = false;
    bool ele = false;
    bool dec = true;
    int d[8];
    for(int i=0; i<2; i++){
      char tmp; cin>>tmp;
      int c = map[tmp];
      if(c == 1) ace = true;
      sum += c;
    }
    for(int i=0; i<8; i++){
      char tmp; cin>>tmp;
      d[i] = map[tmp];
    }
    if(ace && sum + 10 <= 21){
      ele = true;
      sum += 10;
    }
    int idx = 0;
    while( sum <= 16 || (ele && sum == 17) ){
      int c = d[idx++];
      dec = false;
      if(!ace && c == 1)
        ace = true;
      sum += c;
      if(ace && !ele && sum + 10 <= 21){
        ele = true;
        sum += 10;
      }
      if(sum > 21 && ele){
        ele = false;
        sum -= 10;
      }
    }
    if(sum > 21) puts("bust");
    else if(dec && sum == 21) puts("blackjack");
    else printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int n, m;
string s[111];
int d[111][111];

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i] = "*"+s[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			d[i][j] = 1e9;
			if (i == 1 && j == i) d[i][j] = 0;
			if (i > 1) {
				d[i][j] = min(d[i][j],d[i-1][j]+(s[i-1][j]!=s[i][j] && s[i-1][j]=='#'));
			}
			if (j > 1) {
				d[i][j] = min(d[i][j],d[i][j-1]+(s[i][j-1]!=s[i][j] && s[i][j-1]=='#'));
			}
		}
	}
	int r = d[n][m];
	if (s[n][m] == '#') r++;
	cout << r << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
int main(){
    cin>>n;
    if(n==2){
        cout<<1<<endl;
        return 0;
    }
    ll ans=2;
    ll q=n-1;
    for(ll i=2;i<=sqrt(q);i++){
        if(q%i==0){
            if(i*i!=q)ans+=2;
            else ans+=1;
        }
    }
    for(ll i=2;i<=sqrt(n);i++){
        ll t=n;
        if(t%i!=0)continue;
        while(t%i==0){
            t/=i;
        }
        if(t%i==1)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
import java.util.*;
import java.math.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int d = sc.nextInt();
		int range = 2*d + 1;
		int amari=0;
		if(n%range !=0){
			amari = 1;
		}


			System.out.println(n/range + amari);

	}



}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int64_t> divisor(int64_t n) {
    vector<int64_t> result;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if (i * i != n) result.push_back(n / i);
        }
    }
    sort(result.begin(), result.end());
    return result;
}


int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> data = divisor(n);

    int64_t length = data[0] + data[data.size() - 1] - 2;
    int64_t loop = data.size() % 2 == 0 ?
            data.size() / 2 : data.size() / 2 + 1;
    for (int i = 1; i < loop; i++) {
        length = min(length, (data[i] + data[data.size()-i-1] - 2));
    }
    cout << length << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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


ll cake[1010][3];
ll a[8][1010];
int main() {
	int N, M;
	cin >> N >> M;
	REP(i, N)REP(j, 3)cin >> cake[i][j];
	int cnt = 0;
	REP(j, 2) {
		REP(k, 2) {
			REP(l, 2) {
				REP(i, N) {
					a[cnt][i] = cake[i][0] * pow(-1, j) + cake[i][1] * pow(-1, k) + cake[i][2] * pow(-1, l);
				}
				cnt++;
			}
		}
	}
	ll ans = 0;

	REP(i, 8) {
		ll c = 0;
		SORT(a[i], N);
		REVERSE(a[i], N);
		REP(j, M) {
			c += a[i][j];
		}
		if(c > ans)ans = c;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var a int
	fmt.Scan(&a)
	var b int
	fmt.Scan(&b)
	var c int
	fmt.Scan(&c)
	var x int
	fmt.Scan(&x)
	count := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


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

int main () {
    string S;
    cin >> S;
    if (S == "SUN"){
        cout << 7 << endl;
    }
    if (S == "MON"){
        cout << 6 << endl;
    }
    if (S == "TUE"){
        cout << 5 << endl;
    }
    if (S == "WED"){
        cout << 4 << endl;
    }
    if (S == "THU"){
        cout << 3 << endl;
    }
    if (S == "FRI"){
        cout << 2 << endl;
    }
    if (S == "SAT"){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, char[] ss, char[] ts) {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < n; i++) {
      sb.append(ss[i]);
      sb.append(ts[i]);
    }
    return sb.toString();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    char[] ss = reader.nextCharArray();
    char[] ts = reader.nextCharArray();
    out.println(solve(n, ss, ts));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 20692
def solve():
    D = input()
    N = len(D)
    *DI, = map(int, D)
    su = sum(DI)
    pd = 1
    for d in D:
        pd *= int(d) + 1
    memo = [{} for i in range(N)]
    def dfs0(i, s, p):
        key = (s, p)
        if i == N:
            return s > 0 or (s == 0 and p < pd)
        if key in memo[i]:
            return memo[i][key]
        r = 0
        for v in range(min(s, 9)+1):
            r += dfs0(i+1, s-v, p*(v+1))
        memo[i][key] = r
        return r
    res1 = dfs0(0, su, 1)
    memo1 = [{} for i in range(N)]
    def dfs1(i, s, p, m):
        key = (s, p, m)
        if i == N:
            return s == 0 and p == 1
        if key in memo1[i]:
            return memo1[i][key]
        r = 0
        b = s - (N-1-i)*9
        di = DI[i]
        for v in range(max(b, 0), min(s, 9)+1):
            if p % (v+1):
                continue
            if m == 0:
                if di < v:
                    break
                r += dfs1(i+1, s-v, p//(v+1), +(v < di))
            else:
                r += dfs1(i+1, s-v, p//(v+1), 1)
        memo1[i][key] = r
        return r
    res2 = dfs1(0, su, pd, 0) - 1
    ans = res1 + res2
    print(ans)
solve()


Measured memory_bytes: 64752
def main():
    N, L = map(int, input().split())
    a = [L + n for n in range(N)]
    if L > 0:
        print(sum(a) - a[0])
    elif abs(L) >= N:
        print(sum(a) - a[-1])
    else:
        print(sum(a))


main()


Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n, tmp, result int
	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)

		var count int = 0
		for tmp%2 == 0 {
			tmp /= 2
			count++
		}

		if i == 0 || count < result {
			result = count
		}
	}

	fmt.Print(result)
}


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

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

    int ans = 1e8;
    rep(i, N){
        int c, t; cin >> c >> t;
        if(t <= T) ans = min(ans, c);
    }

    if(ans == 1e8){
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

const int MAX_N = 2010;
const ll MOD = 1000000007;

ll gt[MAX_N], rev[MAX_N];

ll mult(ll a, ll b){ 
   if(b==0) return 1;
   if(b==1) return a % MOD;
   ll g = mult(a, b/2); 
   if(b%2) return g * g % MOD * a % MOD;
   return g * g % MOD;
}

ll C(ll n, ll k){ 
   if(k>n || k<0) return 0;
   return gt[n] * rev[n-k] % MOD * rev[k] % MOD;
}

void init(int n){ 
   gt[0] = 1;
   rev[0] = mult(gt[0], MOD-2);
   for(int i=1; i<=n; ++i){
      gt[i] = gt[i-1] * i % MOD;
      rev[i] = mult(gt[i], MOD-2);
   }   
}

int main(){
   ll N, K;
   std::cin >> N >> K;

   init(N);

   ll ans;
   for(int i=1; i<=K; ++i){
      ans = C(K-1,i-1) * C(N-K+1,i) % MOD; 
      std::cout << ans << std::endl;
   }
   
   return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long a, b, x, s1, s2, ans;
int main()
{
    cin >> a >> b >> x;
    s1 = b / x + 1;
    s2 = a / x + 1;
    ans = s1 - s2;
    if(a % x == 0){
        cout << ans + 1;
    }else{
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
k=str(n)
K=list(k)
count=True
for i in range(len(K)):
    if i==0:
        if K[i]!='1':
            break
    else:
        if K[i]!='0':
            break
    if i==len(K)-1:
        count=False
    #print(i)
#print(K)
for j in range(len(K)):
    K[j]=int(K[j])
if count==True:
    print(sum(K))
else:
    print(10)

Measured memory_bytes: 3064
n = int(input())

list753 = ["3","5","7"]

def dfs(s):
    if int(s) > n: #nを超えたら戻る
        return 0
    ret = 1 if all(s.count(c) > 0 for c in list753) else 0 #sの中に3,5,7の全てが存在するならretに1を、そうでないなら0を
    for c in list753: #sの末尾に3,5,7を加えてdfs
        ret += dfs(s+c)
    return ret #最後のループではretを関数外に返す。それ以外では、ret += のところに返す。
print(dfs("0"))


Measured memory_bytes: 53468
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def cnt(x):
    ans = 0
    i = 1
    while True:
        ans += i
        if ans > x:
            return i-1
        i += 1
        
n = int(input())
ans = 0

a = Counter(prime_factorize(n))
for i in a.values():
    ans += cnt(i)

print(ans)

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

def solve():
    import sys
    sys.setrecursionlimit(2*10**6)

    N, Q = map(int, sys.stdin.readline().split())

    tree = [[] for _ in range(N)]  # 木構造
    for _ in range(N-1):
        a, b = map(int, sys.stdin.readline().split())
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)

    anss = [0 for _ in range(N)]
    for _ in range(Q):
        p, x = map(int, sys.stdin.readline().split())
        anss[p-1] += x

    def dfs(a, p):
        """
        a:対象番号
        p:親番号
        """
        for b in tree[a]:
            if b == p: continue
            anss[b] += anss[a]
            dfs(b, a)

    dfs(0, -1)

    print(*anss)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 268404
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
 
*/
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>

 
using namespace std;
 
 
 
#define ll long long
#define ld double
#define null NULL
#define prev prev228
#define index index228
#define left left228
#define right right228
#define hash hash228
#define y1 y1228
#define firn(i, n) for (int i = 0; i < (int)n; ++i)
#define forn(i, n) for (int i = 1; i <= (int)n; ++i)
#define int long long


template<typename T> inline void uin(T &a, T b) {
    if (b < a) a = b;
}

template<typename T> inline void uax(T &a, T b) {
    if (b > a) a = b;
}


const int maxn = 100 * 1000 + 228;


int x[maxn], v[maxn], pref[maxn], suff[maxn], d1[maxn], d2[maxn];



signed main() {
	ios_base::sync_with_stdio(false);
	int n, c;
	cin >> n >> c;
	forn(i, n) {
		cin >> x[i] >> v[i];
		d1[i] = x[i];
		d2[i] = c - x[i];
	}
	int res = 0;
	int bal = 0;
	for (int i = n; i > 0; --i) {
		bal += v[i];
		suff[i] = max(suff[i + 1], bal - d2[i]);
	}
	forn(i, n) {
		pref[i] = pref[i - 1] + v[i];
	}
	
	for (int p = 0; p <= n; ++p) {
		int cur = pref[p] - d1[p];
		uax(res, cur);
		cur -= d1[p];
		cur += suff[p + 1];
		uax(res, cur);
	}
	bal = 0;
	forn(i, n) {
		bal += v[i];
		pref[i] = max(pref[i - 1], bal - d1[i]);
	}
	for (int i = n; i > 0; --i) {
		suff[i] = suff[i + 1] + v[i];
	}
	for (int s = 0; s <= n; ++s) {
		int cur = suff[n - s + 1] - d2[n - s + 1];
		uax(res, cur);
		cur -= d2[n - s + 1];
		cur += pref[n - s];
		uax(res, cur);
	}
	cout << res << '\n';
	return 0;
}






// kek



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

int main(){
    ll h, w;
    cin >> h >> w;
    ll s = h * w;
    if (h == 1 || w == 1){
        cout << 1 << endl;
    }
    else if (s % 2 == 0) {
        cout << s / 2 << endl;
    }
    else {
        cout << s / 2 + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect
import heapq

N = int(input())
A = [int(input()) for _ in range(N)]
q = []
A.reverse()

for i in range(N):
  ii = bisect(q,A[i])
  if ii == len(q):
    heapq.heappush(q,A[i])
  else:
    q[ii] = A[i]
    
print(len(q))

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

#define INF (1 << 29)

int N, M, R;
int d[201][201];
int r[9];
int A, B, C;
int res;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> R;
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= N; j++){
            if(i != j) d[i][j] = INF;
        }
    }
    for(int i = 1; i <= R; i++){
        cin >> r[i];
    }
    for(int i = 1; i <= M; i++){
        cin >> A >> B >> C;
        if(d[A][B] > C) d[A][B] = d[B][A] = C;
    }
    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                if(d[i][j] > d[i][k]+d[k][j])
                    d[i][j] = d[i][k]+d[k][j];
            }
        }
    }
    res = INF;
    vector<int> v(R);
    for(int i = 0; i < R; i++) v[i] = i + 1;
    do {
        int dist = 0;
        for(int i = 0; i < R-1; i++){
            dist += d[r[v[i]]][r[v[i+1]]];
        }
        res = min(res, dist);
    } while(next_permutation(v.begin(), v.end()));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = S()
    if n[-1] in ["2", "4", "5", "7", "9"]:
        print("hon")
    elif n[-1] in ["3"]:
        print("bon")
    else:
        print("pon")
    return


#main
if __name__ == '__main__':
    solve()


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

int main(void) {
	long long N, A, B;
	scanf("%lld %lld %lld", &N, &A, &B);
	long long set = N / (A + B);
	long long r = N % (A + B);
	printf("%lld", A * set + min(A, r));

	return 0;
}


Measured memory_bytes: 3792
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
A.sort()
ans = 0
a = 0
b = 0
if (N+1)//2==N//2:
    for i in range(N//2):
        ans -= 2*A[i]
    ans += A[N//2-1]

    for i in range(N//2,N):
        ans += 2*A[i]
    ans -= A[N//2]

    print(ans)

else:
    for i in range((N-1)//2):
        a -= 2*A[i]
    
    for i in range((N-1)//2,N):
        a += 2*A[i]
    
    a -= A[(N-1)//2]
    a -= A[(N-1)//2+1]

    for i in range((N-1)//2+1):
        b -= 2*A[i]
    
    for i in range((N-1)//2+1,N):
        b += 2*A[i]

    b += A[(N-1)//2]+A[(N-1)//2-1]
    print(max(a,b))

Measured memory_bytes: 7500
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int map[15];
void init()
{
    map[1]=1;
    map[3]=1;
    map[5]=1;
    map[7]=1;
    map[8]=1;
    map[10]=1;
    map[12]=1;
    map[4]=2;
    map[6]=2;
    map[9]=2;
    map[11]=2;
    map[2]=3;
}
int main()
{
    init();
    int x,y;
    scanf("%d%d",&x,&y);
    if(map[x]==map[y])
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;


int main()
{
	int n,a,b,k;
	cin >> n >> a >> b;
	for (int i = 0;i < n;i++)
	{
		cin >> k;
		for (int i = 1;i <= a;i += k)
			b++;
	}
	cout << b;
	return 0;
}

Measured memory_bytes: 256
//Number 1153

#include <stdio.h>
#define MAX 100

int main(void)
{
  int n, m, i, j, sum1, sum2, out1, out2, min;
  int taro[MAX] = {0};
  int hanako[MAX] = {0};

  while(1)
    {
      scanf("%d %d", &n, &m);
      if(n==0&&m==0)
	break;

      sum1 = 0;
      sum2 = 0;
      
      for(i=0; i<n; i++)
	{
	  scanf("%d", &taro[i]);
	  sum1 += taro[i];
	}
      
      for(i=0; i<m; i++)
	{
	  scanf("%d", &hanako[i]);
	  sum2 += hanako[i];
	}

      out1 = -1;
      out2 = -1;
      min = 200;
      for(i=0; i<n; i++)
	{
	  for(j=0; j<m; j++)
	    {
	      if(sum1-taro[i]+hanako[j]==sum2+taro[i]-hanako[j])
		{
		  if(min>=taro[i]+hanako[j])
		    {
		      out1 = taro[i];
		      out2 = hanako[j];
		      min = out1 + out2;
		    }
		}
	    }
	}
      
      if(out1==-1&&out2==-1)
	printf("-1\n");
      else
	printf("%d %d\n", out1, out2);
      
    }
  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void solve(int N) {
    int M;
    map<char, char> v;
    REP(i, N) {
        char a, b;
        cin >> a >> b;
        v[a] = b;
    }
    cin >> M;
    char s[M];
    REP(i, M) cin >> s[i];
    REP(i, M) {
        if(v.find(s[i]) != v.end()) s[i] = v[s[i]];
    }
    REP(i,M) cout << s[i];
    cout << endl;
}

int main() {
    int N;
    while(cin >> N, N) solve(N);
    return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; long long x; cin >> n >> x;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    x -= v[i];
    if (x < 0) {
      cout << i << endl;
      return 0;
    }
  }
  if (x == 0) {
    cout << n << endl;
  } else cout << n-1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt(), q = sc.nextInt();
        int[] p = new int[n];

        for(int i = 0; i < q; i++) {
        	p[sc.nextInt()-1]++;
        }

        for(int i = 0; i < n; i++) {
        	if(k - (q-p[i]) > 0) {
        		System.out.println("Yes");
        	}else {
        		System.out.println("No");
        	}
        }

        return;
    }

}

Measured memory_bytes: 72048
//master
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] a = new int[n-1];
        int[] b = new int[n];
        for(int i = 0; i<n-1; i++) a[i] = sc.nextInt()-1;
        for(int i = 0; i<n-1; i++) b[a[i]]++;
        for(int i = 0; i<n; i++) p(b[i]);
    }
    public static <T> void p(T message) {
        System.out.println(message);
    }

    public static <T> void pe(T message) {
        System.err.println(message);
    }

    public static <T> void pp(T message) {
        System.out.print(message);
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 57612
package main

import "fmt"

func main() {
	var s string

	fmt.Scan(&s)

	s0 := string([]rune(s)[0])

	cnt := 0

	if s0 == "0" {

		for pos, c := range s {
			if pos == 0 {
				continue
			}

			if pos%2 == 0 {
				if string([]rune{c}) == "1" {
					cnt++
				}
			} else {
				if string([]rune{c}) == "0" {
					cnt++
				}
			}
		}

	} else if s0 == "1" {

		for pos, c := range s {
			if pos == 0 {
				continue
			}

			if pos%2 == 0 {
				if string([]rune{c}) == "0" {
					cnt++
				}
			} else {
				if string([]rune{c}) == "1" {
					cnt++
				}
			}
		}

	}

	fmt.Print(cnt)

}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#include <algorithm>
#define INF 1111111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;
vector<int> vec(100100);
vector<int> passed(100100);
vector<int> dx = {-1,1};
int n,k;

int main() {
  int k;
  cin >> k;
  
  int a = k/2;
  int b = k-a;
  
  cout << a*b << endl;
  
  
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  cin>>N>>H;
  if(N==H)printyes;
  else printno;
  return 0;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

vector<int> cost(1e4, 1e9);

int main() {
    int n, m;
    cin >> n >> m;
    cost[0] = 0;
    rp(i, 0, m) {
        int a, b;
        scanf("%d%d", &a, &b);
        int key = 0;
        rp(i, 0, b) {
            int c; scanf("%d", &c);
            c--;
            key += (1<<c);
        }
        rp(j, 0, (1<<n)) {
            chmin(cost[j|key], a+cost[j]);
        } 
    }
    int res = cost[(1<<n) - 1];
    if(res == 1e9) cout << -1 << endl;
    else cout << cost[(1<<n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 3796
import java.util.*;
 

public class Main {
    public static void main(String[] args) {   
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if((a*b)%2==0){
        System.out.println("Even");
    }else {
        System.out.println("Odd");
    } 
		
    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,d,ok,e,f,g;
int gcd(long long a,long long b){
	 if(a==0){
	 	 return b;
	 }
	 return gcd(b%a,a);
}
int main (){
ios::sync_with_stdio(0);
//cin.tie(0); cout.tie(0);
scanf("%lld %lld",&a,&b);
f=a;
g=b;
e=gcd(a,b);
ok=(f/e)*g;
printf("%lld",ok);
return 0;
}


Measured memory_bytes: 256
// Comment
// two pointer

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

int N, Nr[MAX_N];
int Cnt[20];
int main() {
	cin >> N;
	for(int i=1; i<=N; i++) scanf("%d", &Nr[i]);
	int two = 0;
	ll ans = 0;
	for(int l=1, r=1; r<=N; r++) {
		for(int k=0; k<20; k++) if(Nr[r] & (1<<k)) {
			Cnt[k]++;
			if(Cnt[k] == 2) two++;
		}
		while(two > 0) {
			for(int k=0; k<20; k++) if(Nr[l] & (1<<k)) {
				Cnt[k]--;
				if(Cnt[k] == 1) two--;
			}
			l++;
		}
		ans += r - l + 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4604
H, W, K = map(int, input().split())
C = [input() for i in range(H)]

ans = 0
cnt = 0

for i in range(2 ** H):
    for j in range(2 ** W):
        cnt = 0
        for k in range(H):
            for l in range(W):
                if ((i >> k) & 1) and ((j >> l) & 1):
                    if C[k][l] == '#':
                        cnt += 1
                
        if cnt == K:
            ans += 1

print(ans)


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

int main(void) {
    int N,C;
    int sum = 0;
    
    cin >> N;
    vector<int> V(N);
    for(int i=0;i<N;i++) {
        cin >> V[i];
    }
    for(int i=0;i<N;i++) {
        cin >> C;
        if(V[i] > C) {
            sum += (V[i]-C);
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(long long i = 0;i < (n);i++)
typedef long long ll;
#define P pair<ll,ll>
#define pb push_back
#define mk make_pair
using namespace std;
const ll INF = 1e14;



#define MAX_V 100000

struct edge {
    ll to;
    ll cost;
};


ll V;
vector<edge> G[MAX_V];
ll d[MAX_V];


void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}



int main(){
  ll E,r;
  cin >> V;
  
  E = V-1;
  REP(i,E){
    ll f,t,c;
    cin >> f >> t >> c;
    f--;
    t--;
    edge e = {t,c};
    G[f].pb(e);
    e.to = f;
    G[t].pb(e);
  }
  ll q,k;
  cin >> q >> k;
  k--;
  dijkstra(k);
  REP(i,q){
    ll x,y;
    cin >> x >> y;
    cout << d[x-1]+d[y-1] << endl;
    
  }
  //cout << d[4] << d[5] << endl;
  /*for (int i=0; i<V; ++i) {
        if(d[i] != INF)
	  cout <<  d[i] << endl;
	else if(d[i] == INF)
	  cout << "INF" << endl;
  }
  */
  return 0;
}


Measured memory_bytes: 11120
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;


int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b)printf("%d",c);
    else if(b==c)printf("%d",a);
    else printf("%d",b);
    
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int cnt = 2;
        for(int j = 2; j * j <= i; j++){
            if(i % j == 0){
                if(j * j != i){
                    cnt += 2;
                } else {
                    cnt++;
                }
            }
        }
        if(cnt == 8){
            //cout << i << endl;
            ans++;
        }
    }
    cout << ans << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define PI           3.14159265358979323846  /* pi */
typedef long double ld;
long n, m;
vector<vector<long>> adj;
vector<long> par;

void bfs(long src)
{
    par[src] = 0;
    vector<long> q;
    q.push_back(src);
    for (long i = 0; i < q.size(); i ++)
    {
        long v = q[i];
        for (long x: adj[v])
        {
            if (par[x] == -1)
            {
                par[x] = v;
                q.push_back(x);
            }
        }
    }
}



int main(){
    cin >> n >> m;
    long a, b;
    adj.resize(n+1);
    par.resize(n+1, -1);

    for (long i = 0; i < m; i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    bfs(1);
    bool np = false;
    for (long i = 1; i<= n; i++)
        if (par[i] == -1)
            np = true;
    if (np)
        cout << "No";
    else
    {
        cout << "Yes\n";
        for (long i = 2; i <= n; i++)
            cout << par[i] << "\n";
    }
    return 0;
}

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

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


    int L = S.length();
    while(S.length()>0)
    {
        S.erase(S.size()-1);
        if(S.size() %2==0) continue;

        bool flag = true;
        for (int j = 0; j < S.length()/2; j++){
            if(S[j] != S[(S.length()/2)+j]) flag = false;
        }

        if(flag == true){
            cout << S.length()-1 << endl;
            return 0;
        }

    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = min(n * a, b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888