akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    vint x(5);
    rep(i,5){
        cin >> x[i];
        if(x[i]==0) cout<<i+1<<endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (mp.count(a)) mp.erase(a);
		else mp[a]++;
	}
	cout << mp.size() << endl;
}

Measured memory_bytes: 4864
#include<cstdio>
#include<algorithm>

using int64=long long;
using uchar=unsigned char;

constexpr int maxn(200000);
constexpr int p(998244353);

namespace IOManager{
	constexpr int FILESZ(131072);
	char buf[FILESZ];
	const char*ibuf=buf,*tbuf=buf;

	struct IOManager{
		inline char gc()
			{return(ibuf==tbuf)&&(tbuf=(ibuf=buf)+fread(buf,1,FILESZ,stdin),ibuf==tbuf)?EOF:*ibuf++;}

		template<class _Tp>
			inline operator _Tp(){
				_Tp s=0u;char c=gc();
				for(;c<48;c=gc());
				for(;c>47;c=gc())
					s=(_Tp)(s*10u+c-48u);
				return s;
			}
	};
}IOManager::IOManager io;

char s[maxn+1];

int main(){
	int _=fread(s+1,1,maxn,stdin);
	if(s[_]=='\n'||s[_]=='\r')
		--_;
	const int n=_;

	int64 ans=0;
	for(int l=n,r=n;l;--l)
		if(s[l]=='B')
			ans+=(r-l),--r;
	printf("%lld",ans);

	return 0;
}


Measured memory_bytes: 384
import heapq
from heapq import heappush, heappop

n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
l = [[] for i in range(10**5)]

for a,b in ab:
    l[a-1].append(-b)
heap = []

ans = 0
for i in range(m):
    for j in l[i]:
        heappush(heap,j)
    if len(heap) == 0:
        continue
    ans += -(heappop(heap))
    
    
print(ans)

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


int main(void){
    long long start = 100;
    long long x;
    std::cin >> x;
    long long result = 0;
    while(start < x){
        start += start / 100;
        result++;
    }
    std::cout << result << std::endl;
    return 0;
}

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

	void solve() {
		ll n,m;
		cin >> n >> m;
		ll sum=0,c=0;
		ll arr[n];
		rep(i,0,n) {
			cin >> arr[i];
			sum=sum+arr[i];
		}
		ll max=0;
		if(sum%(4*m)==0){
			max=sum/(4*m);
		}else{
			max=sum/(4*m)+1;
		}
		rep(i,0,n){
			if(max<=arr[i]){
				c++;
			}
		}
		if(c>=m){
			cout <<"Yes ";
			return;
		}
		cout <<"No\n ";
		return;

	}

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

		// int t;
		// cin >> t;
		// while(t--)
			solve();

	}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char a = s.charAt(0);
    if (a >= 'A' && a <= 'Z') {
      System.out.println("A");
    } else {
      System.out.println("a");
    }
  }
}    

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  bool ok = false;
  for (int i = a; i < 1000000; i += a) {
    if (i % b == c) {
      ok = true;
      break;
    }
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x1,x2;
    cin>>x1>>x2;
    if(x1>x2){
        cout<<x1-x2<<endl;
    }
    if(x2>x1){
        cout<<x2-x1<<endl;
    }
    if(x1==x2){
        cout<<0<<endl;
    }
}



Measured memory_bytes: 3120
import heapq
N, M = map(int, input().split())
items = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(items)
for _ in range(M):
	tmp = heapq.heappop(items)
	heapq.heappush(items, int(tmp/2))
print(-sum(items))

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  if (a * n < b) {
    cout << a * n << endl;
  } else {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
k = int(input())
s = input()
mod = 10**9 + 7

n = 2*10**6 + 1
factorial = [1]
inverse = [1]
pow25 = [1]
pow26 = [1]
for i in range(1, n+1):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))
    pow25.append((pow25[-1]*25)%mod)
    pow26.append((pow26[-1]*26)%mod)

def comb(n, r, mod):
    if n < r or r < 0: return 0
    elif r == 0: return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod

