akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main() {
	int n,k;
	cin >> n;
	cin >> k;
	if((n-1)%(k-1)==0){
		cout << (n-1)/(k-1);
	}
	else{cout << (n-1)/(k-1)+1;
        }	
} 

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

typedef complex<double> P;

int main(void){
	P p[4];
	while(1){
		rep(i,4){
			double x,y;
			cin >> x >> y;
			p[i]={x,y};
		}
		if(cin.eof()) break;
		bool ok=true;
		if(p[1].real()<p[2].real()) ok=false;
		if(p[3].real()<p[0].real()) ok=false;
		if(p[1].imag()<p[2].imag()) ok=false;
		if(p[3].imag()<p[0].imag()) ok=false;
		if(ok)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

Measured memory_bytes: 1184
chomp (my ($n, $k) = split / /, <STDIN>);
chomp (my @p = split / /, <STDIN>);
my @q;
$q[0] = 0;
for my $i (1..$n) {
  $q[$i] = $p[$i-1] + $q[$i-1];
}
my $max = 0;
for my $i (0..$n-$k) {
  my $m = $q[$k+$i] - $q[$i];
	$max = $m if $max < $m;
}
print (($max+$k)/2);

Measured memory_bytes: 34636
#include<stdio.h>
int A, B, C;
long long Mod = 1000000007, F[5010], InvF[5010], Res;
long long Pow(long long a, int b){
    long long r = 1;
    while(b){
        if(b&1)r=r*a%Mod;
        a=a*a%Mod;b>>=1;
    }
    return r;
}
long long H(int a, int b){
    if(!a&&!b)return 1;
    return F[a+b-1] * InvF[b] % Mod * InvF[a-1] % Mod;
}
int main(){
    int n;
    scanf("%d%d%d%d",&n,&A,&B,&C);
    int i, j;
    F[0]=InvF[0]=1;
    for(i=1;i<=5000;i++){
        F[i]=F[i-1]*i%Mod;
        InvF[i]=Pow(F[i],Mod-2);
    }
    if(B%2){
        printf("0\n");
        return 0;
    }
    for(i=0;i<=A;i++){
        for(j=0;A-i+3*j<=C;j++){
            int s = C - (A-i+3*j);
            Res = (Res +F[A+j+B/2] * InvF[i] % Mod * InvF[j] % Mod * InvF[A-i] % Mod * InvF[B/2] % Mod * H(B/2,s))%Mod;
        }
    }
    printf("%lld\n",Res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define cu continue
#define br break
#define pb push_back
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define F first
#define S second
#define vll vector <ll>
#define dbg(n) cout<<#n<<' '<<n<<endl;

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


    ll n;
    cin>>n;
    ll v[n+1];
    for(ll i=0;i<=n;i++) v[i]=0;
    for(ll i=2;i<=n;i++)
    {
    	ll x;
    	cin>>x;
    	v[x]++;
    }
    for(ll i=1;i<=n;i++)
    	cout<<v[i]<<'\n';
}      

Measured memory_bytes: 5152
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   string s;
   cin>>s;
   for(int i=s.size()-2;i>=0;i--){
      bool flag=true;
      if((i+1)%2==0){
         for(int j=0;j<(i+1)/2;j++){
            if(s[j]!=s[(i+1)/2+j]){
               flag=false;
            }
         }
         if(flag){
            cout<<i+1<<endl;
            return 0;
         }
      }
   }
   
   
}

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

using ll = long long;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Graph = vector<vector<int>>;

int main() {

	int N, A;
	cin >> N >> A;

	int l = A, r = A + N - 1;

	int eat;
	if (r <= 0)eat = r;
	else if (l >= 0)eat = l;
	else eat = 0;

	cout << (r + l) * (r - l + 1) / 2 - eat << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  unsigned long long int n,ans=1,ans1=1;
  scanf("%lld", &n);
  unsigned long long int a[n];
  //printf("%d",n);
  for(int i=0;i<18;i++){
    ans1 = ans1*10;
    //printf("%lld", ans1);
  }

  for(int i=0;i<n;i++){
    scanf("%lld", &a[i]);
    if(a[i]==0){
      ans = 0;
    }
  }
  for(int i=0;i<n;i++){
    if(ans!=0){
    unsigned long long int temp=0;
    temp = ans;
    ans = ans * a[i];
    if(temp!=ans/a[i]){
      ans=-1;
      break;
    }
    if(ans>ans1){
      ans=-1;
      break;
    }
  }
  }
    printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 2504
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  double h,a;

  cin >> h >> a;

  cout << ceil(h / a) << endl;

  return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(input())
s = list(map(int, input().split()))
s.sort()
dp = [0] * ((10 ** 6) + 100)

res = s[0]
for ss in s:
    dp[ss] += 1
    res = gcd(res, ss)

A = max(s)
pairwise = True
setwise = (res == 1)

for i in range(2, A + 1):
    cnt = 0
    for j in range(i, A + 1, i):
        cnt += dp[j]
    if cnt > 1:
        pairwise = False
        break

if pairwise:
    print("pairwise coprime")
elif setwise:
    print("setwise coprime")
else:
    print("not coprime")


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

#define pb push_back
#define F first
#define S second

#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define int long long
#define ll long long


	
void solve(){
	int n, x;
	n = 5;
	int ind = -1;
	for(int i = 0 ; i < n ; i++){
		cin >> x;
		if(x == 0)
			ind = i + 1;	
	}
	cout << ind;

}

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

Measured memory_bytes: 3648
use std::io;
use std::io::Read;

fn main() {
    let mut stdin = io::stdin();
    let mut lines = String::new();
    let _ = stdin.read_to_string(&mut lines);
    let vec = lines.lines().collect::<Vec<&str>>();
    let n :usize = vec[0].trim().parse().unwrap();
    let mut a :Vec<(usize,usize)> = Vec::new();
    for i in 0..n {
        a.push((vec[i+1].trim().parse().unwrap(),i));
    }

    a.sort_by(|a,b| (a.0).cmp(&(b.0)));
    let mut cnt = 0;
    for i in 0..n {
        if i % 2 != 0 { continue; }
        if a[i].1 % 2 != 0 { cnt += 1; }
    }
    println!("{}", cnt);
}



Measured memory_bytes: 9336
h, w = [int(x) for x in input().split()]
maze = []
whitesum = 0
for i in range(h):
  m = input()
  whitesum += m.count('.') 
  maze.append(m)
dist = [[-1]*w for i in range(h)]
dxy = ((1,0),(-1,0),(0,1),(0,-1))

def bfs():
  queue = []
  queue.insert(0,(1,1))
  dist[0][0] = 0
  while(len(queue)):
    x, y = queue.pop()
    if x == w and y == h:
      break
    for (dx, dy) in dxy:
      nx, ny = x+dx, y+dy
      
      if(nx>0 and nx<=w and ny>0 and ny<=h and maze[ny-1][nx-1] == '.' and dist[ny-1][nx-1] == -1):
        queue.insert(0, (nx, ny))
        dist[ny-1][nx-1] = dist[y-1][x-1] + 1
        
bfs()
if dist[h-1][w-1] == -1:
  print(-1)
else:
  print(whitesum-dist[h-1][w-1]-1)

Measured memory_bytes: 3064
X = int(input())
C= [i**5 for i in range(1000)]

a = 0
b = 0

for a in range(len(C)):
    for b in range(len(C)):
        if C[a] + C[b] == X:
            print(a, -b)
            exit(0)
        elif C[a] - C[b] == X:
            print(a, b)
            exit(0)


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

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

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

template < class T > inline void fastScan(T &x){
    register char c = getchar();
    int neg = 0; x = 0;
    for(   ; (c < 48 || c > 57) && (c != '-'); c = getchar());
    if(c == '-') { neg = 1; c = getchar(); }
    for(   ; c > 47 && c < 58; c = getchar()){
        x = (x << 1) + (x << 3) + c - 48;
    }
    if(neg) x = -x;
}

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

int a[N], b[N];

ll P(int n, int k){
    ll ret = 0;
    for(int i = 1; i <= n; i++){
        if((a[i] & k) == a[i]){
            ret += b[i];
        }
    }
    return ret;
}

int main(){
    int n, k;
    fastScan(n); fastScan(k);
    for(int i = 1; i <= n; i++){
        fastScan(a[i]); fastScan(b[i]);
    }
    ll res = P(n, k);
    for(int i = 30; i >= 0; i--){
        if(k & (1 << i)){
            int x = k & ~(1 << i);
            x |= ((1 << i) - 1);
            res = max(res, P(n, x));
        }
    }
    printf("%lld\n", res);
}


Measured memory_bytes: 1024
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

int[26] CS;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];

    foreach (_; 0..H) {
        foreach (c; readln.chomp) ++CS[c - 'a'];
    }
    sort!"a > b"(CS[0..26]);
    size_t i;
    foreach (_y; 0..H/2) {
        foreach (_x; 0..W/2) {
            while (i < 26 && CS[i] < 4) ++i;
            if (i == 26) {
                writeln("No");
                return;
            }
            CS[i] -= 4;
        }
    }
    if (H%2 == 1) {
        i = 0;
        foreach (_x; 0..W/2) {
            while (i < 26 && CS[i] < 2) ++i;
            if (CS[i] < 2) {
                writeln("No");
                return;
            }
            CS[i] -= 2;
        }
    }
    if (W%2 == 1) {
        i = 0;
        foreach (_x; 0..H/2) {
            while (i < 26 && CS[i] < 2) ++i;
            if (i == 26) {
                writeln("No");
                return;
            }
            CS[i] -= 2;
        }
    }
    writeln("Yes");
}

Measured memory_bytes: 256
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include<array>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const LL INF = 1000000007;

//毎回変える定数
constexpr int MAX_N = 100015;


//変数
LL n;
LL l, r;
pair<array<LL, MAX_N>, array<LL, MAX_N>> factorialTableNow;


//サブ関数
//入力
void input() {
	cin >> n;
	vector<LL> a(n + 1, -1);

	//同じ数字が何なのか、どこにあるかを入力と同時に調べる
	REP(i, n + 1) {
		LL tmp;
		cin >> tmp;
		if (a[tmp] == -1) {
			a[tmp] = i;
		}
		else {
			l = a[tmp];
			r = i;
			break;
		}
	}
}


//二分累乗法
//http://chausson.eng.kagawa-u.ac.jp/Comp/Prog/DosC/Sec4/Note483.html
LL mod_pow(LL base, LL exp, LL mod = INF) {
	LL s;
	//初期条件
	if (exp == 0) { return 1; }
	if (exp == 1) { return (base%mod); }
	//漸化式
	s = mod_pow(base, exp / 2) % mod;//再帰呼出
	if (exp % 2 == 0) {//偶数の場合
		return (s*s) % mod;
	}
	else {//奇数の場合
		LL tmp = (s*s) % mod;
		tmp *= base;
		tmp %= mod;
		return tmp;
	}
}


//階乗テーブル計算
//引数：maxX:必要な階乗の剰余の最大値 (x! mod MODのうちxの最大値) 
//返値：first: (index)!(mod MOD), second: (index!)^-1(mod MOD)
pair<array<LL,MAX_N>, array<LL,MAX_N>> makeFactorialTable(LL maxX, LL mod = INF) {
	array<LL, MAX_N> normal, inverse;
	normal[0] = 1;

	//vector<LL> normal(1, 1);
	//vector<LL> inverse;

	//通常の剰余
	LL base = 1;
	FOR(i, 1, maxX + 1) {
		base *= i;
		base %= mod;
		normal[i] = base;
		//if (base < 0)cout << "Error" << endl;
	}

	//逆元の剰余
	base = mod_pow(normal[maxX], mod - 2) % mod;// i!(mod MOD)

	for (int i = maxX; i > 1; i--) {
		base *= i;
		base %= INF;
		inverse[i - 1] = base;
	}
	inverse[0]= 1;

	//reverse(inverse.begin(), inverse.end());

	return make_pair(normal, inverse);
}


//計算
void calc() {
	factorialTableNow = makeFactorialTable(n + 3);
}


//コンビネーション剰余
//argument:L コンビネーションの左のやつ。R　コンビネーションの右のやつ
//         factorialTable: 階乗テーブル
LL combination(
	const LL& L, 
	const LL& R, 
	const pair<array<LL,MAX_N>, array<LL,MAX_N>>& factorialTable = factorialTableNow,
	const LL& mod = INF) {
	if (L - R < 0)return 0;
	LL ans = factorialTable.first[L];
	ans *= factorialTable.second[R];
	ans %= mod;
	ans *= factorialTable.second[L - R];
	ans %= mod;
	return ans;
}


//出力
void output() {
	FOR(k, 1, n + 1) {
		LL ans = combination(n + 1, k) - combination(l - 1 + n + 1 - r, k - 1);
		//cout << combination(n + 1, k) << " " << combination(l - 1 + n + 1 - r, k - 1) << " ";
		ans += INF * 2;
		ans %= INF;
		cout << ans << endl;
	}
	cout << 1 << endl;
}

//デバッグ
void debug() {

	//REP(i, 100)
	//cin >> n;
}


//メイン関数
int main() {

	input();
	calc();
	output();
	debug();

	return 0;
}


Measured memory_bytes: 5872
#include<stdio.h>

void main()
{
	int kazu;
	char moji[105];
	int i;
	int a;
	a = scanf("%d", &kazu);
	a = scanf("%s", moji);


	for (i = 0; i < kazu; ++i) {
		if (moji[i] == '\0') {
			return;
		}
		printf("%c", moji[i]);
	}
	for (i = 0; moji[i] != '\0'; ++i);
	if (kazu < i) {
		printf("...");
	}

}

Measured memory_bytes: 1724
import sys
MOD = 998244353


def main():
    input = sys.stdin.buffer.readline
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [[None] * (s + 1) for _ in range(n + 1)]
#     dp[i][j]:=集合{1..i}の空でない部分集合T全てについて,和がjとなる部分集合の個数の和
    for i in range(n + 1):
        for j in range(s + 1):
            if i == 0 or j == 0:
                dp[i][j] = 0
                continue
            if j > a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + dp[i - 1][j - a[i - 1]]
            elif j == a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + pow(2, i - 1, MOD)
            else:
                dp[i][j] = dp[i - 1][j] * 2
            dp[i][j] %= MOD
    print(dp[n][s])


if __name__ == '__main__':
    main()


Measured memory_bytes: 278828
#include <cstdio>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=0 && 0<=b)puts("Zero");
	else if(0<a && 0 <b)puts("Positive");
	else if(a<0 && b<0){
		if((b-a+1)&1){
			puts("Negative");
		}
		else puts("Positive");
	}

}

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

