akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = int(1e9) + 7;

int n, a, b, c;
int f[200005], rf[200005];
int pa[200005], pb[200005];

int binPow(int a, int p) {
    LL res = 1;
    while (p) {
        if (p & 1) {
            res = res * a % MOD;
        }
        p >>= 1;
        if (p) {
            a = (LL)a * a % MOD;
        }
    }
    return (int)res;
}

int inv(int a) {
    return binPow(a, MOD - 2);
}

void init() {
    f[0] = 1;
    for (int i = 1; i < 200005; ++i) {
        f[i] = (LL)f[i - 1] * i % MOD;
    }
    forn(i, 200005) {
        rf[i] = inv(f[i]);
    }
    pa[0] = pb[0] = 1;
    pa[1] = (LL)a * inv(a + b) % MOD;
    pb[1] = (LL)b * inv(a + b) % MOD;
    for (int i = 2; i < 200005; ++i) {
        pa[i] = (LL)pa[i - 1] * pa[1] % MOD;
        pb[i] = (LL)pb[i - 1] * pb[1] % MOD;
    }
}

int C(int n, int k) {
    return (LL)f[n] * rf[k] % MOD * rf[n - k] % MOD;
}

int main() {
    cin >> n >> a >> b >> c;
    init();
    int preA = 0, preB = 0;
    int ans = 0;
    for (int i = n; i < 2 * n; ++i) {
        int curA = (LL)C(i, n) * pa[n] % MOD * pb[i - n] % MOD;
        int curB = (LL)C(i, n) * pb[n] % MOD * pa[i - n] % MOD;
        preA = (LL)preA * pb[1] % MOD;
        preB = (LL)preB * pa[1] % MOD;
        ans = (ans + (LL)i * ((LL)curA - preA + (LL)curB - preB)) % MOD;
        if (ans < 0) {
            ans += MOD;
        }
        preA = curA;
        preB = curB;
    }
    ans = (LL)ans * 100 % MOD * inv(a + b) % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define int long long
#define d lld
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

main() {
    int i,j;
    int N,X,T;

    cin >> N >> X >> T;
    int ans = ( N / X + ( N % X > 0 ) ) * T;
    printf("%lld\n", ans);
    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
int a[300001][2];
int main()
{
    int n, mi = 1 << 30;
    char inp;
    scanf("%d\n", &n);
    for(int i = 1; i <= n; ++i)
    {
        scanf("%c", &inp);
        if(inp == 'E')
        {
            ++a[i][0];
        }
        else
        {
            ++a[i][1];
        }
        a[i][0] += a[i - 1][0];
        a[i][1] += a[i - 1][1];
    }
    for(int i = 1; i <= n; ++i)
    {
        mi = min(mi, a[i - 1][1] - a[0][1] + a[n][0] - a[i][0]);
    }
    printf("%d\n", mi);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i=0;i<N;i++) cin >> h.at(i);

    int dp[N];
    dp[0] = 0;
    for(int i=1;i<N;i++){
        int mi = 1001001001;
        for(int j=1;j<K+1;j++){
            if(i-j<0) break;
            int cost = abs(h.at(i) - h.at(i-j));
            mi = min(mi, dp[i-j]+cost);//dp[i]よりK以下だけ前の場所から移動するのにかかる最低合計コストを計算
        }
        dp[i] = mi;
    }
    cout << dp[N-1] << endl;
    return 0;
}

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

#define ll long long
#define pb push_back
#define vi vector<int>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define sizeOf(A) (sizeof(A))/(sizeof(A[0]))
#define odd(x) ((x) % (2))
#define fastio ios_base::sync_with_stdio(false), cin.tie(0);
const ll MOD = 1e9 + 7;

bool isEven (string s) {
    if (odd(s.size())) {
        return false;
    } else {
        FOR(i, 0, s.size()/2) {
            if (s[i] != s[i+s.size()/2]) {
                return false;
            }
        }
    }
    return true;
}
int main() {
    fastio;

    string s;
    cin >> s;

    s.erase(s.size()-1, 1);
    while (!isEven(s)) {
        s.erase(s.size()-1, 1);
    }
    cout << s.size() << "\n";
    return 0;
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  for (int i = 0; i < n - 1; i++) {
    ans *= (k - 1);
  }
  cout << ans * k << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
static ll INF = 1e9;

int N, M;
vector<vector<int> > vi;
vector<vector<bool> >flg;

bool djk()
{
	vector<int> cost(N, INF);
	cost[0] = 0;
	priority_queue<P, vector<P>, greater<P> >q;
	q.push(P(0, 0));
	for (; !q.empty();)
	{
		P p = q.top(); q.pop();
		int v = p.first;
		if (cost[v] < p.second)continue;
		for (auto i : vi[v])
		{
			if (flg[v][i] == true && cost[i] > cost[v] + 1)
			{
				cost[i] = cost[v] + 1;
				q.push(P(i, cost[i]));
			}
		}
	}
	for (auto c : cost)
	{
		if (c == INF)return false;
	}
	return true;
}

int main()
{
	vi = vector<vector<int> >(50);
	flg = vector<vector<bool> >(50, vector<bool>(50, false));
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++)
	{
		int f,t;
		cin >> f >> t; f--; t--;
		vi[f].push_back(t);
		vi[t].push_back(f);
		flg[f][t] = flg[t][f] = true;
	}
	int res = 0;
	for(int i=0;i<N;i++)
		for (auto j : vi[i])
		{
			flg[i][j] = flg[j][i] = false;
			if (djk() == false)res++;
			flg[i][j] = flg[j][i] = true;
		}
	cout << res/2<<endl;
}


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

public class Main{
	static void main() throws Exception{
		String s=sc.nextLine(),t=sc.nextLine().substring(0, s.length());
		pw.println(s.equals(t)?"Yes":"No");
	}
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		int tc=1;
		while(tc-->0) main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 32716
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=10101;

int main()
{
    int n,m;
    cin>>n>>m;
    int total=0;
    vector<int>a(n);
    rep(i,n)
    {
        cin>>a[i];
        total+=a[i];
    }
    int c=0;
    double j=((double)total)/(4.0*(double)m);
    rep(i,n)
    {
        if(a[i]>=j)c++;
    }
    if(c>=m)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
}

Measured memory_bytes: 888
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;
//using Graph = vector<vector<int>>;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
    int a, b;
    cin >> a >> b;
    cout << a*b << ' ' << 2*(a+b) << endl;
}
    





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

#define fi first
#define se second
#define endl '\n'
#define lc (rt<<1)
#define rc (rt<<1|1)
#define mp make_pair
#define pb push_back
#define lowbit(a) (a&(-a))
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define mst(a,v) memset(a,v,sizeof(a))
#define debug(x) cout<<#x": "<<x<<'\n';
#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

const int N=3010;
const int mod=1e9+7;
const ld PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;

template<typename T>inline void gmax(T &A,T B)
{
    (A<B)&&(A=B);
}
template<typename T>inline void gmin(T &A,T B)
{
    (A>B)&&(A=B);
}

template <class T>
inline bool re(T &ret)
{
    char c;
    int sgn;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    ret*=sgn;
    return 1;
}

ld p[N],dp[N][N];

int main()
{
#ifdef local
    //freopen("in.txt", "r", stdin);
#endif
    IOS;
    int n;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>p[i];
    dp[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        dp[i][0]=dp[i-1][0]*(1-p[i]);
        for(int j=1; j<=i; j++)
        dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
    }
    ld ans=0;
    for(int i=n; i>n-i; i--) ans+=dp[n][i];
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

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

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

int n, k;
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);

  scanf("%d%d", &n, &k);

  ll ans;

  if(k%2 == 1){
    ll d = n/k;
    ans = d*d*d;
  } else {
    ll d0 = n/k, d2 = (n/(k/2))-d0;
    ans = d0*d0*d0 + d2*d2*d2;
  }

  printf("%lld\n",ans);
}


