akhauriyash/Code-Regression huggingface dataset:
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>


using namespace std;


int main()
{
    string s,t;
    cin>>s>>t;
    if(s.size()>t.size())
    cout<<"GREATER";
    if(s.size()<t.size())
    cout<<"LESS";
    if(s.size()==t.size())
    {if(s==t)
    cout<<"EQUAL";
    if(s>t)
    cout<<"GREATER";
    if(s<t)
    cout<<"LESS";} 

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



struct Combinations {
  static int num;
  vi fact,factr,inv;

  Combinations(int num) {

    fact.assign(num+1,0);
    factr.assign(num+1,0);
    inv.assign(num+1,0);
    inv[1]=fact[0]=factr[0]=1;
    FOR(i,2,num+1) inv[i]=inv[M%i]*(M-M/i)%M;
    FOR(i,1,num+1) fact[i]=fact[i-1]*i%M,factr[i]=factr[i-1]*inv[i]%M;
  }


  int comb(int n,int c){
    if(c<0||c>n) return 0;
    return factr[c]*fact[n]%M*factr[n-c]%M;
  }

  int per(int n,int c){
    if(c<0||c>n) return 0;
    return fact[n]*factr[n-c]%M;
  }

  int hcomb(int n,int c){
    if(n==0&&c==0) return 1;
    return comb(n+c-1,c-1);
  }

};

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

  int n,k;
  cin>>n>>k;
  Combinations comb(n+k);
  cout<<comb.hcomb(n,k)<<endl;


}


Measured memory_bytes: 3256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 922337203685477580;//7;
constexpr auto mod = 1000000007;

int main() {

	double n, k;
	cin >> n >> k;
	double ans = 0;
	eFOR1(i, n) {
		int j = 0;
		double now = i, cnt = (double)1/(double)n;
		while (now < k) {
			j++;
			now *= 2;
			cnt /= 2;
		}
		ans += cnt;
	}
	printf("%.11f", ans);
}

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

int main(){
    // input
    string s;
    cin >> s;
    
    // compute
    string t;
    for (int i=0; i < s.size(); i++){
        if (i%2 == 0){
            t = t + s.at(i);
        }
    }

    // output
    cout << t << endl;
}



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

typedef long long ll;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

vector<int> grafo[MAXN];
ll dp[MAXN][2];
int N;

ll solve(int v,int c,int p){

	if(dp[v][c] != -1) return dp[v][c];

	ll tot = 1;
	for(int u : grafo[v]){
		if(u == p) continue;
		if(c == 0) tot = (tot * (solve(u,0,v) + solve(u,1,v))) % MOD;
		else tot = (tot * solve(u,0,v)) % MOD;
	}

	return dp[v][c] = tot;

}

int main(){

	memset(dp,-1,sizeof(dp));

	scanf("%d",&N);
	for(int i = 1;i<N;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
		grafo[v].push_back(u);
	}

	printf("%lld\n", (solve(1,0,-1) + solve(1,1,-1)) % MOD );

	return 0;

}


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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli lastInsert=0;
map<lli,set<lli>> d;

signed main(){

	lli n;
	cin>>n;

	lli flag[500100]={0};
	for(lli i=1;i*(i+1)/2<500100;i++){
		flag[i*(i+1)/2]=i;
	}

	if(flag[n]==0){
		cout<<"No"<<endl;
		return 0;
	}

	lli num = flag[n];
	if(DEBUG)cout<<"num="<<num<<endl;
	cout<<"Yes"<<endl;
	cout<<num+1<<endl;
	lli last=1;
	for(lli i=0;i<=num;i++){
		cout<<num<<" ";
		for(lli cnt=0;cnt<num;cnt++){
			if(d[cnt].empty()){
				for(lli j=cnt;j<num;j++){
					d[cnt].insert(last);
					cout<<last<<" ";
					last++;
				}
				break;
			}
			else{
				auto itr = d[cnt].begin();
				cout<<*itr<<" ";
				d[cnt].erase(itr);
			}
		}
		cout<<endl;
	}


	return 0;
}