n = len(s)
length = k + n
ans = 0
for i in range(n, length+1):
    temp = 1
    temp *= comb(i-1, n-1, mod)
    temp %= mod
    temp *= pow25[i-n]
    temp %= mod
    temp *= pow26[length-i]
    temp %= mod
    ans += temp
    ans %= mod
print(ans)

Measured memory_bytes: 263252
#include<stdio.h>
int main(void)
{
	int a,s,s1;
	while(1){
		scanf("%d",&a);
		if(a==0)break;
		s=1000-a;
		s1=s/500;
		s=s%500;
		s1+=s/100;
		s=s%100;
		s1+=s/50;
		s=s%50;
		s1+=s/10;
		s=s%10;
		s1+=s/5;
		s=s%5;
		s1+=s/1;
		printf("%d\n",s1);
	}
	
	return 0;
}
	

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int n;
  cin >> n;
  map<int, int> m;
  ll sum = 0;
  rep(i, n) {
    int x;
    cin >> x;
    m[x]++;
    sum += x;
  }

  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    m[c] += m[b];
    sum += m[b] * (c - b);
    cout << sum << '\n';
    m.erase(b);
  }

  return 0;
}


Measured memory_bytes: 6592
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

lli X, k, D;

void read_input()
{
    cin >> X >> k >> D;
}

void solve()
{
    if(X < 0) X = -X;
    lli t = X / D;
    if(k < t)
    {
        cout << X - D * k << '\n';
        return;
    }
    if((k - t) % 2 == 0)
        cout << X - D * t << '\n';
    else cout << abs(X - D * (t + 1)) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



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


int main() {
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  long long sum=0;
  map<int,long long int> mp;
  long long ans=0;
  mp[0]++;
  for(int i=0;i<n;++i){
    sum += a[i];
    ans += mp[sum%m];
    mp[sum%m]++;
  }
  cout << ans;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  sort(all(a), greater<int>());
  int alice = 0, bob = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }
  cout << abs(alice - bob) << '\n';
}


Measured memory_bytes: 3604
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int len = sc.nextInt();
			int max1 = 0;
			int count = 0;
			for (int i=0; i<len; i++) {
				if (sc.nextInt() == 1) {
					count++;
				} else {
					max1 = Math.max(max1, count);
					count = 0;
				}
				max1 = Math.max(max1, count);
			}
			System.out.println(max1+1);
		}
	}
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a * 2 - 1, b * 2 - 1});
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007;
LL a[100000];
int main() {
	int N;
	LL L;
	cin >> N >> L;
	for (int i = 0; i < N; i++) cin >> a[i];
	int idx = -1;
	for (int i = 0; i + 1 < N; i++) {
		if (a[i] + a[i + 1] >= L) {
			idx = i;
			break;
		}
	}
	if (idx == -1) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	for (int i = 0; i < idx; i++) {
		cout << i + 1 << endl;
	}
	for (int i = N - 2; i >= idx + 1; i--) {
		cout << i + 1 << endl;
	}
	cout << idx + 1 << endl;
}

Measured memory_bytes: 1536
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int a;
	cin >> a;
	int w = a;
 
	int simpan =0;
	while(a!=0){
	    simpan += (a%10);
	    a/=10;
	}
//	cout << simpan << endl;
 
	cout << (w%simpan!=0 ? "No" : "Yes") << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b;
    cin >> a >> b;
    if (a+b > 24) cout << a+b-24 << endl;
    else if(a+b <24) cout << a+b << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 1LL<<50;