Measured memory_bytes: 256
N,M = map(int,input().split())
s = []
for _ in range(N):
    a,b = map(int,input().split())
    s.append((a,b))
check = []
for _ in range(M):
    c,d = map(int,input().split())
    check.append((c,d))
res_list = []
for i in s:
    a = i[0]
    b = i[1]
    tmp = 1e+9
    res = 0
    for j in range(len(check)):
        c = check[j][0]
        d = check[j][1]
        ans = abs(a-c)+abs(b-d)
        if tmp > ans:
            res = j+1
            tmp = ans
    res_list.append(res)
for i in res_list:
    print(i)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

// 最大公約数を求める関数
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

int main() {

	int N;
	cin >> N;
	vector<int> A(N, 0);

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

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

	int v_gcd = A[0];
	for (int i = 1; i < N; i++) {
		v_gcd = gcd(A[i], v_gcd);
	}

	cout << v_gcd << endl;

	return 0;
}



Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <cstring>
#include <string>
#include <bitset>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef unsigned long long ull;
typedef set<int>::iterator SI;

#define st first
#define sd second
#define mkp make_pair
#define pb push_back
void wenjian(){freopen("concatenation.in","r",stdin);freopen("concatenation.out","w",stdout);}
void tempwj(){freopen("hash.in","r",stdin);freopen("hash.out","w",stdout);}
ll gcd(ll a,ll b){return b == 0 ? a : gcd(b,a % b);}
ll qpow(ll a,ll b,ll mod){a %= mod;ll ans = 1;while(b){if(b & 1)ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans;}
struct cmp{bool operator()(const pii & a, const pii & b){return a.second > b.second;}};
int lb(int x){return  x & -x;}

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 9901;
 
const int M = 10000007;
const int maxn = 1e6+5;


int main()
{
	string s,t;
	cin>>s>>t;
	int n = s.length();
	int ans =0 ;
	for (int  i= 0; i<n; i ++ )
	{
		if(s[i] != t[i])
			ans ++ ;
	}
	printf("%d\n",ans);
}

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

int main() {
    // input
    int n;
    cin >> n;
    int a[2][100];
    for(int i=0;i<n;i++){
        cin >> a[0][i];
    }
    for(int i=0;i<n;i++){
        cin >> a[1][i];
    }

    // calc
    int ans = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<n;j++){
            if(j <= i) sum += a[0][j];
            if(j >= i) sum += a[1][j];
        }
        ans = max(ans, sum);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl
 
const int INF = pow(10, 9) + 1;
const double EPS=1e-9;
const int MOD=998244353;

char m[10][10];
bool eval(int H, int W, int bit, int K) {

    int c = 0;
    rep(i, H) {
        rep(j, W) {
            if (m[i][j] == '.') continue;
            if (bit & (1<<i) || bit & (1<<(j+H))) continue;
            c++;
        }
    }
    // cout << bit << " " << c << " " <<  K << endl;
    if (c == K) return true;
    else return false;
}
 
signed main() {
    int H, W, K;
    cin >> H >> W >> K;

    rep(i, H) {
        rep(j, W) {
            cin >> m[i][j];
        }
    }

    int ans = 0;
    rep(bit, 1<<(H+W)) {
        if (eval(H, W, bit, K)) ans++;
    }

    cout << ans;

}

Measured memory_bytes: 3600
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    g = []
    for _ in range(m):
        a,_ = LI()
        c = LI()
        b = 0
        for i in c:
            b |= 1<<(i-1)
        g.append((b,a))
    B = 1<<n
    dp = [float("inf")]*B
    dp[0] = 0
    for b in range(B):
        for i,v in g:
            nb = b|i
            nd = dp[b]+v
            if nd < dp[nb]:
                dp[nb] = nd
    ans = dp[-1]
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 42584
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

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

template <class T>
void read(T &x)
{
	char ch;
	for (ch=getchar();(ch<'0'||ch>'9')&&ch!='-';) ch=getchar();
	x=0;int t=1;if (ch=='-') {ch=getchar();t=-1;}
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	x*=t;
}

int a[100010];

int main()
{
	int k;scanf("%d",&k);
	for (int i=1;i<=k;i++) scanf("%d",&a[i]);
	ll mi=2,ma=2;
	for (int i=k;i;i--)
	{
		if ((mi-1)/a[i]==ma/a[i]) {puts("-1");return 0;}
		ll l=(mi-1)/a[i]+1,r=ma/a[i];
		mi=l*a[i];ma=(r+1)*a[i]-1;
	}
	printf("%lld %lld\n",mi,ma);
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>


int main()
{
	int N;
	std::cin >> N;
	int L[110];
	int max = 0;
	for (int i = 0; i < N; i++) {
		std::cin >> L[i];
		if (L[i] > max)max = L[i];
	}
	std::string result;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += L[i];
	}

	if (sum - 2 * max > 0) {
		result = "Yes";
	}
	else {
		result = "No";
	}
	std::cout << result;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
K = int(input())
q = deque()
for i in range(1, 10):
    q.append(i)
i = 0
run = []
while i < K:
    i += 1
    x = q.popleft()
    if x % 10 != 0:
        q.append(10*x + x%10 - 1)
    q.append(10*x + x%10)
    if x % 10 != 9:
        q.append(10*x + x%10 + 1)
    run.append(x)

print(run[K - 1])


Measured memory_bytes: 22808
#include <iostream>
using namespace std;
 
int main() {
    int n,p,q,i,j = 0;;
    int a[51];
    while(1){
        cin >> n >> p;
        if(n+p == 0)break;
        q = p;
        for(i = 0;i < 51;i++)a[i] = 0;
        while(1){
            for(i = 0;i < n;i++){
                if(p > 0){
                    a[i]++;
                    p--;
                }
                else if(p == 0 && a[i] > 0){
                    p = a[i];
                    a[i] = 0;
                }
            if(a[i] == q)break;
            }
            if(a[i] == q)break;
        }
        cout << i <<endl;
    }
    return 0;
}
 

Measured memory_bytes: 1160
a = input()
length = len(a)
dame=0

for i in range(0,int(length),2):
  if a[i] == "L":
    dame += 1
    break
for i in range(1,int(length),2):
  if a[i]=="R":
    dame += 1
    break
    
if dame == 0:
  print("Yes")
else:
  print("No")
  

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

using namespace std;

int main() {
    stack<int> s1;
    stack<pair<int, int> > s2;
    char ch;
    int sum = 0;
    for (int i = 0; cin >> ch; i++) {
        if (ch == '\\') {
            s1.push(i);
        } else if (ch == '/' && s1.size() > 0) {
            int j = s1.top();
            s1.pop();
            sum += i - j;
            int a = i - j;
            while (s2.size() > 0 && s2.top().first > j) {
                a += s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while (s2.size() > 0) {
        ans.push_back(s2.top().second);
        s2.pop();
    }
    reverse(ans.begin(), ans.end());
    printf("%d\n", sum);
    printf("%d", ans.size());
    rep(i, ans.size()) printf(" %d", ans[i]);
    printf("\n");
}


Measured memory_bytes: 3336
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	
    	int sum=N*(N+1)/2;
    	
    	System.out.println(sum);
    }
}


Measured memory_bytes: 25044
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)

using namespace std;

const int mod=1e9+7;

void run();

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

signed main(){
    init();
    run();
    return 0;
}

int h,a[2000001];

void maxHeapify(int i){
    int l=i*2;
    int r=l+1;
    int largest;
    if(l<=h&&a[l]>a[i])
        largest=l;
    else
        largest=i;
    if(r<=h&&a[r]>a[largest])
        largest=r;
    if(largest!=i){
        swap(a[i],a[largest]);
        maxHeapify(largest);
    }
}

int extract(){
    if(h<1)return -inf;
    int m=a[1];
    a[1]=a[h];
    h--;
    maxHeapify(1);
    return m;
}

void increaseKey(int i,int k){
    if(k<a[i])return;
    a[i]=k;
    while(i>1&&a[i/2]<a[i]){
        swap(a[i],a[i/2]);
        i/=2;
    }
}

void insert(int k){
    h++;
    a[h]=-inf;
    increaseKey(h,k);
}

void run(){
    while(true){
        string s;
        cin>>s;
        if(s=="end")break;
        if(s=="insert"){
            int k;
            cin>>k;
            insert(k);
        }
        else if(s=="extract"){
            cout<<extract()<<endl;
        }
    }
}


Measured memory_bytes: 10936
/*
 * ----------------------------------------------------------------------------
 (: Bismillahir Rahmanir Rahim :) 
 * File: /root/Programming/Atcoder/B_Homework.cpp
 * Project: /root/Programming/Atcoder
 * Created Date: Sunday, April 19th 2020, 6:07:52 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Sun Apr 19 2020
 * Modified By: Grim Firefly :)
 * -----
 * ----------------------------------------------------------------------------
 */







//Code Start
#include <bits/stdc++.h>
using namespace std;

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;
typedef set<int> seti;
typedef set<ll> setl;
typedef queue<int> qui;
typedef deque<int> dqui;

//Debug Setting up
#define watch(x) cout<< (#x)<<" is "<<x<<endl
#define watchara(wow)  for(auto x:wow) cout<<x<<" "


//defining something
#define SZ 10000

//main function start

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

    int n,m;
    scanf("%d %d",&n,&m);
    int sum=0;
    int num;
    for (int i = 0; i < m; i++)
    {
        scanf("%d",&num);
        sum+=num;
    }
    cout<<max(-1,n-sum)<<endl;

    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

int main() {
    long long a = 0, b = -1;
    string s;
    cin >> s;
    s.push_back('3');
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
            a++;
        } else {
            if (a > b) {
                b = a;
            }
            a = 0;
        }
    }
    cout << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std; 
  
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

const int N=1e5+1000; 
int n,m;
int a[N],tmp[N];
pii P[N];
 
int found(int x) 
{
	if (tmp[x]==x) return x;
	else return tmp[x]=found(tmp[x]);
}
 
int main() 
{
	int ans=0;
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=m;i++) cin>>P[i].first>>P[i].second;
	for (int i=1;i<=n;i++) tmp[i]=i;
	for (int i=1;i<=m;i++) 
	{
		tmp[found(P[i].first)]=tmp[found(P[i].second)];
	}
	for (int i=1;i<=n;i++) 
	{
		if (found(i)==found(a[i])) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

    vector <int> t(N);
    for(int i = 0; i < N; i++){
        cin >> t[i];
    }

    int blank = 0;
    for(int i = 0; i < N-1; i++){
        int tmp = (t[i+1]) - (t[i]);
        if(tmp > T){
            blank += (t[i+1]) - ((t[i]) + T);
        }
    }

    int X = (t[N-1] + T) - blank;
    cout << X << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <vector>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <cctype>
#include <queue>
#include <algorithm>
#include <memory>
#include <memory.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;

bool can[1000001];

int main(){
	int n, a, b;
	while(cin >> n >> a >> b && (a || b || n)){
		fill(can, can + 1000001, false);
		queue<int> que;
		can[0] = true;
		que.push(0);
		while(!que.empty()){
			int c = que.front();
			que.pop();
			if(a + c <= n && !can[a+c]){
				can[a+c] = true;
				que.push(a+c);
			}
			if(b + c <= n && !can[b+c]){
				can[b+c] = true;
				que.push(b+c);
			}
		}
		int count = 0;
		for(int i = 0; i <= n; i++){
			if(!can[i]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1892
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n,k;cin>>n>>k;
  vl h(n);
  rep(i,n)cin>>h[i];
  sort(h.begin(),h.end());
  ll MIN=INF;
  rep(i,n-k+1){
    //cout<<i+k-1<<" "<<i<<endl;
    MIN=min(MIN,h[i+k-1]-h[i]);
  }
  cout<<MIN<<endl;
}

    

Measured memory_bytes: 1024
(defparameter *n* (read))

(defparameter *intervals*
  '((100 . 111)
    (112 . 222)
    (223 . 333)
    (334 . 444)
    (445 . 555)
    (556 . 666)
    (667 . 777)
    (778 . 888)
    (889 . 999)))

(defun f (n intervals)
  (cdar (remove-if-not (lambda (pair) (<= (car pair) n (cdr pair)))
                       intervals)))

(princ (f *n* *intervals*))

Measured memory_bytes: 10724
#include <bits/stdc++.h>
using namespace std;
int main(){

  int N;
  cin>>N;
   int sum=0;
 for(int i=0;i<N;i++){
 int l,r;
   cin>>l>>r;

   sum=sum+(r-l+1);
 }
   
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

signed main()
{
  int n, i;
  cin >>n >> i;

  cout << n - i + 1 << endl;

  return 0;
}



Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func floatSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	x := 1
	ans := 0
	for _, v := range a {
		if x == v {
			x++
		} else {
			ans++
		}
	}
	if ans == n {
		ans = -1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5016
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  char n;
  cin >> n;

  if (n >= 'A' && n <= 'Z') {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
}


Measured memory_bytes: 3632
import java.util.*;class Main{public static void main(String[]z){int i,j,k,c,t,b;Scanner s=new Scanner(System.in);for(;(t=s.nextInt())>0;System.out.println(b))for(b=i=0;i++<t;)for(j=i+2;j<=t;b+=c==t?1:0,j++)for(c=0,k=i;k<j;k++)c+=k;}}

Measured memory_bytes: 12000
d, g = map(int, input().split())
g //= 100
p = [0] * d
c = [0] * d
for i in range(d):
    p[i], c[i] = map(int, input().split())
    c[i] //= 100
ans = 10000000
for i in range(1 << d):
    s = set()
    use = 0
    res = 0
    for j in range(d):
        if i >> j & 1:
            use += p[j]
            res += p[j] * (j + 1) + c[j]
            s.add(j)
    for j in range(d - 1, -1, -1):
        if res >= g:
            break
        if j in s:
            continue
        use += min(p[j], (g - res + j) // (j + 1))
        res += min(p[j], (g - res + j) // (j + 1)) * (j + 1)
    if res >= g:
        ans = min(ans, use)
print(ans)


Measured memory_bytes: 73628
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    vector<int> A;
    for (int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());

    if ((A[0] == A[1] && A[1] != A[2]) || A[0] != A[1] && A[1] == A[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
    ll A;
    cin >> A;
    string B_str;
    cin >> B_str;
    ll B100 = 100 * int(B_str[0] - '0') + 10 * int(B_str[2] - '0') + int(B_str[3] - '0');
    cout << A * B100 / 100 << endl;
    return 0;
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;

int main(){
  int n;
  cin >> n;
  vector<int> p(n),q(n),a(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> q.at(i);
  }
  for(int i=0;i<n;i++){
    a.at(i) = i+1;
  }
  int count,aa,b;
  do{
    bool flaga = true;
    bool flagb = true;
    for(int i=0;i<n;i++){
      if(a.at(i) != p.at(i)){
        flaga = false;
      }
    }
    for(int i=0;i<n;i++){
      if(a.at(i) != q.at(i)){
        flagb = false;
      }
    }
    if(flaga) aa = count;
    if(flagb) b = count;
    count++;
  }while(next_permutation(a.begin(),a.end()));
  cout << abs(b-aa) << endl;
}

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

int main() {
  long long int L, R;
  cin >> L >> R;
  
  long long int ans = 2020;
  if (R/2019 == L/2019) {
   for (long long int i = L; i < R; ++i) {
     for (long long int j = i+1; j <= R; ++j) {
        ans = min(ans, (i * j) % 2019); 
     }
   }
  }
  else {
    ans = 0; // どちらか片方が割り切れる 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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


fn main() {
    input! {
        r: u64,
    }
    println!("{}", 3 * r.pow(2))
}


Measured memory_bytes: 4352
N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
for i in range(N - 1, -1, -1):
  ai = A[i]
  for j in range(i, N, i + 1):
    ai ^= B[j]
  B[i] = ai
print(sum(B))
if sum(B):
  print(' '.join([str(i + 1) for i in range(N) if B[i]]))

Measured memory_bytes: 14772
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool h=true;
    if((a+b+c)%2==0) h=false;
    bool k=max({a,b,c})%2;
    if(h==k){
        cout<<(max({a,b,c})*3-a-b-c)/2<<endl;
    }else{
        cout<<(max({a,b,c})*3-a-b-c+3)/2<<endl;
    }
}

Measured memory_bytes: 256
package main

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

var dm map[int]map[int]int
var colors []int
var checked []bool

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	dm = make(map[int]map[int]int, n)
	for i := 1; i <= n; i++ {
		dm[i] = make(map[int]int)
	}

	colors = make([]int, n)
	checked = make([]bool, n)
	for i := 0; i < n-1; i++ {
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		w, _ := strconv.Atoi(sc.Text())
		dm[v][u] = w
		dm[u][v] = w
	}

	color(1, 0)

	for _, c := range colors {
		fmt.Println(c)
	}
}

func color(v, d int) {
	if checked[v-1] {
		return
	}
	colors[v-1] = d
	checked[v-1] = true
	for u, w := range dm[v] {
		if w != 0 {
			color(u, (d+w)%2)
		}
	}
}


Measured memory_bytes: 39936
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ss[] = new String[4];
    for(int i = 0;i<4;i++){
      ss[i] = s.substring(i,i+1);
    }

    String sa = s.replace(ss[0],"");
    if(sa.length() == 0){
      System.out.println("No");
      return;
    }

    int target = 0;
    for(int i = 1;i<4;i++){
      if(ss[i].equals(ss[0])){
        target = i;
        break;
      }
      if(i == 3){
        System.out.println("No");
        return;
      }
    }
    if(target == 1){
      if(ss[2].equals(ss[3])){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else if(target == 2){
      if(ss[1].equals(ss[3])){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      if(ss[1].equals(ss[2])){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, K; cin >> N >> K;
    map<ll,ll> MAP;
    rep(i,N) {
        ll A, B;
        cin >> A >> B;
        MAP[A] += B;
    }

    for (auto x : MAP) {
        K -= x.second;
        if (K <= 0) {
            cout << x.first << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4224
import  java.util.*;
class Main{
    int n;
        
    Main(){
	Scanner sc = new Scanner(System.in);
	n=sc.nextInt();
	int ans=-1000000000;
	int mini;
	mini=sc.nextInt();

	for(int i=0; i<n-1; i++){
	    int num=sc.nextInt();
	    
	    ans=max(ans,num-mini);

	    mini=min(mini,num);
	}
       
	System.out.println(ans);
    }

    int max(int a,int b){
	if(a>b)return a;
	else return b;
    }

    int min(int a,int b){
	if(a<b)return a;
	else return b;
    }





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

Measured memory_bytes: 94484
"use strict"
function main(arg) {
    var data = arg.trim().split("\n")[0].split(" ").map(Number)
    var p,q,r
    p = data[0]
    q = data[1]
    r = data[2]

    var data = [
        p + q,
        q + r,
        r + p
    ]
    console.log(Math.min(...data))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22076
import java.util.Scanner;
 
class Main {
	String s;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		s = sc.next();
	}
	void solve(){
		boolean[] c = new boolean[26];
		for(int i=0;i<s.length();i++){
			c[s.charAt(i)-'a'] = true;
		}
		for(int i=0;i<26;i++){
			if(!c[i]) {
				System.out.printf("%c\n",('a'+i));
				break;
			} else if(i==25){
				System.out.println("None");
			}
		}
	}
}

Measured memory_bytes: 24148
#include<bits/stdc++.h>
#include<unistd.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N;cin>>N;
    vector<ll> a(3*N);
    REP(i,3*N) cin>>a[i];
    sort(All(a));
    int l=0,r=3*N-1;
    ll ans=0;
    while(l<r){
        l++;
        ans+=a[r-1];
        r-=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a, b,c,d;
  
  cin >> a >> b >> c >> d ;
  
  if((a+b)==(c+d)){
  	cout << "Balanced"<< endl;
  }else if((a+b)<=(c+d)){
  	cout << "Right" << endl;
  }else{
  	cout << "Left" << endl;
  }
  
}

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

namespace _0030
{
    
    class Program
    {

        
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());

            for(int y = 0; ; y++)
            {
                if(n - 7 * y < 0)
                {
                    Console.WriteLine("No");
                    break;
                }
                if((n - 7 * y) % 4 == 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }
            }
       
        }
    }
}

Measured memory_bytes: 11092
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let x: u64 = read_as_vec()[0];

    let mut ans = (x/11)*2;

    let x = x%11;

    if 0 < x && x <= 6{
        ans += 1;
    }else if 6 < x{
        ans += 2;
    }

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


Measured memory_bytes: 4352
n, m = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
g = [[] for i in range(n)]
for i in range(m):
    a, b = (int(i) for i in input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

cnt = 0
for i in range(n):
    mx = -1
    for j in g[i]:
        mx = max(mx, h[j])
    cnt += h[i] > mx

print(cnt)


Measured memory_bytes: 92420
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b);
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

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

using namespace std;

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

    if (s[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    bool can = true;
    int cnt = 0;
    for (int i = 2; i < (s.length())-1; i++) {
        if (s[i] == 'C')
            cnt++;
    }
    if (cnt != 1) {
        cout << "WA" << endl;
        return 0;
    }

    for (int i = 1; i < s.length(); i++) {
        if (s[i] != 'C' && 0 <= s[i]-'A' && s[i]-'A' < 26) {
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 256