int main(){
    int x;
    cin >> x;
    int h, m, s;
    h = x / 3600;
    m = (x % 3600) / 60;
    s = ((x % 3600) % 60);
    cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void dump_(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  VAR(int, N);
  if (N == 1) OUTL("Hello World");
  else {
    VAR(int, a, b);
    OUTL(a + b);
  }

  return 0;
}


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

int main() 
{
    string s;
    cin >> s;
    // stack<char> pile;
    // pile.push(s[0]);
    // int i=1;
    int one = count(s.begin(),s.end(),'1');
    int zero = count(s.begin(),s.end(),'0');
    cout << min(one,zero)*2;

    // while(i!=s.size())
    // {
    //     i++;
    //     if (!pile.empty())
    //         if ((pile.top()=='0' && s[i]=='1') || 
    //         (pile.top()=='1' && s[i]=='0'))
    //             pile.pop();
    //         else
    //             pile.push(s[i]);
    //     else
    //         pile.push(s[i]);
    // }
    // cout << pile.size();
    // cout << s.size() - pile.size();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M;
  cin>>N>>M;
  VI A(M),C(M);
  int B,D,INF=1e9;
  rep(i,M){
    cin>>A[i]>>B;
    rep(j,B){
      cin>>D;
      C[i]|=(1<<(D-1));
    }
  }
  int dp[M+1][(1<<N)];
  rep(i,M+1) rep(j,(1<<N)) dp[i][j]=INF;
  dp[0][0]=0;
  rep(i,M+1) rep(j,(1<<N)) if(i){
    dp[i][j]=min(dp[i][j],dp[i-1][j]);
    dp[i][j|C[i-1]]=min(dp[i][j|C[i-1]],dp[i-1][j]+A[i-1]);
  }
  if(dp[M-1][(1<<N)-1]==INF) cout<<-1<<endl;
  else cout<<dp[M-1][(1<<N)-1]<<endl;
}



Measured memory_bytes: 16256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>> store(n);
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		store[i] = make_pair(a, b);
	}
	sort(store.begin(), store.end());
	ll ans = 0;
	for (int i = 0; i<n;i++) {
		if (m > store[i].second ) {
			ans += store[i].first*store[i].second;
			m -= store[i].second;
		}
		else if (m < store[i].second) {
			ans += m * store[i].first;
			break;
		}
		else {
			ans += store[i].first*store[i].second;
			break;
		}
	}
	cout << ans << endl;