Measured memory_bytes: 7680
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            int n = Integer.parseInt(br.readLine());
            st = new StringTokenizer(br.readLine());
            int[] a = new int[n];
            long sum = 0;
            HashMap<Integer, Integer> hm = new HashMap<>();
            for(int i=0 ; i<n; i++) {
                a[i] = Integer.parseInt(st.nextToken());
                sum += a[i];
                hm.put(a[i], hm.getOrDefault(a[i], 0) + 1);
            }

            int q = Integer.parseInt(br.readLine());
            while(q-->0) {
                st = new StringTokenizer(br.readLine());
                int x = Integer.parseInt(st.nextToken());
                int y = Integer.parseInt(st.nextToken());

                if(hm.containsKey(x)) {
                    int fr = hm.get(x);
                    sum -= (long)x*fr;
                    hm.remove(x);
                    hm.put(y, hm.getOrDefault(y, 0) + fr);
                    sum += (long)y*fr;
                }

                pw.println(sum);
            }
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
}


Measured memory_bytes: 58424
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int64_t n,sum=0,ma=-1000001,mi=1000001;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		sum += a;
		if(ma < a)
			ma = a;
		if(mi > a)
			mi = a;
	}
	cout << mi << ' ' << ma << ' ' << sum << endl;
}


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