int n,m;
struct edge{
    int from,to;
    ll cost;
};
edge e[2100];
ll d[1100];
bool nn[1100];
inline ll solve();
inline bool ng();
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;ll c;cin>>a>>b>>c;
        a--;b--;
        e[i].from=a;
        e[i].to=b;
        e[i].cost=-c;
    }
    ll ans=solve();
    if(ng()){
        cout<<"inf"<<endl;
    }else{
        cout<<-ans<<endl;
    }
    return 0;
}
inline ll solve(){
    for(int i=0;i<n;i++)d[i]=inf;
    d[0]=0;
    int cont=0;
    while(cont<n-1){
        bool update=false;
        for(int i=0;i<m;i++){
            edge a=e[i];
            if(d[a.from]!=inf && d[a.to]>d[a.from]+a.cost){
                d[a.to]=d[a.from]+a.cost;
                update=true;
            }
        }
        if(!update)break;
        cont++;
    }
    //for(int i=0;i<n;i++)cout<<d[i]<<" ";
    //cout<<endl;
    return d[n-1];
}
inline bool ng(){
    for(int i=0;i<n;i++)nn[i]=false;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            edge a=e[j];
            if(d[a.from]!=inf && d[a.to]>d[a.from]+a.cost){
                nn[a.to]=true;
                d[a.to]=d[a.from]+a.cost;
            }
            if(nn[a.from]==true)nn[a.to]=true;
        }
    }
    return nn[n-1];
}

Measured memory_bytes: 256
Dice = Struct.new(:labels) do
  def self.init(labels)
    labels = labels.dup.freeze
    raise ArgumentError, "length of labels should be 6" unless labels.count == 6

    new(labels)
  end

  def rotate(direction)
    case direction
    when ?N then rotate_northward
    when ?S then rotate_southward
    when ?E then rotate_eastward
    when ?W then rotate_westward
    else raise ArgumentError, "direction should be N, S, E or W, but #{direction} was given."
    end
  end

  def rotate_westward
    a,b,c,d,e,f = labels
    self.class.init([c,b,f,a,e,d])
  end

  def rotate_eastward
    c,b,f,a,e,d = labels
    self.class.init([a,b,c,d,e,f])
  end

  def rotate_southward
    a,b,c,d,e,f = labels
    self.class.init([e,a,c,d,f,b])
  end

  def rotate_northward
    e,a,c,d,f,b = labels
    self.class.init([a,b,c,d,e,f])
  end

  def [](index)
    raise ArgumentError, "index should be in 1 to 6" unless (1..6).include?(index)

    labels[index-1]
  end

  def top
    self[1]
  end
end

labels = gets.split.map(&:to_i)
dice = Dice.init(labels)

dice_last_state = gets.chomp.chars.reduce(dice) {|dice, direction|
  dice.rotate(direction)
}

p dice_last_state.top


Measured memory_bytes: 6876
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	a := nextInt()
	b := nextInt()
	if (a * 500 >= b) {
		fmt.Printf("Yes")
	} else {
		fmt.Printf("No")
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	ll n, t;
	cin >> n >> t;
	vector<ll> l(n);
	for (int i = 0; i < n; i++)
		cin >> l[i];
	sort(l.begin(), l.end());
	ll head = 0, end = 0;
	ll ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (l[i] + t < l[i + 1]) {
			end = l[i] + t;
			ans += end - head;
			head = l[i + 1];
		}
	}
	end = l[n - 1] + t;
	ans += end - head;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
    struct newdata
    {
        int label,cnt;
    };
    int n,m;
    int a[301][301];
    newdata rankm[301];
    bool used[301];
bool cmp(newdata i,newdata j)
{
    return (i.cnt>j.cnt);
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
        {
            scanf("%d",&a[i][j]);
            if (j==1) rankm[a[i][j]].cnt++;
        }
    int now=0;
    for (int i=1;i<=m;i++)
        rankm[i].label=i;
    int ans=2147483647;
    while (now<m)
    {
        sort(rankm+1,rankm+m+1,cmp);
        ans=min(ans,rankm[1].cnt);
        used[rankm[1].label]=true;
        memset(rankm,0,sizeof(rankm));
        for (int i=1;i<=m;i++)
            rankm[i].label=i;
        for (int i=1;i<=n;i++)
            for (int j=1;j<=m;j++)
            	if (!used[a[i][j]])
            	{
					rankm[a[i][j]].cnt++;
					break;
				}
        now++;
    }
    printf("%d",ans);
}


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