//	cout << store[0].first<<" "<<store[0].second << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define inf 1e15
int main(){
  int size,k;
  cin>>size>>k;
  vector<int>height(size,0);
  for(int i=0;i<size;i++){
	
    cin>>height[i];
  }
  vector<int>dp(size,inf);
  dp[0]=0;
  for(int i=0;i<size;i++){
    for(int j=1;j<=k&&i+j<size;j++){
  		dp[i+j]=min(dp[i+j],dp[i]+abs(height[i]-height[i+j]));
  		//dp[i+1]=min(dp[i+j],dp[i]+abs(height[i]-height[i+j]));
    }
  }
  cout<<dp[size-1];
  return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<t: FromStr>() -> t {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        // initialize
        let mut v: Vec<usize> = vec![];
        for i in 0..n + 1 {
            v.push(i)
        }
        let mut s: Vec<usize> = vec![1; n + 1];

        UnionFind { parent: v, size: s }
    }

    fn root(&self, x: usize) -> usize {
        if self.parent[x] == x {
            return x;
        } else {
            return self.root(self.parent[x]);
        }
    }

    fn size(&self, a: usize) -> usize {
        let ra = self.root(a);
        self.size[ra]
    }

    fn unite(&mut self, a: usize, b: usize) {
        let mut ra = self.root(a);
        let mut rb = self.root(b);
        if ra == rb {
            return;
        }
        if self.size[ra] < self.size[rb] {
            std::mem::swap(&mut ra, &mut rb)
        };
        self.size[ra] += self.size[rb];
        self.parent[rb] = ra;
    }

    fn same(&self, a: usize, b: usize) -> bool {
        let ra = self.root(a);
        let rb = self.root(b);
        ra == rb
    }
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut p: Vec<i64> = vec![];
    let mut uf = UnionFind::new(n);
    for _ in 0..n {
        p.push(read());
    }
    let mut xy: Vec<(i64, i64)> = vec![];
    for _ in 0..m {
        let x: i64 = read();
        let y: i64 = read();
        xy.push((x, y));
        uf.unite(x as usize, y as usize);
    }
    let mut ans = 0;

    for i in 0..n {
        if uf.same(i + 1, p[i] as usize) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    for (int i = 0; i < (s.length() - 1); i++) {
      if (s.substring(i, i + 2).equals("AC")) {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");

  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'S') ++cnt;
        else {
            ans += (cnt > 0);
            cnt = max(0, cnt - 1);
        }
    }
    cout << n - 2 * ans << '\n';
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    string s;
    int k;
    cin>>s>>k;
    int n=s.length();
    set<string> a;
    rep(j,k+1){
        if(j==0)continue;
        rep(i,n-j+1){
            a.insert(s.substr(i,j));
        }
    }
    vector<string>ans;
    for(auto x:a){
        ans.push_back(x);
    }
    cout<<ans[k-1]<<endl;

}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

int n, m;
int s[100000], t[100000];
int pre[2][100000];
vector<int> p;

void Pre(){
	rep(i,p.size()){
		if(i == 0){
			pre[0][i] = 0;
			pre[1][i] = 0;
			continue;
		}
		pre[0][i] = pre[1][i-1]+p[i]-p[i-1];
		pre[1][i] = pre[0][i-1];
	}	
}

int main(){
	cin >> n >> m;
	rep(i,n){
		cin >> s[i] >> t[i];
	}
	rep(i,m){
		int tmp; cin >> tmp;
		p.push_back(tmp);
	}
	sort(p.begin(),p.end());
	Pre();
	
	long long ans = 0;
	rep(i,n){
		if(s[i] < t[i]){
			int stt = (upper_bound(p.begin(),p.end(),s[i])-p.begin());
			int ett = (upper_bound(p.begin(),p.end(),t[i])-p.begin());
			if(ett == 0){
				ans += t[i]-s[i];
				continue;
			}
			ett--;
			if(stt == p.size() || p[stt] > t[i]){
				ans += t[i]-s[i];
				continue;
			}
			ans += p[stt]-s[i];
			if((ett-stt)%2 == 0){
				ans += pre[0][ett]-pre[0][stt];
			} else{
				ans += t[i]-p[ett];
				ans += pre[1][ett]-pre[0][stt];
			}
		} else{
			int stt = (upper_bound(p.begin(),p.end(),t[i])-p.begin());
			int ett = (upper_bound(p.begin(),p.end(),s[i])-p.begin());
			if(ett == 0){
				ans += s[i]-t[i];
				continue;
			}
			ett--;
			if(stt == p.size() || p[stt] > s[i]){
				ans += s[i]-t[i];
				continue;
			}
			ans += s[i]-p[ett];
			if((ett-stt)%2 == 0){
				ans += pre[1][ett]-pre[1][stt];
			} else{
				ans += p[stt]-t[i];
				ans += pre[1][ett]-pre[0][stt];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3120
using System;

class Program
{
    static void Main()
    {
        int[] d = new int[10];
        int[] da = new int[10];
        for (int f = 0; f < 10; f++)
        {
            d[f] = int.Parse(Console.ReadLine());
        }
        for (int di = 0; di < 10; di++)
        {
            da[di] = int.Parse(Console.ReadLine());
        }
        Array.Sort(d);
        Array.Sort(da);
        Console.WriteLine((d[7] + d[8] + d[9]) + " " + (da[8] + da[7] + da[9]));
    }
}

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < n; i++)
#define INF INT_MAX
#define fcout cout << fixed << setprecision(15) // 15桁まで表示
#define en '\n'
using str = string;
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using puu = pair<ui, ui>;
using P = pair<int, int>;
using vi = vector<int>;
int gcd(int a, int b) {
  return b ? gcd(b, a % b) : a;
};
int lcm(int a, int b) {
  return a / gcd(a, b) * b;
};
int floor(int a, int b) {
  return (a + b - 1) / b;
};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
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;
};
const ll mod = 1000000007;
const double PI = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n, h, w, ans = 0;
  cin >> n>>h>>w;
  int a, b;
  rep(i,n){
    cin >> a>>b;
    if (a>=h and b>=w)
      ans++;
  }
  cout << ans << en;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,a,bad[10]={};
  cin >> m >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    bad[a]++;
  }
  for(int i=m;i<=10*m;i++){
    string t=to_string(i);
    int tmp=i,cnt=0;
    while(1){
      if(bad[tmp%10]==0){
        cnt++;
      }
      if(cnt==t.size()){
        cout << i << endl;
        return 0;
      }
      if(tmp/10==0){
        break;
      }
      tmp/=10;
    }
  }
}


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

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var w = a.Count(x => x % 2 == 1);
        Console.WriteLine(w % 2 == 0 ? "YES":"NO");
    }
}