int main(){
	int x, y;
	cin >> x >> y;
	for(int i = 0; i <= x; ++i){
		if(y == i * 2 + (x - i) * 4){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



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

bool ok[10];
bool g[10][10];
int n,m;

int dfs(int v){
    bool a=true;

    for(int i=0;i<n;i++){
        if(ok[i]==false) a=false;
    }

    if(a) return 1;

    int cnt=0;
    for(int i=0;i<n;i++){
        if(g[v][i]==false) continue;
        if(ok[i]) continue;
        ok[i]=true;
        cnt+=dfs(i);
        ok[i]=false;
    }
    return cnt;
}

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

    for(int i=0;i<m;i++){
        int s,t; cin>>s>>t;
        g[s-1][t-1]=g[t-1][s-1]=true;
    }
    
    ok[0]=true;
    cout<<dfs(0)<<endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;
	ll A[200005], B[200005];

	cin >> N;
	rep(i,N) cin >> A[i] >> B[i];

	bool f = true;
	rep(i,N) f &= ( A[i] == B[i] );
	if( f ){
		cout << 0 << endl;
		return 0;
	}

	ll sumA=0, sumB=0, dA=0, dB=0;
	ll mn = INF, sum = 0;
	rep(i,N){
		sum += A[i];
		if( A[i] <= B[i] ){
			sumA += A[i];
			sumB += B[i] - A[i];
		}else{
			dA += A[i] - B[i];
			dB += B[i];
			chmin(mn, B[i]);
		}
	}

	ans = sum - mn;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2432
xn = input('')
x = int(xn.split(' ')[0])
n = int(xn.split(' ')[1])
ps = list(map(int,input().split()))

max_width = 2*x

result = x
for i in range(max_width):
    x1 = x-i
    x2 = x+i
    if x1 not in ps:
        result = x1
        break
    if x2 not in ps:
        result = x2
        break

print(result)



Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int a;
    cin >> a;
    PRINT(a + a * a + a * a * a);
    return 0;
}

Measured memory_bytes: 3632
A, B, C, D = [int(i) for i in input().split()]
round = 0
# health, strength
def helper(a, b, c, d):
    global round
    round += 1
    if a<=0:
        return False
    else:
        c -= b
        return helper(c, d, a, b)
helper(A, B, C, D)
if round%2==0:print('Yes')
else:print('No')


Measured memory_bytes: 9248
#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>;
 
const int MAX_V = 50;
const int MAX_S = MAX_V*50+5;
const ll INF = 1e18;
 
struct Edge {
  int to, a, b;
  Edge(int to, int a, int b):to(to),a(a),b(b) {}
};
 
struct Data {
  int v, s;
  ll x;
  Data(int v, int s, ll x):v(v),s(s),x(x) {}
  bool operator<(const Data& a) const {
    return x > a.x;
  }
};
 
vector<Edge> g[MAX_V];
ll dist[MAX_V][MAX_S+5];
 
int main() {
  int n, m, s;
  cin >> n >> m >> s;
  rep(i,m) {
    int u,v,a,b;
    cin >> u >> v >> a >> b;
    --u; --v;
    g[u].emplace_back(v,a,b);
    g[v].emplace_back(u,a,b);
  }
  rep(i,n)rep(j,MAX_S+5) dist[i][j] = INF;
  s = min(s, MAX_S);
  priority_queue<Data> q;
  auto push = [&](int v, int s, ll x) {
    if (s < 0) return;
    if (dist[v][s] <= x) return;
    dist[v][s] = x;
    q.emplace(v,s,x);
  };
  vector<int> c(n), d(n);
  rep(i,n) cin >> c[i] >> d[i];
  push(0,s,0);
  while (!q.empty()) {
    Data hoge = q.top(); q.pop();
    int v = hoge.v, s = hoge.s;
    ll x = hoge.x;
    if (dist[v][s] != x) continue;
    {
      int ns = min(s+c[v], MAX_S);
      push(v,ns,x+d[v]);
    }
    for (Edge e : g[v]) {
      push(e.to, s-e.a, x+e.b);
    }
  }
  for (int i = 1; i < n; ++i) {
    ll ans = INF;
    rep(j,MAX_S+5) {
      ans = min(ans, dist[i][j]);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  
  string s="";
  
  for(int i=0;i<W+2;i++){
    s+="#";
  }
  
  vector<string>vec(H+2);
  for (int i=0;i<H+2;i++){
    if(i==0 || i== H+1){
      vec.at(i)=s;
    }
    else {
      string m;
      cin >> m;
      vec.at(i) ="#" + m + "#";
    }
  }
  
  for(int i=0;i<H+2;i++){
    cout << vec.at(i) <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    ll n;
    cin >> n;
    ll t = sqrt(n);
    int ans = 1000;
    for (int i = 1; i <= t; i++) {
        if (n % i == 0) {
            int j = n / i;
            int x = i;
            int digit1 = 1, digit2 = 1;
            while (x /= 10) {
                digit1++;
            }
            while (j /= 10) {
                digit2++;
            }
            ans = min(ans, max(digit1, digit2));
        }
    }
    cout << ans << endl;
}

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

a=0 
b=0

# 偶数+偶数
if n==0 or n==1: a==0
else :a=(n*(n-1))/2

if m==0 or m==1: b==0
else :b=(m*(m-1))/2

print(int(a+b))


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

#define fti(i, x, y) for(int i = (x), _y = (y); i <= _y; ++ i)
#define ftd(i, x, y) for(int i = (x), _y = (y); i >= _y; -- i)
#define ll long long

using namespace std;

double res = 0.5, n;

void inp()
{
    scanf("%lf", &n);
}

void proc()
{
    int k = n;
    if(k % 2) {
        res = (n + 1) / (2 * n);
    }
    printf("%.10lf\n", res);
}

int main()
{
    inp();
    proc();
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (h,a) = get!(usize, usize);
    if h%a  == 0 {
        println!("{}", h/a);
    } else{
        println!("{}",h/a+1);
    }
}


Measured memory_bytes: 8572
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let s=t.s()
  let ans=1000;
  for(let i=0;i<s.length-2;i++)ans=t.min(t.abs(753-Number(s[i]+s[i+1]+s[i+2])),ans)
  t.o(ans)
}
main()

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 0;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
//#define int unsigned long long
//----------------------------------------------------
string s;
int dp[300000];
int bit[1ll << 26];
signed main() {
	cin >> s;
	for (int i = 1; i < 1ll << 26; i++) {
		bit[i] = inf;
	}
	ll res = 0;
	for (int i = 0; i < s.size(); i++) {
		int t = (int)(s[i] - 'a');
		res ^= 1 << t;
		int sum = bit[res];
		for (int j = 0; j < 26; j++) {
			sum = min(sum, bit[res ^ (1 << j)]);
		}
		bit[res] = min(bit[res], sum + 1);
		dp[i] = sum + 1;
	}
	cout << dp[s.size() - 1] << endl;
}

Measured memory_bytes: 263556
l = []

for _ in range(3):
    l.append([int(x) for x in input().split()])

flag = True

v,h = [],[]

for i in range(3):
    a = l[i]
    b,c = a[0] - a[1], a[1] - a[2]
    v.append([b,c])

if v[0] != v[1] or v[1] != v[2]:
    flag = False

for i in range(3):
    a = [l[0][i], l[1][i], l[2][i]]
    b,c = a[0] - a[1], a[1] - a[2]
    h.append([b,c])

if h[0] != h[1] or h[1] != h[2]:
    flag = False

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
# ssr

s = gets.chomp
s_1 = s[0]
s_2 = s[1]
s_3 = s[2]

if s_1 == "S"
  if s_2 == "S"
    if s_3 == "S"
      puts 0
    else # s_3 = "r"
      puts 1
    end
  else # s_2 = "r"
    if s_3 == "S"
      puts 1
    else # s_3 = "r"
      puts 2
    end
  end
else # s_1 = "r"
  if s_2 == "S"
    if s_3 == "S"
      puts 1
    else # s_3 = "r"
      puts 1
    end
  else # s_2 = "r"
    if s_3 == "S"
      puts 2
    else # s_3 = "r"
      puts 3
    end
  end
end





Measured memory_bytes: 14284
#include<bits/stdc++.h>
using namespace std;
string s;
void output(int x,int y)
{
	cout<<x<<" "<<y<<endl;
	exit(0);
}
int main()
{
	cin>>s;
	for(int i=0;i<(int)s.size();i++)
	{
		if(s[i]==s[i+1])
			output(i+1,i+2);
		if(s[i]==s[i+2])
			output(i+1,i+3);
	}
	output(-1,-1);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
int n, m, k, a[N], b[N], ra[N], rb[N];
char str[N];
vector<pair<int, int> > stk, vec;
int main() {
	scanf("%d%d%d %s", &n, &m, &k, str + 1);
	for (int i = 1; i <= n; i++) a[n - i + 1] = str[i] - '0';
	scanf(" %s", str + 1);
	for (int i = 1; i <= m; i++) b[m - i + 1] = str[i] - '0';
	for (int i = max(n, m); i >= 1; i--) {
		if (a[i] + b[i] == 1) stk.push_back(make_pair(i, a[i] * 2 + b[i]));
		if (a[i] + b[i] <= 1) continue;
		int z = k, pos = i, x = 3;
		while (!stk.empty()) {
			pair<int, int> tmp = stk.back();
			if (pos == tmp.first) {
				stk.pop_back();
				if ((x ^ tmp.second) == 3) {
					x = 3;
					if (z) z--;
					else break;
				} else if (x == 3) {
					x &= tmp.second;
					vec.push_back(make_pair(pos, tmp.second ^ 3));
				}
				pos++;
			} else if (x == 3) {
				if (tmp.first - pos > z) break;
				z -= tmp.first - pos;
				pos = tmp.first;
			} else break;
		}
		if (x == 3) ra[pos + z] = rb[pos + z] = 1;
		else vec.push_back(make_pair(pos, x));
		while (!vec.empty()) {
			stk.push_back(vec.back());
			vec.pop_back();
		}
	}
	while (!stk.empty()) {
		int i = stk.back().first;
		int x = stk.back().second;
		stk.pop_back();
		ra[i] = x / 2;
		rb[i] = x % 2;
	}
	int l = max(n, m) + k;
	while (ra[l] == 0) l--;
	for (int i = l; i >= 1; i--) putchar('0' + ra[i]);
	putchar('\n');
	l = max(n, m) + k;
	while (rb[l] == 0) l--;
	for (int i = l; i >= 1; i--) putchar('0' + rb[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 34792
#(44)科目選択
a=[]
for i in range(4):
     n=int(input())
     a.append(n)
a.sort(reverse=True)
b=[]
for j in range(2):
     m=int(input())
     b.append(m)
b.sort(reverse=True)
sum=0
for k in range(3):
     u=a[(k)]
     sum+=u
B=b[0]
print(sum+B)


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

void Main()
{
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n+x-1)/x * t << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string S;
	cin >> S;
	vector<char> result;

	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'B') {
			if (result.size() > 0) {
				result.pop_back();
			}
		}
		else {
			result.push_back(S[i]);
		}
	}

	cout << string(result.begin(), result.end());
}

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

int n,m,s;
int dp[50][3001];

int main() {
  while(cin>>n>>m>>s, n|m|s) {
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    // ????????????
    for (int i=1; i<=m; ++i)
      for (int j=n*n; j>0; --j)
        for (int k=s; k>=i; --k)
          dp[j][k] = (dp[j][k] + dp[j-1][k-i])%100000;
    cout<<dp[n*n][s]<<endl;
  }
}

Measured memory_bytes: 1748
#include<bits/stdc++.h>
#define FOR0(i,n) for(int i=0;i<n;i++)
#define FOR1(i,n) for(int i=1;i<=n;i++)
#define FORl(i,l,n) for(int i=l;i<n;i++)
using namespace std;
#define pi pair<int,int>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<in>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll mod = 1e9+7;
ll power(ll num,ll g,ll mod)
{
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

  
int main() { 
    int n;
    cin >> n;
    ll arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    ll sum = 0; 
    for (int i = 0; i <= 61; i++){ 
        int zc = 0, oc = 0;  
        ll idsum = 0;  
        for (int j = 0; j < n; j++){ 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
        ll c =1;
        for (int j = 0; j < i; j++) c*=2, c%=mod;
        idsum = oc * c;
        idsum %= mod;
        idsum *= zc;
        idsum %= mod;
        sum += idsum;
        sum %= mod;  
    } 
    cout << sum;
} 

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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
void solve()
{
    string s,t; cin>>s>>t;
    ll ans=INT_MAX;
    for(int i=0;i<s.size()-t.size()+1;i++)
    {
        int c=0,k=0;
        for(int j=i;j<i+t.size();j++)
        {
           // k++;
            if(s[j]==t[k]) c++;
            k++;
        }
       // cout<<c<<"\n";
        ans=min((int)ans,(int)t.size()-c);
    }
    cout<<ans<<"\n";
}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
 //  cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 3676
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 18:07:38 2020

@author: Kanaru Sato
"""
import heapq

n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
adush = [-1*a[i] for i in range(len(a))]
heapq.heapify(adush)

for i in range(m):
    product = heapq.heappop(adush)
    product = -1*((-1*product)//2)
    heapq.heappush(adush, product)

print(-1*sum(adush))

Measured memory_bytes: 14380
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
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>())

// dp[i] := ちょうどi本のマッチ棒を使って、条件を満たす整数を作るときの最大桁数
// dp[N] := ちょうどN本のマッチ棒を使って作ることができる最大桁数 <- これが答え！
// 整数kを1桁作るのに使うマッチ棒の本数をnum(k)とすると、Aiを最上位の桁に使えることを調べるには、
// dp[N-num(Ai)] = dp[N] - 1
// dp[i] = max(0 < j < m)(dp[i-num(Aj)] + 1)

const string MINUSINF = "-";

void chmax(string &a, string b) {
  if (a == MINUSINF) a = b;
  else if (a.size() < b.size()) a = b;
  else if (a.size() == b.size()) {
    if (a < b) a = b;
  }
}

ll match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

int main() {
  int N,M; cin >> N >> M;
  vector<int> A(M);
  rep(i,M) cin >> A[i];

  rep(i,11000) dp[i] = MINUSINF;

  dp[0] = "";

  rep(i,N) {
    if (dp[i] == MINUSINF) continue;
    for (auto a : A) chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 43776
a,b,c=[0]*200,[0]*200,[0]*200
def check(a,n):
    for i in range(n-1):
        if not a[i]:continue
        t=a[i]
        for j in range(i+1,n):
            if t==a[j]:a[i],a[j]=0,0

if __name__ == '__main__':
    n=int(input())
    for i in range(n):a[i],b[i],c[i]=map(int,input().split())
    check(a,n)
    check(b,n)
    check(c,n)
    for i in range(n):print(a[i]+b[i]+c[i])

Measured memory_bytes: 7688
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	int A[2][100];
	int row0 = 0, row1 = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[0][i];
		row0 += A[0][i];
	}
	for (int i = 0; i < N; i++) {
		cin >> A[1][i];
		row1 += A[1][i];
	}

	int highest = 0;
	row0 = 0;
	for (int i = 0; i < N; i++) {
		row0 += A[0][i];
		highest = std::max(highest, row0 + row1);
		row1 -= A[1][i];
	}

	cout << highest;

	return 0;
}


Measured memory_bytes: 256
/// mAAria


#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define MAX 500000
#define K 30


signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

    int a,b,t,i=0,A=0,B=0;
    cin >> a >> b >> t;
    double T = t+0.5;
    //cout << T <<endl;
    i = T/(double)a;
    cout << b*i <<endl;




    return 0;
}

///....

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


from itertools import combinations_with_replacement
N = INT()
L = LIST()

C = Counter(L)
S = sorted(set(L))
# print(S)
# print(C)

A = list(combinations(S, 3))
# print(a)
cnt = 0
for a, b, c in A:
    if a != b != c:
        if a + b > c:
            # print(a, b, c)
            # print(c[a])
            # print(c[a])
            cnt += C[a] * C[b] * C[c]
print(cnt)

# cnt = 0
# p = 0
# for idx in range(len(S)-1):
#     p = 0
#     while p + idx != len(S) - 1:
#         s_num = c[S[idx]]
#         min_wa = S[idx] + S[idx + p]
#         print(min_wa)
#         right = S[idx+2:]
#         print(right)
#         a = bisect_left(right, min_wa)
#         print("idx", a)
#         cnt += a * s_num
#         p += 1
# print(cnt)

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


int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) {
    cin >> l[i];
  }

  sort(l.rbegin(), l.rend());

  int ans = 0;

  rep(i, k) {
    ans += l[i];
  }

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

Measured memory_bytes: 3632
use std::io::*;
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn main() {
    let mut s = read_vec_char();
    let k = read::<usize>();
    let mut subs: Vec<Vec<char>> = vec![vec!['z','z'];5];
    let mut open: Vec<bool> = vec![false;5];
    for c in s {
        let mut cv = vec![c];
        for i in 0..4 {
            let ii = 3-i;
            if open[ii] {
                let mut tmp = subs[ii].clone();
                tmp.push(c);
                open[ii]=false;
                for j in ii+1..5 {
                    if subs[j] < tmp {
                        continue;
                    } else if subs[j] == tmp {
                        open[j]=true;
                        break;
                    } else {
                        subs.insert(j,tmp);
                        open.insert(j,true);
                        subs.pop();
                        open.pop();
                        break;
                    }
                }
            }
        }
        for i in 0..5 {
            if subs[i] < cv {
                continue;
            } else if subs[i] == cv {
                open[i]=true;
                break;
            } else {
                subs.insert(i,cv);
                open.insert(i,true);
                subs.pop();
                open.pop();
                break;
            }
        }
    }
    println!("{}",subs[k-1].iter().map(|x| *x).collect::<String>());
}


Measured memory_bytes: 4352
s = []
a = []

data = gets

data.size.times do |i|
  c = data[i]

  if s.any? && c == '/'
    x = s.pop
    y = i - x

    while a.any? && x < a.last[0]
      y += a.pop[1]
    end
    a << [x, y]
  end

  s << i if c == '\\'
end

A = a.map{ |e| e[1] }

unless A.any?
  print "0\n0\n"
  exit
end

printf "%d\n%d %s\n", A.reduce(:+), A.size, A.join(' ')

Measured memory_bytes: 9032
from bisect import bisect_right
from itertools import accumulate

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a_ac=[0]+list(accumulate(a))
b_ac=[0]+list(accumulate(b))

ans=0
for i in range(n+1):
  remain=k-a_ac[i]
  if remain<0:
    break
  t_ans=i
  t_ans+=bisect_right(b_ac,remain)-1
  ans=max(ans,t_ans)

print(ans)

Measured memory_bytes: 50720
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    ll ans = 0;
    repf(i,1,n) {
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF = 1001001001;

int main() {
	long long n;
	cin >> n;
	long long sum = 0, absmin = INF, m = 0;
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		sum += abs(a);
		if (a < 0) m++;
		if (abs(a) < absmin) absmin = abs(a);
	}
	long long ans = sum;
	if (m & 1) ans -= 2*absmin;
	cout << ans << endl;
	return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int32 n,m;
vector<vector<int32>> a;

int32 cntmax(){
    vector<pii> cnt(m);
    REP(i,m)cnt[i] = pii(0, i);
    REP(i, n){
        cnt[a[i][0]].first++;;
    }
    sort(ALL(cnt), greater<pii>());
    REP(i,n){
        a[i].erase(find(ALL(a[i]), cnt[0].second));
    }
    // cout << cnt[0].first << " " << cnt[0].second + 1 << endl;
    return cnt[0].first;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    a = vector<vector<int32>>(n, vector<int32>(m));
    REP(i,n)REP(j,m){
        cin >> a[i][j];
        a[i][j]--;
    }
    int32 ans = INF;
    REP(i,m){
        int32 mx = cntmax();
        ans = min(ans, mx);
    }
    ANS(ans);
    // ostream_iterator<int32> out_it(cout, " ");
    // copy(ALL(a[0]), out_it);
    return 0;
}

Measured memory_bytes: 1152
N = int(raw_input())
A = list(raw_input())
B = raw_input()
C = raw_input()
con = 0
for i in range(N):
  if A[i] != B[i] and B[i] != C[i] and A[i] != C[i]:
    con += 2
  elif A[i] != B[i]:
    con += 1
  elif B[i] != C[i]:
    con += 1
  elif A[i] != C[i]:
    con += 1

print con

Measured memory_bytes: 2824
x = [0]*5
y = [0]*5

x[1],y[1],x[2],y[2] = map(int, input().split() )

dx = x[2]-x[1]
dy = y[2]-y[1]

x[3] = x[2] - dy
y[3] = y[2] + dx
x[4] = x[3] - dx
y[4] = y[3] - dy

print(str(x[3]),' ',str(y[3]),' ',str(x[4]),' ',str(y[4]))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int r = scanner.nextInt();
        int g = scanner.nextInt();
        int b = scanner.nextInt();
        if ((g * 10 + b) % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21076
N, Q, *QX = map(int, open(0).read().split())

A = [N] * (N + 1)
B = [N] * (N + 1)

ans = (N - 2) ** 2
h = w = N
for q, x in zip(*[iter(QX)] * 2):
    if q == 1:
        if x < w:
            B[x:w] = [h] * (w - x)
            w = x
        ans -= B[x] - 2
    else:
        if x < h:
            A[x:h] = [w] * (h - x)
            h = x
        ans -= A[x] - 2

print(ans)

Measured memory_bytes: 37112
n,m=map(int,input().split())

memo=set()
ACcount=0
PEcount={}
for _ in range(m):
	p,s=input().split()
	if p not in memo:
		if s=="AC":
			ACcount+=1
			memo.add(p)
		else:
			if p in PEcount:
				PEcount[p]+=1
			else:
				PEcount[p]=1
count=0
for i in memo:
	if i in PEcount:
		count+=PEcount[i]
print("{} {}".format(ACcount,count))

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
vector<int> f[30];
bool memo[50][50];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, _t, _f;
    while(cin >> N && N){
        rep(i, 30) f[i].clear();
        memset(memo, 0, sizeof(memo));
        rep(i, N) memo[i][i] = true;
        rep(i, N){
            cin >> _t;
            rep(j, _t){
                cin >> _f; --_f;
                f[_f].push_back(i);
            }
        }
        rep(i, 30){
            for(int k : f[i])
              for(int l : f[i])
                rep(j, N)
                  memo[k][j] |= memo[l][j];
            for(int k : f[i])
              if(count(memo[k], memo[k] + N, 1) == N){
                  cout << i + 1 << endl;
                  goto success;
              }
        }
        cout << -1 << endl;
        continue;
      success: continue;
    }
    return 0;
}

Measured memory_bytes: 3124
X, Y = map(int, input().split())

if Y - 2*X < 0 or 4*X - Y < 0 :
    print("No")
elif (Y - 2*X) % 2 != 0 or (4*X - Y) % 2 != 0 :
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

struct scc {
    using Graph = vector<vector<int>>;
    int N;
    Graph FG, RG;
    vector<int> start;

    scc(int _N)
        : N(_N), start(_N + 1), FG(_N), RG(_N){}

    // 辺追加
    void add_edge(int u, int v) { FG[u].emplace_back(v), RG[v].emplace_back(u); }
    
    vector<vector<int>> get_scc() {
        int now_ord = 0, group_num = 0;
        vector<int> used(N), ord(N, -1), group(N, -1);

        bool sw = false;
        auto dfs = [&](auto&& dfs, int v, Graph& G) -> void {
            used[v] = 1;
            for(auto to: G[v]) {
                if (used[to]) continue;
                dfs(dfs, to, G);
            }
            if (sw) group[v] = group_num;
            else    ord[now_ord] = v, now_ord++;
        };

        // 1回目dfs
        for (int i = 0; i < N; i++) if (!used[i]) dfs(dfs, i, FG);
        sw = true;
        reverse(ord.begin(), ord.end()), fill(used.begin(), used.end(), 0);
        // 2回目dfs
        for (auto i: ord) if(group[i] == -1) dfs(dfs, i, RG), group_num++;

        vector<int> counts(group_num);
        for (auto id : group) counts[id]++;
        vector<vector<int>> groups(group_num);
        for (int i = 0; i < group_num; i++) groups[i].reserve(counts[i]);
        for (int i = 0; i < N; i++) groups[group[i]].emplace_back(i);
        for (int i = 0; i < group_num; i++) reverse(groups[i].begin(), groups[i].end());

        return groups;
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    scc G(N);

    rep(i, M){
        ll u, v;
        cin >> u >> v;
        G.add_edge(u, v);
    }

    auto ans = G.get_scc();

    cout << ans.size() << endl;
    rep(i, ans.size()){
        cout << ans[i].size();
        for(auto v: ans[i]) cout<<" " <<v;
        cout << '\n';
    }
}

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

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

  int n; cin >> n;

  ll low = 1, high = n;

  ll res = 0;
  while (low <= high) {
    ll mid = low + (high - low) / 2;
    ll x = mid * mid;

    if (x <= n) {
      res = max(res, x);
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }

  cout << res << "\n";
}


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

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

}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  getline(cin,s);
  int len = s.length();
  for(int i = 0;i<len;i++)
  {
    if(s[i]==',')
    cout<<" ";
    else
    cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 3604
from collections import Counter

n = int(input())
A = [int(x) for x in input().split()]
BC = [(int(x) for x in input().split()) for _ in range(int(input()))]
ans = sum(A)
cnts = Counter(A)
for b, c in BC:
    b_num = cnts[b]
    c_num = cnts[c]
    ans += (c - b) * cnts[b]
    print(ans)
    cnts[c] = cnts[c] + cnts[b]
    cnts[b] = 0


Measured memory_bytes: 111896
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]


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

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

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

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

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

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

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

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


#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    ($arg:expr) => (println!("{:?}",$arg));
}


#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}


use std::cmp;
use std::collections::HashMap;





fn main() {

    input! { 
       n: usize,
       m: usize,
       city :[(i64,i64);m],
    }

    let mut city = city;
    for i in 0..m{
        city[i] = (city[i].0- 1 , city[i].1);
    }

    //let mut ken : Vec<std::collections::BinaryHeap<(i64,usize)>> = vec![std::collections::BinaryHeap::new();n];
    let mut ken :Vec<Vec<(i64,usize)>>  = vec![vec![];n];

    for i in 0..m{
        let (p , y ) = city[i];
        ken[p as usize].push((y,i));
    }



    let mut ans :Vec<String>= vec![String::new();m];

    for i in 0..n{
        let mut item = &mut ken[i];
        item.sort_by(|x,y|{
            if x.0 < y.0{cmp::Ordering::Less}
            else if x.0 == y.0 { cmp::Ordering::Equal}
            else { cmp::Ordering::Greater}
        });

        for (index,&mut (y,j)) in item.into_iter().enumerate(){
            let s = format!("{0:>06}{1:>06}", (i+1) , (index+1) );
            ans[j] = s;
        }
    }
    
    for item in &ans{
        println!("{}",item);
    }


 
 
    


}


Measured memory_bytes: 24060
package main

import "fmt"

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

	op := make([]int, n)
	reds := make([]int, n)
	whites := make([]int, n)
	for i := 0; i < n; i++ {
		whites[i] = 1
		op[i] = 1
	}
	reds[0], whites[0] = 1, 0

	var x, y int
	for i := 0; i < m; i++ {
		fmt.Scan(&x, &y)
		x--
		y--
		op[x]--
		op[y]++
		if reds[x] == 1 && whites[x] == 0 {
			reds[x]--
			reds[y]++
		} else if reds[x] == 1 && whites[x] > 0 {
			reds[y] = 1
			whites[y]++
			if op[x] == 0 {
				reds[x] = 0
				whites[x] = 0
			}
		} else {
			whites[x]--
			whites[y]++
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		if reds[i] == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504