using namespace std;


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        string s = to_string(i);
        int sum = 0;
        for(auto cc : s) {
            sum += cc - 48;
        }
        if(a <= sum && sum <= b) {
            ans += i;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3708
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    sum = power(n , 2) + power(n , 3) + n;

    cout<<sum<<endl; 
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3648
N,M = map(int,input().split())
keys = []
for _ in range(M):
  a,b = map(int,input().split())

  s = 0
  for c in list(map(int,input().split())):
    c -= 1
    s = s | 1<<c

  keys.append((s, a))


# dp[i][j] = Nの状態の鍵を用いた時に、Mの鍵を開けるための最小コスト
dp = [float('inf')] * (1<<N)
dp[0] = 0
for s in range(1<<N):
  for i in range(M):
    t = s | keys[i][0]
    cost = dp[s] + keys[i][1]
    dp[t] = min(dp[t], cost)

if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1])

Measured memory_bytes: 76428
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const int INF=1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
ll a[100010][5];
ll dp[100010][3];

int main(int argc, char const *argv[]) {
  std::cin >> n;
  rep(i,n){
    rep(j,3){
      std::cin >> a[i][j];
    }
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
        if(k!=j) chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }

  ll ans=0;
  rep(i,3) chmax(ans,dp[n][i]);
  std::cout << ans << '\n';

  return 0;
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

int main(){
	string s;
	int K;
	cin >> s >> K;
	vector<string> a;
	int n = s.size();
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 5 && i + j < n; ++j)
			a.push_back(s.substr(i, j + 1));
	sort(all(a));
	unique(all(a));
	cout << a[K - 1];
	return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll a[N];
ll ans = 1e18;
ll n;
ll f(ll x){
	ll d = 0;
	for (int i = 0; i < n; i ++) {
		d += abs(x - a[i]) * abs(x - a[i]);
	}
	return d;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i ++)
    	cin >> a[i];
	for (int i = 1; i <= 100; i ++)
		ans = min(ans, f(i));
	cout << ans;
    return (0);
}

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

void movef(std::vector<char>* S,  int movex, int movey)
{
	char str;
	for(int i=0; i<movey; i++){
		str = 'U';
		S->push_back(str);
	}
	for(int i=0; i<movex; i++){
		str = 'R';
		S->push_back(str);
	}
}

void moveb(std::vector<char>* S,  int movex, int movey)
{
	char str;
	for(int i=0; i<movey; i++){
		str = 'D';
		S->push_back(str);
	}
	for(int i=0; i<movex; i++){
		str = 'L';
		S->push_back(str);
	}
}