Measured memory_bytes: 20576
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,cnt=0;
  cin >> n;
  string s;
  map<string,int> m;
  set<string> se;
  for(int i=0; i<n; i++) {
    cin >> s;
    m[s]++;
    cnt=max(cnt,m[s]);
  }
  for(auto p:m) {
    if(p.second==cnt) {
      se.insert(p.first);
    }
  }
  for(auto itr=se.begin(); itr!=se.end(); itr++) {
    cout << *itr << endl;
  }
}

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

int main()
{
    int num[1001]={0};
    int sum1=0,sum2=0;
    int n,m;
    scanf("%d",&n);
    for(m=0;m<n;m++){
        scanf("%d",&num[m]);
    }
    sort(num,num+n);
    for(m=0;m<n;m++){
        if(m%2==0){
            sum1+=num[n-m-1];
        }
        else sum2+=num[n-m-1];
    }
    printf("%d",sum1-sum2);
    return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  
  if (a==b){
    if(b==c){
      cout << 1 << endl;
    }
    else{
      cout << 2 << endl;
    }
  }
  else{
    if (b==c){
      cout << 2 << endl;
    }
    else{
      if (a==c){
        cout << 2 << endl;
      }
      else{
        cout << 3 << endl;
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


int n;int a[210000];
signed main(){
  cin>>n;rep(i,n){
    cin>>a[i];
    a[i] *= -1;
  }
  multiset<int> st;
  rep(i,n){
    auto itr = st.upper_bound(a[i]);
    if(itr != st.end())st.erase(itr);
    st.insert(a[i]);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>

typedef long double ld;
typedef long long ll;

using namespace std;

string s, t;

int main() {
	cin >> s >> t;
	bool good = true;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != t[i]) {
			good = false;
			break;
		}
	}
	if (good) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <queue>
#include <string>
//--------------------------------------------------------------------------
struct TData
{
	std::string Name;
	int Rest;
	void Input();
};
//--------------------------------------------------------------------------
void TData::Input()
{
	std::cin >> Name;
	std::cin >> Rest;
}
//--------------------------------------------------------------------------
typedef std::queue<TData> TDataQueue;

void InputDataQueue(TDataQueue& DataQueue,const int& Count);
void RoundRobin(TDataQueue& DataQueue,const int& Quantum);
//--------------------------------------------------------------------------
int main()
{
	int Count = 0;
	std::cin >> Count;
	int Quantum = 0;
	std::cin >> Quantum;
	
	TDataQueue DataQueue;
	InputDataQueue(DataQueue,Count);
	RoundRobin(DataQueue,Quantum);
	
	return 0;
}
//--------------------------------------------------------------------------
void InputDataQueue(TDataQueue& DataQueue,const int& Count)
{
	for(int i=0;i<Count;i++)
	{
		TData Data;
		Data.Input();
		DataQueue.push(Data);
	}
}
//--------------------------------------------------------------------------
void RoundRobin(TDataQueue& DataQueue,const int& Quantum)
{
	int Clock = 0;
	while(!DataQueue.empty())
	{
		TData FrontData = DataQueue.front();
		FrontData.Rest -= Quantum;
		if(FrontData.Rest > 0)
		{
			Clock += Quantum;
			DataQueue.push(FrontData);
		}else
		{
			Clock += DataQueue.front().Rest;
			std::cout << FrontData.Name << " " << Clock << std::endl;
		}
		DataQueue.pop();
	}
}
//--------------------------------------------------------------------------

Measured memory_bytes: 4404
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,m,cnt=1;
  cin >> n >> m;
  for(int i=0; i<m; i++) {
    cnt*=2;
  }
  cout << ((n-m)*100+m*1900)*cnt << endl;
}

Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split())

# 各参加者がチョコレートを食べる日付を取得してリストへ格納する
al = [0 for _ in range(n)]
for i in range(n):
    al[i] = int(input())

# 1日目が経過した状態にする
ans = n
eat_count = [1 for _ in range(n)]
next_eat = [0 for _ in range(n)]
for i in range(n):
    next_eat[i] = al[i]*eat_count[i]+1
    eat_count[i] = 2

# 2日目以降の食べた個数を求める
for day in range(1, d+1):
    if not(day in next_eat):
        continue

    for i, eat_day in enumerate(next_eat):
        if eat_day == day:
            ans += 1
            next_eat[i] = al[i]*eat_count[i]+1
            eat_count[i] += 1

print(ans+x)


Measured memory_bytes: 3064
import java.io.*;

public class Main{

    static boolean exhaustiveSearch(int[] a, int i, int key){
        if(key == 0)
            return true;
        if(i >= a.length)
            return false;
        boolean res = exhaustiveSearch(a, i + 1, key) || exhaustiveSearch(a, i + 1, key - a[i]);
        return res;
    }
    public static void main(String[] args){
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();

        try{
            int n = Integer.parseInt(br.readLine());
            String[] s = br.readLine().split(" ");
            int[] a = new int[n];
            for(int i = 0; i < n; i++)
                a[i] = Integer.parseInt(s[i]);

            int q = Integer.parseInt(br.readLine());
            String[] str = br.readLine().split(" ");
            int[] m = new int[q];
            for(int i = 0; i < q; i++)
                m[i] = Integer.parseInt(str[i]);

            for(int i = 0; i < q; i++){
                if(exhaustiveSearch(a, 0, m[i])){
                    sb.append("yes\n");
                }else{
                    sb.append("no\n");
                }
            }

            System.out.print(sb.toString());
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24668
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

  int root(int x){
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  int n,m;
  cin >> n >> m;
  ll h[n+1];
  rep(i,n){
    cin >> h[i+1];
  }

  int flag[n+1];
  rep(i,n){
    flag[i+1] = 1;
  }
  rep(i,m){
    int a,b;
    cin >> a >> b;
    if(h[a] > h[b]){
      flag[b] = 0;
    }
    else if(h[a] < h[b]){
      flag[a] = 0;
    }
    else{
      flag[a] = 0;
      flag[b] = 0;
    }
  }

  int ans = 0;
  rep(i,n){
    ans += flag[i+1];
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4796
n,m=map(int,input().split())
memo=[0]*n
from itertools import accumulate
for i in range(m):
    l,r=map(lambda x:int(x)-1,input().split())
    memo[l]+=1
    if r+1!=n:
        memo[r+1]-=1
ac=list(accumulate(memo))
print(ac.count(m))

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

int main() {
  string s;
  cin >> s;
  string k = "keyence";
  int n = s.size();
  int j = 0;
  for (int i=0; i<7; i++){
    if (s.at(i) == k.at(i)){
      j++;
    }
    else {
      break;
    }
  }
  if (j == 7){
    cout << "YES" << endl;
  }
  
  else {
    int i = 0;
    while (i < (7-j)){
      if (s.at(n-1-i) != k.at(6-i)){
        cout << "NO" << endl;
        break;
      }
      if (i == (6-j)){
        cout << "YES" << endl;
        break;
      }
      i++;
    }
  }
}

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


int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  string z;
  for(int i=0;i<n;++i){
    if(i==0){
      z=s[0];
      z=z+t[i];
    }else{
      z=z+s[i];
      z=z+t[i];
    }
  }
  cout << z << endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define debug(n1) cout << n1 << endl;
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

const string __sep = "\n";
const ll INF = 1000000000000000001;
const int MOD = 998244353;


ll foo(ll n, int a, int b, int c, int d) {
  if (n == 0) return 0;
  if (n == 1) return d;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  T = 1;
  //cin >> T;
  while (T-- > 0) {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> A(N+M);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A[i]=make_pair(a,1);
  }
  for(int i=0;i<M;i++){
    int b,c;
    cin>>b>>c;
    A[N+i]=make_pair(c,b);
  }
  sort(A.begin(),A.end());
  int j=0,k=0;
  for(int i=N+M-1;i>=0;i--){
    if(k+A[i].second<N){
      j+=A[i].first*A[i].second;
      k+=A[i].second;
    }else{
      cout<<j+A[i].first*(N-k)<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 6396
x,y=map(int,input().split())
ans=0
if x==3: ans+=100000
if y==3: ans+=100000
if x==2: ans+=200000
if y==2: ans+=200000
if x==1: ans+=300000
if y==1: ans+=300000
if x==1 and y==1: ans+=400000
print(ans)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define int     long long int
#define MOD     1000000007
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI      3.1415926535897932384626
#define pb      push_back
#define clr(x)  memset(x, 0, sizeof(x))
const int N=1000001;
using namespace std;
int gcd(int a,int b)
{if(a==0)return b;return gcd(b%a,a);}
int lcm(int a,int b){return (max(a,b)/gcd(a,b))*min(a,b);}
int powermodm(int x,int n,int M){int result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
int gcdExtended(int a, int b, int *x, int *y){if (a == 0){*x = 0, *y = 1;return b;}int x1, y1;int gcd = gcdExtended(b % a, a, &x1, &y1);*x = y1 - (b / a) * x1;*y = x1;return gcd;}
int modInverse(int a, int m){int x, y;int g = gcdExtended(a, m, &x, &y);if (g != 1)return -1;else{int res = (x % m + m) % m;return res;}}
bool isPrime(int a){if(a==1) return false;if(a==2) return true;if(a%2==0) return false;int root=sqrt(a);for(int i=3;i<=(int)root;i+=2){if(a%i==0)return false;}return true;}

main()
{
    fastIO;
    int count = 0;
    string s,t;
    cin >> s;
    cin >> t;
    for(int i=0; i<s.size(); i++){
        if(s[i] != t[i]){
            count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 3856
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	int sum=0;
	rep(i,n)cin>>a[i];
	rep(i,n){
		sum=sum^a[i];
	}
	if(sum==0){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
	return 0;
}

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= 0x3f3f3f3f;
void solve(){
 int n;
 sl(n);
 map<string,int>dp;
 for(int i=0;i<n;i++){
	 string str;
	 cin>>str;
	 dp[str]++;
 }
 vector<pair<string,int>>vec;
 int mx=-inf;
 for(auto it:dp){
	 vec.pb(mp(it.F,it.S));
	 if(it.S>mx)mx=it.S;
 }
 sort(vec.begin(),vec.end());
 
 for(auto it:vec){
	 if(it.S==mx)cout<<it.F<<endl;
 }

}

signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();

   }
  return 0;
}


Measured memory_bytes: 29844
#include <bits/stdc++.h>
using namespace std;
int h, w;
vector<vector<char>> mp;
vector<vector<int>> cost;
struct pos {
    int y;
    int x;
};

int bfs() {
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};

    queue<pos> que;
    pos start;
    start.x = 0; start.y = 0;
    que.push(start);
    cost.at(0).at(0) = 0;

    while(!que.empty()) {
        pos p = que.front();
        que.pop();
        pos finish;
        finish.x = w-1; finish.y = h-1;
        if(p.x == finish.x && p.y == finish.y) {
            return cost.at(p.y).at(p.x);
        }
        for(int i = 0; i < 4; ++i) {
            int ny = p.y + dy[i], nx = p.x + dx[i];
            if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
            if(mp.at(ny).at(nx) == '#') continue;
            if(cost.at(ny).at(nx) != -1) continue;

            cost.at(ny).at(nx) = cost.at(p.y).at(p.x) + 1;
            pos next;
            next.x = nx; next.y = ny;
            que.push(next);
        }
    }
    return -1;
}

int main() {
    cin >> h >> w;
    mp = vector<vector<char>>(h, vector<char>(w));
    int white = 0;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> mp.at(i).at(j);
            if(mp.at(i).at(j) == '.') white++;
        }
    }
    cost = vector<vector<int>>(h, vector<int>(w, -1));
    int mincost = bfs();
    if(mincost == -1) {
        cout << -1 << endl;
    }else {
        cout << white - (mincost+1) << endl;
    }
}

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

using namespace std;

int main() {

	int c[3][3];


	int a[3];
	int b[3];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	a[0] = 0;
	for (int i = 0; i < 3; i++) {
		b[i] = c[0][i] - a[0];
	}
	for (int i = 0; i < 3; i++) {
		a[i] = c[i][0] - b[0];
	}

	bool ans = true;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (a[i] + b[j] != c[i][j]) ans = false;
		}
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

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

    ll n, a, b;
    cin >> n >> a >> b;
    ll batch = n / (a + b);
    ll left = n - batch * (a + b);
    ll blue = batch * a + min(left, a);
    cout << blue;
}


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

typedef long long ll;
ll M = 1000000007;

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for (ll i = 2; i <= n; i++) {
		ll N = i;
		for (ll i = 2; i*i <= N; i++) {
			while (N%i == 0) {
				res[i]++;
				N /= i;
			}
		}
		if (N != 1)res[N]++;
	}

	return res;
}

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

	map<ll, ll> res;

	res = prime_factor(N);

	ll sum = 1;
	for (int i = 1; i <= N; i++) {
		if (res[i] > 0) {
			sum *= (res[i] + 1);
			sum %= M;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
r = 0
g = 0
b = 0
for x in s:
    if x == 'R':
        r += 1
    elif x == 'G':
        g += 1
    elif x == 'B':
        b += 1

ng_cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            continue
        else:
            k = 2 * j - i
            if k < n and s[i] != s[k] and s[j] != s[k]:
                ng_cnt += 1

print(r * g * b - ng_cnt)

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

int main(){
    int a,b,c; cin >> a >> b >> c;
    string ans = "No";
    if(a > b){
        if(b < c && c < a) ans = "Yes";
    }else{
        if(a < c && c < b) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256