int main()
{
	std::vector<char> S;
	int move[4], movex, movey;
	for(int i=0; i<4; i++){
		scanf("%d", &move[i]);		
	}
	movex = move[2] - move[0];
	movey = move[3] - move[1];
	movef(&S, movex, movey);
	moveb(&S, movex, movey); 
	S.push_back('L');
	movef(&S, movex+1, movey+1);
	S.push_back('D');
	S.push_back('R');
	moveb(&S, movex+1, movey+1);
	S.push_back('U');
	for(int i=0; i<S.size(); i++){
		printf("%c", S[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t = (h2-h1)*60;
    if(m2 >= m1)t += m2 - m1;
    else{
        t -= 60;
        t += (60 - m1);
        t += m2;
    }
    cout << t-k << endl;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  map<int, int> mp;
  rep(i, n) {
    mp[a.at(i)]++;
  }
  int m1 = -1;
  int m2 = -1;
  ll res = 0;
  for (auto m : mp) {
    if (m.second < 2) {
      continue;
    }
    if (m.first >= m1) {
      if (m.second >= 4) {
        res = max(res, (ll) m.first * m.first);
      }
      m2 = m1;
      m1 = m.first;
    } else if (m.first > m2) {
      m2 = m.first;
    }
    if (m2 != -1) {
      res = max(res, (ll) m1 * m2);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;
vector<ll> a;

int main(){
    cin >> N;
    a.resize(N);
    rep(i,N){
        cin >> a[i];
    }


    map<ll,ll> mp;
    rep(i,N){
        for(int j=-1;j<=1;j++){
            int b = a[i] + j;
            mp[b]++;
        }
    }

    ll vv = -1;
    ll ans = 0;
    for(auto p : mp){
        ll key = p.fi;
        ll val = p.se;
        if(vv < val){
            vv = val;
            ans = key;
        }
    }
    cout << vv << endl;
}

Measured memory_bytes: 6912
#include<iostream>
#include<climits>
using namespace std;
typedef long long int lli;

int main()
{
    //put here bitch 
    lli N,W; cin>>N>>W;
    lli w[101],v[101]; 
    lli a[101][100001]={0};
    for(lli i=0;i<N;i++) cin>>w[i]>>v[i];
    for(lli i=1;i<=W;i++) if(w[0]<=i) a[0][i]=v[0];
    
    for(lli i=1;i<N;i++)
        for(lli j=1;j<=W;j++)
        {
            if(j-w[i]>=0) a[i][j]=max(a[i-1][j],v[i]+a[i-1][j-w[i]]);
            else a[i][j]=a[i-1][j];
        }
    cout<<a[N-1][W]<<endl;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x % i == 0)return false;
	}
	return true;
}

int n, k, a[100010];
int ta, mu, rin, ans;

signed main() {
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		if (a[i] > 0)ta += a[i];
	}
	rep(i, n) {
		if (i <= k - 1) {
			if (a[i] > 0)mu += a[i];
			rin += a[i];
		}
		else {
			if (a[i - k] > 0)mu -= a[i - k];
			rin -= a[i - k];
			if (a[i] > 0)mu += a[i];
			rin += a[i];
		}
		if (i > k - 2) {
			ans = max({ ans,ta + rin - mu,ta - mu });
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main(){
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	if (K % 2 == 1){
		cout << B - A << endl;
	}
	else{
		cout << A - B << endl;
	}

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n ;
const int mxN=1000,M=1e9+7;
string s[mxN];
int W;
long long dp[mxN][mxN];
int main(){
	cin >> n >> W ;
	for(int i=0 ; i<n ;i++)
	cin >> s[i];
	dp[0][0]=1;
	for(int i=0; i< n ;++i){
	 for(int j=0 ;j< W ;++j){
	    if(i>0)
	    dp[i][j]+=dp[i-1][j];
	    
	    if(j>0)
	    dp[i][j]+=dp[i][j-1];
	    
	    dp[i][j]%=M;
	    if(s[i][j]=='#')
	    dp[i][j]=0;
	  } 
	}
    cout << dp[n-1][W-1];
}

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

using namespace std;

int main(){

	int num;
	double weight,length;
	char ch;

	vector<int> v;
	while(cin>>num>>ch>>weight>>ch>>length){
		if((weight/(length*length))>=25.0){
			v.push_back(num);
		}
	}
	for(int i= 0; i < v.size(); i++)
		cout<<v[i]<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n)    for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define _for(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define ALL(x)      begin (x), end (x)
#define FOR(...)    _for (__VA_ARGS__)
using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  int y, m, d;
  char dummy;
  cin >> y >> dummy >> m >> dummy >> d;

  size_t ans = 0;
  array <const char *, 2> table = {"TBD", "Heisei"};
  if (y < 2019)
  {
    ans = 1;
  }
  else if (y == 2019)
  {
    if (m < 4)
    {
      ans = 1;
    }
    else if (m == 4)
    {
      if (d <= 30)
      {
        ans = 1;
      }
    }
  }
  cout << table [ans] << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Stack;
import java.util.Scanner;
import java.util.Queue;

/**
 * @author yoshikyoto
 */



class Main{
	static final boolean DEBUG = false;
	static Scanner sc = new Scanner(new InputStreamReader(System.in));
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String args[]) throws Exception{
		int[] m = new int[10];
		for(int i = 0; i < 10; i++) m[i] = readInt();
		Arrays.sort(m);
		for(int i = 0; i < 3; i++) p(m[9-i]);
	}

	public static String readLine() throws IOException{return br.readLine();}
	public static int readInt(){return sc.nextInt();}
	public static void pa(Object[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(int[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(double[] arr){System.out.println(Arrays.toString(arr));}
	public static void pa(boolean[] arr){System.out.println(Arrays.toString(arr));}
	public static void p(Object o){System.out.println(o.toString());}
	public static void d(Object o){if(DEBUG)System.out.println(o.toString());}
	public static int[] parseInt(String[] arr){
		int[] res = new int[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Integer.parseInt(arr[i]);
		return res;
	}
	public static int parseInt(Object o){return Integer.parseInt(o.toString());};
}

class MyHashMap<E> extends HashMap<E, Integer>{
	ArrayList<E> keyArray = new ArrayList<E>();
	public void add(E key){add(key, 1);}
	public void add(E key, Integer value){
		if(containsKey(key)){
			value += get(key);
		}else{
			keyArray.add(key);
		}
		put(key, value);
	}
}

Measured memory_bytes: 17208
#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(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int 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;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


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,m;
int s[2010],t[2010];
ll dp[2010][2010];

ll cong[2010][2010];
int main(){
	cin>>n>>m;
	REP(i,n)cin>>s[i];
	REP(i,m)cin>>t[i];
	dp[0][0]=(s[0]==t[0])?1:0;
	for(int i=1;i<n;i++){
		dp[0][i]=dp[0][i-1]+((t[0]==s[i])?1:0);
	}
	for(int i=1;i<m;i++){
		dp[i][0]=dp[i-1][0]+((t[i]==s[0])?1:0);
	}
	
	for(int i=1;i<m;i++){
		for(int j=1;j<n;j++){
			dp[i][j]=((dp[i-1][j]+dp[i][j-1])%MOD-dp[i-1][j-1]+MOD)%MOD;
			if(t[i]==s[j])dp[i][j]=dp[i][j]+dp[i-1][j-1]+1;
			dp[i][j]%=MOD;
		}
	}
	
	cout<<(dp[m-1][n-1]+1)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 32512
N = input()

def is1974( N ):
    ans = ['1', '9', '7', '4']
    for i in ans:
        num = 0
        for n in N:
            if n == i: num += 1
        if num != 1:
            print( 'NO' )
            return
    print( 'YES' )

is1974( N )


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

// main function
int main(){
    // input
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }

    int maxv = v[1] - v[0];
    int minv = v[0];
    for(int j = 1; j < n; ++j){
        if (v[j] - minv > maxv){
            maxv = v[j] - minv;
        }
        if(minv > v[j]){
            minv = v[j];
        }
    }

    cout << maxv << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
#include <string>

using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    string a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i!=j){
                if(a[i]==a[j]){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    for(int i=0;i<n-1;i++){
        if(a[i][a[i].size()-1]!=a[i+1][0]){
           cout<<"No"<<endl;
        return 0; 
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  
  vector<int> vec;
  int now = 1;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == (char)('0' + now)) {
      cnt++;
    } else {
      vec.push_back(cnt);
      cnt = 1;
      now ^= 1;
    }
  }
  if (cnt > 0) {
    vec.push_back(cnt);
  }
  
  if (vec.size() % 2 == 0) {
    vec.push_back(0);
  }
  
  vector<ll> sum(vec.size() + 1, 0);
  for (int i = 0; i < vec.size(); i++) {
    sum[i + 1] = sum[i] + vec[i];
  }
  
  ll ans = 0;
  for (int left = 0; left < vec.size(); left+=2) {
    int right = min(left + 2 * k + 1, (int)vec.size());
    ans = max(ans, sum[right] - sum[left]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100;

int n;
char f[2 * N];

char ask(vector <int> &a){
    cout << "? ";
    for(auto &i : a) cout << i << " ";
    cout << endl;
    string ret;
    cin >> ret;
    return ret[0];
}
char ask(int x){
    if(f[x] != ';') return f[x];
    vector <int> cur;
    for(int i = x ; i < x + n ; i++){
        cur.push_back(i);
    }
    return f[x] = ask(cur);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for(int i = 0 ; i < 2 * N ; i++){
        f[i] = ';';
    }
    cin >> n;
    if(n == 1){
        vector <int> a = {1};
        char x = ask(a);
        a = {2};
        char y = ask(a);
        cout << "! " << x << y << endl;
        return 0;
    }
    int l = 1, r = n;
    while(l < r){
        int mid = (l + r + 1) / 2;
        if(ask(mid) == ask(1)) l = mid;
        else r = mid - 1;
    }
    vector <int> impartial;
    l++;
    for(int i = l ; i < l + n - 1 ; i++){
        impartial.push_back(i);
    }
    string ans(2 * n + 1, ';');
    for(int i = 1 ; i <= 2 * n ; i++){
        if(i < impartial[0] || i > impartial.back()){
            impartial.push_back(i);
            ans[i] = ask(impartial);
            impartial.pop_back();
        }
    }
    vector <int> impartial2;
    int cnt_r = 0, cnt_b = 0;
    for(int i = 1 ; i <= 2 * n ; i++){
        if(ans[i] == ';') continue;
        if(ans[i] == 'R'){
            if(cnt_r < n / 2){
                impartial2.push_back(i);
                cnt_r++;
            }
        }
        if(ans[i] == 'B'){
            if(cnt_b < n / 2){
                impartial2.push_back(i);
                cnt_b++;
            }
        }
    }
    for(auto &i : impartial){
        impartial2.push_back(i);
        ans[i] = ask(impartial2);
        impartial2.pop_back();
    }
    cout << "! ";
    for(int i = 1 ; i <= 2 * n ; i++){
        cout << ans[i];
    }
    cout << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b;return true;} return false;}
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b;return true;} return false;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main() {
  ll n, x;
  cin >> x >> n;
  vll p(n);
  vin(p);
  vll count(102, 0);
  vrep(i, p) count.at(i)++;
  ll ans = 0;
  rep(i, 0, 102){
    if(count.at(i) == 0){
      if(abs(ans - x) > abs(i - x)) ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.*;

/**
 * Copyright © 2018 Chris. All rights reserved.
 *
 * @author Chris
 * 2018/7/5 22:51
 */
public class Main {

    final static int MOD = 1000000007;
    static Scanner sc;

    private static int comb(int n, int m) {
        return 1;
    }

    static void getDiv(Map<Integer, Integer> map, int n) {
        int sqrt = (int) Math.sqrt(n);
        for (int i = sqrt; i >= 2; i--) {
            if (n % i == 0) {
                getDiv(map, i);
                getDiv(map, n / i);
                return;
            }
        }
        map.put(n, map.getOrDefault(n, 0) + 1);
    }

    @SuppressWarnings("unchecked")
    private static void solve() {
        int n = nextInt();
        double t = nextInt();
        double a = nextInt();
        int idx = 1;
        double min = 10000;
        for (int i = 1; i <= n; i++) {
            double h = nextInt();
            double val = Math.abs(a - (t - h * 0.006));
            if (val < min) {
                idx = i;
                min = val;
            }
        }
        System.out.println(idx);
    }

    static long gcd(long a, long b) {
        if (a < b) {
            a ^= b;
            b ^= a;
            a ^= b;
        }
        while (b != 0) {
            long tmp = a % b;
            a = b;
            b = tmp;
        }
        return a;
    }

    public static void main(String args[]) {
        sc = new Scanner(System.in);
        solve();
    }

    private static int nextInt() {
        return sc.nextInt();
    }

    private static long nextLong() {
        return sc.nextLong();
    }

    private static String next() {
        return sc.next();
    }

    private static double nextDouble() {
        return sc.nextDouble();
    }
}

Measured memory_bytes: 22228
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string s, t;
string S, T;
vector<string> vecs, vect;

int main(void)
{
	while(1){
		cin >> s;
		if(s == ".") break;
		cin >> t;
		
		S = "", T = "";
		vecs.clear(), vect.clear();
		{
			bool in = false;
			string buf;
			for(int i = 0; i < s.size(); i++){ 
				if(s[i] == '\"'){
					S += s[i];
					if(in){
						vecs.push_back(buf);
						buf = "";
						in = false;
					}
					else in = true;
				}
				else if(in){
					buf += s[i];
				}
				else S += s[i];
			}
		}
		{
			bool in = false;
			string buf;
			for(int i = 0; i < t.size(); i++){ 
				if(t[i] == '\"'){
					T += t[i];
					if(in){
						vect.push_back(buf);
						buf = "";
						in = false;
					}
					else in = true;
				}
				else if(in){
					buf += t[i];
				}
				else T += t[i];
			}
		}
		
		if(S != T){
			cout << "DIFFERENT" << endl;
			continue;
		}
		if(vecs.size() != vect.size()){
			cout << "DIFFERENT" << endl;
			continue;
		}
		int cnt = 0;
		for(int i = 0; i < vecs.size(); i++){
			if(vecs[i] != vect[i]) cnt++;
		}
		if(cnt == 0){
			cout << "IDENTICAL" << endl;
		}
		if(cnt == 1){
			cout << "CLOSE" << endl;
		}
		if(cnt >= 2){
			cout << "DIFFERENT" << endl;
		}
	}
	
	return 0;
}


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

#define ll long long
const int N=1e5+5;
int cnt[N];
int main() {
    ll ans=0ll;
    int n,q;
    cin>>n;
    for(int i=1; i<=n; ++i) {
        int x;
        cin>>x;
        ans+=x;
        cnt[x]++;
    }
    cin>>q;
    for(int i=1; i<=q; ++i) {
        int x,y;
        cin>>x>>y;
        if(x<=y) {
            int d=y-x;
            ans+=d*cnt[x];
            cnt[y]+=cnt[x];
            cnt[x]=0;
        } else {
            int d=x-y;
            ans-=d*cnt[x];
            cnt[y]+=cnt[x];
            cnt[x]=0;
        }
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int x[5];

    for (int i = 0; i < 5; ++i) {
        cin >> x[i];
    }

    for (int i = 0; i < 5; ++i) {
        if (x[i] == 0) {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n==22)
        cout<<"Christmas Eve Eve Eve"<<endl;
    if(n==23)
    cout<<"Christmas Eve Eve"<<endl;
    if(n==24)
        cout<<"Christmas Eve"<<endl;
    if(n==25)
        cout<<"Christmas"<<endl;
    return 0;
}


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

N = int(input())
H = []
h = input().split()

for i in range(N):
    h_n = int(h[i])
    H.append(h_n)

ans = 1
for j in range(1,N):
    if all([H[j] >= H[k] for k in range(0,j)]):
        ans += 1

print(ans)
    


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var input = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
            var n = input[0];
            var m = input[1];

            Console.WriteLine(n * 1 / m);
        }
    }
}

Measured memory_bytes: 13396
fn main() {
    let strings={
        let mut strings=String::new();
        std::io::stdin().read_line(&mut strings).unwrap();
        strings.trim_end().to_owned()
    };
    let mut wstrings=strings.split_whitespace();
    let distance:f32=wstrings.next().unwrap().parse().unwrap();
    let estimate_time:f32 = wstrings.next().unwrap().parse().unwrap();
    let speed:f32=wstrings.next().unwrap().parse().unwrap();
    if distance/speed<=estimate_time
    {
        println!("Yes");
    }
    else{
        println!("No");
    }
}

Measured memory_bytes: 2164
N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]

# dp[i][j] i日目にjを選んだ場合の幸福度
dp = [[0]*3 for _ in range(N+1)]

for i, a in enumerate(A):
  for j, h in enumerate(a):
    dp[i+1][j] = max(dp[i][(1+j)%3], dp[i][(2+j)%3]) + h
    
print(max(dp[N]))

Measured memory_bytes: 40232
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
int findSumOfDigit(int n){
    int sum = 0;
    while(n>0){
        sum+=n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int total = 0;
    rep(1,i,n+1){
        int sum = findSumOfDigit(i);
        if(a<=sum && sum<=b){
            total += i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

M1,D1 = many_int()
M2,D2 = many_int()

if M1 != M2:
    print(1)
else:
    print(0)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A,B;
  cin >> A;
  cin >> B;
  if ((A+B)%2==0) cout << (A+B)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256