akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
 
#define X first
#define Y second
#define N 100
#define M 11
 
typedef long long ll;
const int Mod = 1000000007;
const int INF = 1 << 30;
 
const double eps = 1e-10;
 
bool Check(int a, int b, int c)
{
	if (a & 1) return false;
	if (b & 1) return false;
	if (c & 1) return false;
	return true;
 } 
 
int main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    
    int a, b, c, res = 0;
    cin >> a >> b >> c;
    
    while (Check(a, b, c))
    {
    	res++;
    	int na = (b + c) >> 1;
    	int nb = (a + c) >> 1;
    	int nc = (a + b) >> 1;
    	a = na, b = nb, c = nc;
    	if (a == b && a == c && (a % 2 == 0))
    	{
    		res = - 1;
    		break;
		}
	}
	printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
          
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , x;
    long long int b = 0;
    cin >> n >> x;
    int a[n];
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
    }
    for ( int i = 0 ; i < n - 1 ; i++ ) {
        if ( a[i] + a[i + 1] > x ) {
            int c = a[i] , d = a[i + 1];
            if ( a[i] >= x ) {
                a[i] = x;
                a[i + 1] = 0;
            } else {
                a[i + 1] = x - a[i];
            }
            b += c - a[i] + d - a[i + 1];
        }
    }
    cout << b;
}

Measured memory_bytes: 640
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let n = Array(readLine()!)
    if n[0] == "7" || n[1] == "7" || n[2] == "7" {
        print("Yes")
    } else {
        print("No")
    }
}

main()


Measured memory_bytes: 7724
N = int(input())
scores = list(int(input()) for _ in range(N))
ans = sum(scores)
if ans % 10 != 0:
    print(ans)
    exit()

scores.sort()
for score in scores:
    if score % 10 != 0:
        ans -= score
        print(ans)
        exit()
print('0')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define ll long long
using namespace std;
const int N=3005;
int n,ans,mo;
int s[N][N],c[N][N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
int ksm2(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%(mo-1))if(y&1)t=(ll)t*x%(mo-1);
	return t;
}
int main(){
	cin>>n>>mo;
	s[0][0]=1;
	fo(i,1,n){
		s[i][0]=1;
		fo(j,1,i)s[i][j]=((ll)s[i-1][j]*(j+1)+s[i-1][j-1])%mo;
	}
	
	fo(i,0,n){
		c[i][0]=1;
		fo(j,1,i)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mo;
	}
	fo(a,0,n){
		int x=ksm(2,a),y=ksm(2,ksm2(2,a)),tot=0,g=1;
		fo(i,0,n-a){
			tot=((ll)s[n-a][i]*g+tot)%mo;
			g=(ll)g*x%mo;
		}
		ans=((ll)y*tot%mo*c[n][a]*(n-a&1?-1:1)+ans)%mo;
	}
	printf("%d",(ans+mo)%mo);
}

Measured memory_bytes: 69504
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[0] + a[1]);
    }
}


Measured memory_bytes: 21844
// 動的計画法
// knapsack

#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int n_max = 100 + 5, w_max = 1e5 + 5;

int n,W;
ll w[n_max], v[n_max];

ll dp[n_max][w_max]; //[i][j]---i番目の品物の中で、重さの総和がj以下の時の価値の最大値

int main() {
  rep(i,n_max) rep(j,w_max) dp[i][j] = -1;
  cin >> n >> W;
  rep(i,n) cin >> w[i] >> v[i];
  rep(i,W+1) dp[0][i] = 0;
  rep(i, n) {
    rep(j, W+1) {
      if(w[i] > j) {
        dp[i+1][j] = dp[i][j];
      } else {
        dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j]);
      }
    }
  }
  cout << dp[n][W] << endl;
}


Measured memory_bytes: 82304
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	ll m, n, k;
	cin >> n >> m >> k;
	ll a[n];
	ll b[m];
	//int A;
	//int B;
	int max = 0;
	rep(i, n) {
		cin >> a[i];
		if (i > 0) {
			a[i] = a[i] + a[i - 1];
		}
		if (a[i] <= k && max <= i + 1) {
			max = i + 1;
			//cout << max << endl;
		}
	}
	int j = n - 1;

	rep(i, m) {
		cin >> b[i];
		if (i > 0)b[i] = b[i] + b[i - 1];
		for (; j >= 0;) {
			if (b[i] + a[j] <= k) {
				if (max <= i + j + 2) {
					max = i + j + 2;
				}
				break;
			}
			j--;
		}
		if (j < 0 && b[i] <= k ) {
		//	cout << b[i] << endl;
			if (max < i + 1) {
				
				max = i + 1;
			}
		}
	}
	cout << max << endl;;
	
	
}


Measured memory_bytes: 6316
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        es: [(usize1, usize1, usize); n - 1]
    }
    let mut t: HashMap<usize, Vec<(usize, usize)>> = HashMap::new();
    for (u, v, w) in es.iter().cloned() {
        t.entry(u).or_insert(Vec::new()).push((v, w % 2));
        t.entry(v).or_insert(Vec::new()).push((u, w % 2));
    }
    let mut ans = vec![0; n];
    dfs(0, 0, &t, &mut ans);
    for i in 0..n {
        println!("{}", ans[i]);
    }
}

fn dfs(n: usize, p: usize, t: &HashMap<usize, Vec<(usize, usize)>>, c: &mut Vec<usize>) {
    for (v, w) in t.get(&n).unwrap().iter().cloned() {
        if v == p {
            continue;
        }
        if w == 0 {
            c[v] = c[n];
        } else {
            c[v] = c[n] ^ 1;
        }
        dfs(v, n, t, c);
    }
}


Measured memory_bytes: 24008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt(),c=s.nextInt();
        System.out.println(c+" "+a+" "+b);


    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << endl;
  return 0;
}


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

using namespace std;

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

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector<int> a(n);
        rep(i, n) cin >> a[i];
        sort(a.begin(), a.end());
        int ans = a[1] - a[0];
        rep(i, n) if (i) ans = min(ans, a[i] - a[i - 1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3096
import java.util.Scanner;

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

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 24404
import java.awt.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = i;
        }

        Point[] order = new Point[m];

        for (int i = 0; i < m; i++) {
            order[i] = new Point(scanner.nextInt() - 1, scanner.nextInt() - 1);
        }

        int ans = 0;

        for (int i = 0; i < m; i++) {
            int[] copied = new int[n];
            System.arraycopy(array, 0, copied, 0, n);
            for (int j = 0; j < m; j++) {
                if (i == j) {
                    continue;
                }
                union(copied, order[j].x, order[j].y);
            }
            int v = find(copied, 0);
            for (int j = 1; j < n; j++) {
                if (v != find(copied, j)) {
                    ans++;
                    break;
                }
            }
        }

        System.out.println(ans);
    }

    public static int find(int[] tree,int idx) {
        if(tree[idx]==idx) return idx;
        else return tree[idx] = find(tree,tree[idx]);
    }

    //union idx2 tree to idx1 tree O(a(N))
    public static void union(int[] tree,int idx1,int idx2) {
        int root1 = find(tree,idx1);
        int root2 = find(tree,idx2);
        tree[root2] = root1;
    }
}

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

int main() {
    int v[32] = {1,
             1,
             1,
             2,
             1,
             2,
             1,
             5,
             2,
             2,
             1,
             5,
             1,
             2,
             1,
             14,
             1,
             5,
             1,
             5,
             2,
             2,
             1,
             15,
             2,
             2,
             5,
             4,
             1,
             4,
             1,
             51};

    int k;
    cin >> k;

    cout << v[--k] << endl;

    return 0;
}

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

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

    vector<int> a(B-A+1), amari(B-A+1);
    rep(i,B-A+1){
        a.at(i) = A + i;
    }
    rep(i,B-A+1){
        amari.at(i) = a.at(i) % K;
    }
    rep(i,B-A+1){
        if(amari.at(i) == 0){
            cout << "OK" << endl;
            return 0;
        }    
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3628
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;

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

  int N, K; cin >> N >> K;
  vi H(N); REP(i, N) cin >> H[i];

  int ans = 0;  
  REP(i, N) {
    if (H[i] >= K) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

int change(int i){
    if(i==1){
        return 9;
    }
    if(i==9){
        return 1;
    }
}
int main (){
    int n,d1,d2,d3;
    cin >>n;
    d1=n/100;
    d2=(n/10)%10;
    d3=n%10;
    d1=change(d1);
    d2=change(d2);
    d3=change(d3);
    n=100*d1+10*d2+d3;
    cout << n << endl;
}

Measured memory_bytes: 384
// author - saiku_ni_naro
// TO THE TOP

#include<bits/stdc++.h>
using namespace std;
#define F_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl '\n'
#define For(i,a,n) for(int i=(a);i<=(n);i++)
#define RFor(i,a,n) for(int i=(n);i>=(a);i--)
#define SET(a,val) memset((a),(val),sizeof((a)))
#define X first
#define Y second
#define pb push_back
#define over(v) v.begin(),v.end()
#define sz(x) (int)x.size()
#define inp(x) cin>>x;
#define oup(x) cout<<x<<endl;

const int N = 2e5 + 10;
int a[N];

void solving_problem(){
    int n; cin>>n;
    For(i,1,n) cin>>a[i];

    sort(a+1,a+n+1); reverse(a+1,a+n+1);

    int cnt = 1,Sum = 0;

    int prev = a[1];

    For(i,2,n){
        if(cnt >= n) break;

        int upto = 2;
        if(i == 2) upto = 1;

        For(j,1,upto){
            if(cnt >= n) break;
            cnt++;
            Sum += prev;
        }
        prev = a[i];
    }

    cout<<Sum<<endl;
}

signed main(){
    F_IO;


    int testcases = 1; 
    // cin>>testcases;

    For(i,1,testcases){
        // cout<<"Cases #"<<i<<": ";
        solving_problem();
    }
}

Measured memory_bytes: 5252
/*
6 5 2 5 3 2

1->6->2->5->3->2->5->3


3 2 4 1

1->3->4->1->3->4

2 3 4 5 1

1->2->3->4->5->1
*/


#include <bits/stdc++.h>

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1<<30;
const ll MOD = 1e9+7;

int main(){
	int n, a[200005], pos[200005];
	vector<int> path;
	ull k;

	bool vis[200005];

	cin>>n>>k; 

	for(int i=0;i<n;i++)
		cin>>a[i];

	memset(vis, 0, sizeof vis);

	int curr = 1;
	ull cnt = 0;
	vis[curr] = 1;
	path.pb(curr);
	pos[curr] = path.size()-1;
	
	while(true){
		curr = a[curr-1];
		if(vis[curr]){
			int idx = (k-pos[curr])%(path.size()-pos[curr]);
			while(idx<0)
				idx += path.size()-pos[curr];
			//cout<<curr<<" "<<pos[curr]<<" "<<path.size()-pos[curr]<<" "<<idx<<"\n";
			cout<<path[pos[curr]+idx]<<"\n";
			break;
		}
		else{
			vis[curr] = 1;
			path.pb(curr);
			pos[curr] = path.size()-1;
			cnt++;
			if(cnt == k){
				cout<<curr<<"\n";
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 6020
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val S = sc.next()

    val c = S.slice(2, S.length - 1) indexOf 'C'
    val ok = S(0) == 'A' && c != -1 && ((0 until S.length) forall { i =>
      if (i == 0) S(i) == 'A'
      else if (i == c + 2) true
      else 'a' <= S(i) && S(i) <= 'z'
    })

    val ans = if (ok) "AC" else "WA"

    out.println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) { f(i); i += 1 }
  }
  def rep_r(n: Int)(f: Int => Unit): Unit = {
    var i = n - 1
    while(i >= 0) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 25552
#include<iostream>
            #include<bits/stdc++.h>
            using namespace std;
            #define size 100000
            #define NUM 998244353
            #define ll long long int
             
            int main()
            {
              int n;
              string arr;
              cin>>arr;
              n=arr.length();
              bool x=true;
              for(int i=0;i<n;i++)
              {
                if(arr[i]!=arr[n-1-i])
                {
            		x=false;
                  	break;
                }
              }
               for(int i=0;i<(n-1)/2;i++)
              {
                if(arr[i]!=arr[((n-1)/2)-1-i])
                {
            		x=false;
                  	break;
                }
              }
              if(x)
                cout<<"Yes"<<endl;
              else
                cout<<"No"<<endl;
            }

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 210000
ll int inv[N],comb[N],prd[N],invprd[N];
void calc_inv(){
    inv[0]=1;
    inv[1]=1;
    rep2(i,2,N){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
void calc_product(){
    prd[0]=prd[1]=1;
    invprd[0]=invprd[1]=1;
    rep2(i,2,N-1){
        prd[i]=i*prd[i-1]%MOD;
        invprd[i]=inv[i]*invprd[i-1]%MOD;
    }
    return ;
}
ll cmb(int a,int b){
    return prd[a]*invprd[b]%MOD*invprd[a-b]%MOD;
}
ll inv2[N];
main(){
    calc_inv();
    calc_product();
    inv2[0]=1;
    rep(i,N-1){
        inv2[i+1]=inv2[i]*inv[2]%MOD;
    }
    ll ans[N];
    int b=in(),w=in();
    rep2(i,1,b+w)ans[i]=inv[2];
    ll now=0;
    rep2(i,w+1,b+w){
        now=(now+inv2[i]*cmb(i-2,w-1)%MOD)%MOD;
        //cout<<cmb(i-1,w)<<endl;
        ans[i]=(ans[i]+now)%MOD;
    }
    now=0;
    rep2(i,b+1,b+w){
        now=(now+inv2[i]*cmb(i-2,b-1)%MOD)%MOD;
        ans[i]=(ans[i]+MOD-now)%MOD;
    }
    rep2(i,1,b+w){
        cout<<ans[i]<<endl;
    }
}


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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '
#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e5+10,
         INF=1e18;
ll dp[110][MAXN],n,w;
pll a[MAXN];
int main()
{
    fast_io;
    cin>>n>>w;
    for(ll i=1;i<=n;i++){
        cin>>a[i].X>>a[i].Y;
    }
    fill(dp[0]+1,dp[0]+MAXN,INF);
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<MAXN;j++){
            if(j>=a[i].Y){
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-a[i].Y]+a[i].X);
            }
            else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    for(ll i=MAXN-1;i>=0;i--){
        if(dp[n][i]<=w) return cout<<i<<endl,0;
    }
    return 0;
}


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

using namespace std;

typedef long long li;

vector<li> a;
vector<vector<int>> e;

li dfs(int v, int p = -1)
{
    if (e[v].size() == 1)
        return a[v];
    
    li sum = 0, maxnum = 0;
    for (int u: e[v])
    {
        if (u == p) continue;
        
        li dChild = dfs(u, v);
        sum += dChild;
        maxnum = max(maxnum, dChild);
    }
    
    li paired = sum - a[v];
    //printf("at %d %lld paired, sum %lld maxnum %lld\n", v + 1, paired, sum, maxnum);
    if (paired < 0 || paired > min(sum / 2, sum - maxnum))
    {
        cout << "NO\n";
        exit(0);
    }
    
    return sum - paired * 2;
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    e.resize(n);
    a.resize(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        
        e[u].push_back(v);
        e[v].push_back(u);
    }
    
    if (n == 2)
    {
        cout << (a[0] == a[1] ? "YES\n" : "NO\n");
        return 0;
    }
    
    for (int i = 0; i < n; i++)
        if (e[i].size() > 1)
        {
            li x = dfs(i);
            if (x == 0)
                cout << "YES\n";
            else
                cout << "NO\n";
            return 0;
        }
    
    return 0;
}

Measured memory_bytes: 13184
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	a := getNextInt(scanner)
	b := getNextInt(scanner)

	ans := 0
	if a > b*2 {
		ans = a - b*2
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}


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

char f[16][16];
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

void dfs(int y, int x)
{
	f[y][x] = '0';

	for(int d=0; d<4; d++)
	{
		int nx = x+dx[d];
		int ny = y+dy[d];
		if(0<=nx&&nx<12&&0<=ny&&ny<12)
		if(f[ny][nx] == '1')
		{
			dfs(ny,nx);
		}
	}
}

int main()
{
	int c;
	while(cin >> f[0])
	{
		for(int y=1; y<12; y++)
		{
			cin >> f[y];
		}

		c=0;
		for(int y=0; y<12; y++)
		for(int x=0; x<12; x++)
		{
			if(f[y][x]=='1')
			{
				c++;
				dfs(y,x);
			}
		}
		cout << c << endl;
	}
}

Measured memory_bytes: 0
S = input()
#dp[i][four] =: i + 1番目まで見たとき,照合したケツがfourとなるものの総数
dp = [[0 for _ in range(4)] for _ in range(len(S)+1 )]
dp[0][0] = 1
mod = 10**9 + 7
for i in range(len(S)):
    if S[i] == 'A' or S[i] == '?':
        dp[i+1][1] += dp[i][0] 
        for k in range(4): dp[i+1][k] += dp[i][k]
    if S[i] == 'B' or S[i] == '?':
        dp[i+1][2] += dp[i][1]
        for k in range(4): dp[i+1][k] += dp[i][k]
    if S[i] == 'C' or S[i] == '?':
        dp[i+1][3] += dp[i][2]
        for k in range(4): dp[i+1][k] += dp[i][k]
    for k in range(4): dp[i+1][k] %= mod
print(dp[len(S)][3])


Measured memory_bytes: 27592
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=chomp(readline())
    for i in 1:3
        if n[i]=='1'
            print('9')
        elseif n[i]=='9'
            print('1')
        else
            print(n[i])
        end
    end
    print("\n")
end
main()

Measured memory_bytes: 108092
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int n;cin >> n;
    vector<lli> a(n);
    map<lli,lli>m;
    rep(i,n){
        cin >> a[i];
        m[a[i]]++;
    }
    lli left = *max_element(a.begin(),a.end());
    lli right = *min_element(a.begin(),a.end());
    m[left]--;
    m[right]--;
    vector<pair<lli,lli>> ans;
    for(auto s:m){
        if(s.first > 0){
            rep(k,s.second){
                ans.push_back(make_pair(right,s.first));
                right -= s.first;
            }
        }else {
            rep(k,s.second){
                ans.push_back(make_pair(left,s.first));
                left -= s.first;
            }
        }
    }
    ans.push_back(make_pair(left,right));
    cout << left - right << endl;
    rep(i,ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
bool dbg = false;
int N, K, a[100010], b[100010];
int c[100010];
int n[100010];
V G[100010];

int f()
{
    FOR(i, 1, N)
    {
        if ((int)G[i].size() == 1) {
            return 1;
        }
    }
}

void solve()
{
    FORR(i, 1, N)
    {
        c[i] = -1;
    }
    int t = f();
    queue<int> que;
    que.push(t);
    c[t] = K;
    while (!que.empty()) {
        int q;
        q = que.front();
        que.pop();
        for (int i = 0; i < (int)G[q].size(); i++) {
            int p = G[q][i];
            if (c[p] == -1) {
                que.push(p);
                c[p] = K - 1 - n[q];
                n[q]++;
                n[p] = 1;
            }
        }
    }
    int ans = 1;
    FORR(i, 1, N)
    {
        ans *= c[i];
        ans %= MOD;
    }
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    FORR(i, 1, N - 1)
    {
        int s, t;
        cin >> s >> t;
        G[s].pb(t);
        G[t].pb(s);
    }
    solve();
    return 0;
}


Measured memory_bytes: 9076
#include<cstdio>
int check(int x,int y,int d){int c=__builtin_ctz(d);return c&1? !(x>>(c/2)&1):!((x^y)>>(c/2)&1);}
int main()
{
    int n,d1,d2;scanf("%d%d%d",&n,&d1,&d2);
    for(int c=0,i=0;i<n+n;++i)
	for(int j=0;j<n+n;++j)
	    if(check(i,j,d1)&&check(i,j,d2))
	    {
		printf("%d %d\n",i,j);
		if(++c==n*n) return 0;
	    }
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;

int main(){
  string s;
  cin >>s;
  if (s.size()%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  rep(i,s.size()){
    if(i%2==0){//h
      if(s[i]!='h'){
        cout<<"No"<<endl;
        return 0;
      }
    
    }else{//i
      if(s[i]!='i'){
        cout<<"No"<<endl;
        return 0;
      }
      
    }
    
  }
  cout<<"Yes"<<endl;
  return 0;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define vi vector<long long int>
#define vs vector<string>
#define mii map<long long int, long long int>

void show(auto a){
  long long int i = 0;
  while(i < a.size()){
    cout<<a[i]<<" ";
    i++;
  }
  cout<<endl;
}



long long int dp[3005][3005];


int main(){
  ios_base::sync_with_stdio(false);

  long long int n; cin>>n;
  vi a(n); for(long long int i = 0; i < n; i++) cin>>a[i];

  for(long long int i = 0; i <= 3004; i++){
  	for(long long int j = 0; j <= 3004; j++){
  		dp[i][j] = 0;
  	}

  }
  //dp[l][r] = max value of X-Y for long long interval l, r

  for(long long int l = n-1; l >= 0; l--){
  	for(long long int r = 0; r < n; r++){
  		if(l == r) dp[l][r] = a[l];
  		else dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1]);
  	}
  }

  cout<<dp[0][n-1]<<endl;


}

Measured memory_bytes: 70784
#include<cstdio>
#include<algorithm>
using namespace std;
struct Node
{
	int x;
	int y;
}ans[200010];
int cmp(const Node &a,const Node &b)
{
	return a.y<b.y;
}

int main()
{
	int n,i,sum;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&ans[i].x,&ans[i].y);
	}
	sort(ans,ans+n,cmp);
	sum=0;
	for(i=0;i<n;i++)
	{
		sum+=ans[i].x;
		if(sum>ans[i].y)
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n , k , INF = 1e9+5;
    cin >> n >> k;
    vector<int> h(n+1);
    for(int i = 1 ; i <= n ; i++) cin >> h[i];
    vector<int> dp(n+1,INF);

    dp[1] = 0;
    for(int  i =  2 ; i <= n ; i++)
        for(int j = 1 ; j <= k ; j++)
            if( i -j >= 1)
                dp[i] = min(dp[i] , dp[i-j]+abs(h[i]-h[i-j]));
    cout << dp[n];


    return 0;
}


Measured memory_bytes: 4056
from scipy.optimize import*
from numpy import*
n=int(input())
x=array([list(map(int,input().split()))for _ in range(n)])
def r(a):return sqrt(square(x-a).sum(1).max())
print(minimize(r,[0,0],method="Nelder-Mead",tol=1e-8).fun)


Measured memory_bytes: 17464
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll res = 1LL;
    rep(i, 1, n+1){
        res = MUL(res, i);
    }
    cout << res << endl;

    return 0;
}


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

int main(){
	int S,a,b,c;
	cin >> S;
	a = S / 3600;
	b = (S - a * 3600)/60;
	c = S - a * 3600 - b*60;
	cout << a << ":"<< b << ":" << c << endl;
	return 0;
}


Measured memory_bytes: 3120
#include<cstdio>
#include<cstring>

char dict[50000000];

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++) {
        char com[10],str[30];
        scanf("%s%s",com,str);
        int hash = (1<<25)-1;
        hash <<= 1;
        for(int j=0; j<strlen(str); j++) {
            hash <<= 2;
            switch(str[j]) {
                case 'A':
                    hash++;
                case 'C':
                    hash++;
                case 'G':
                    hash++;
            }
        }
        hash &= (1<<25)-1;

        if(com[0] == 'i')
            dict[hash] = 1;
        else
            puts(dict[hash] ? "yes" : "no");
    }
    return 0;
}

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

int main() {
  int x;
  cin >> x;
  if (x == 0) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    long double ans1 = w / 2.0 * h;
    int ans2 = 0;
    if (x * 2 == w && y * 2 == h) ans2 = 1;
    printf("%.10Lf %d\n", ans1, ans2);
    return 0;
}


Measured memory_bytes: 256
def judgeEven(s):
  for list in s:
  	if list % 2 != 0:
  		return False

  return True
num = input()
s = input().split(" ")
s_int = [int(n) for n in s]
count = 0
while(judgeEven(s_int)):
  s_int = [i/2 for i in s_int]
  count = count + 1

print(count)


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

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

using namespace std;

int main(void){
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  vector<string> sub(k);

  for(int i = 0; i < n; i++){
    int m = i % k;
    sub[m] += t[i];
  }

  ll ans = 0;
  rep(i, k){
    string str = sub[i];
    char pre = ' ';
    rep(j, str.size()){
      if(str[j] == 'r'){
        if(pre != 'p'){
          ans += p;
          pre = 'p';
        }else{
          pre = ' ';
        }
      }else if(str[j] == 's'){
        if(pre != 'r'){
          ans += r;
          pre = 'r';
        }else{
          pre = ' ';
        }
      }else{
        if(pre != 's'){
          ans += s;
          pre = 's';
        }else{
          pre = ' ';
        }
      }
    }
  }

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

Measured memory_bytes: 5120
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int A[20];
int x[20][20], y[20][20];

int main() {
  int N;

  cin >> N;

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

  int ans = 0;

  for (int i=0; i<(1<<N); i++) {
    bool ok = true;

    for (int j=0; j<N; j++) {
      if (i & (1 << j)) {

        for (int k=0; k<A[j]; k++) {
          ok &= !!(i & (1 << x[j][k])) == y[j][k];
        }

      }
    }

    if (ok) {
      ans = max(ans, __builtin_popcount(i));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    map<string, int> mp;
    REP(i, N) {
        cin >> S;
        mp[S]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>


int main() {
#ifdef DEBUG

#endif
	char X, Y;
	scanf("%c %c", &X, &Y);
	if (X > Y) {
		printf(">\n");
	}
	else if (X < Y) {
		printf("<\n");
	}
	else {
		printf("=\n");
	}

	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;
using Complex = complex<double>;
const double PI = acos(-1);

ull gcd(ull a, ull b) {
    return (a % b ? gcd(b, a % b) : b);
}

int main() {
    ull N, M;
    cin >> N >> M;
    vector<ull> a(N);
    ull pow = 1;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
        a[i] /= 2;
    }

    ull mul = a[0];
    for (int i = 1; i < N; ++i) {
        ull g = gcd(mul, a[i]);
        mul *= (a[i] / g);
        if (!(mul / a[i] % 2)) {
            cout << 0 << endl;
            return 0;
        }
        if (M < mul) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (M + mul) / (mul * 2) << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys

N = int(input())
p_list = list(map(int,input().split()))

try:

    if sorted(p_list) == p_list:
        print("YES")
        sys.exit()

    sum = 0

    for i,j in zip(p_list,sorted(p_list)):
        if i != j:
            sum += 1

    if sum == 2:
        print("YES")
    else:
        print("NO")

except EOFError:
    pass
    

Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>

int cost[101];
int time[101];

int main(void) {

	int i, j;
	int n, Time;
	int minway;
	int mincost;
	int mintime;

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

	for (i = 0; i < n; i++) {
		scanf("%d%d", &cost[i], &time[i]);
	}//要素0からn-1に格納//

	mintime = 1001;
	mincost = 1001;

	for (i = 0; i < n; i++) {
		if (time[i] <= Time) {
			mintime = time[i];
			if (mincost > cost[i]) {
				mincost = cost[i];
			}
		}
	}

	if (mintime > Time) {
		printf("TLE\n");
	}
	else {
		printf("%d", mincost);
	}

	return 0;
}

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

const int N = 100005;

int all, k, q, r[N], t[N], a[N];
int up, down, c;
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> all >> k;
	for (int i = 1; i <= k; ++i)
		std::cin >> r[i];
	r[0] = 0, r[k + 1] = 1e9 + 1;
	std::cin >> q; int p = 0;
	for (int i = 0; i < q; ++i)
		std::cin >> t[i] >> a[i];
	up = all; int typ = 0;
	for (int i = 0; i <= k && p < q; ++i) {
		while (p < q && t[p] >= r[i] && t[p] < r[i + 1]) {
			int x = std::min(std::max(a[p] + c, down), up), d = t[p++] - r[i];
			if (typ) x = std::min(x + d, all); else x = std::max(x - d, 0);
			std::cout << x << '\n';
		}
		int d = r[i + 1] - r[i];
		if (typ) down = std::min(down + d, all), up = std::min(up + d, all), c += d;
		else down = std::max(down - d, 0), up = std::max(up - d, 0), c -= d;
		typ ^= 1;
	}
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n,m,ans,sum,temp,difff,len,test=0;
    string str;
    getline(cin,str);
    len=str.length();
    for(i=0;i<len;i=i+2)
    {
        if(str[i]=='L')
        {
            test=1;
            break;
        }
    }
    if(test==1)
    {
        cout<<"No"<<endl;
    }
    else
    {
        for(i=1;i<len;i=i+2)
        {
            if(str[i]=='R')
            {
                test=1;
                break;
            }
        }
        if(test==1)
        {
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"Yes"<<endl;
        }
    }
}


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

int main() {
  int n,x=0;
  cin >> n;
  vector<int> a(n);
  vector<int> judge(n,0);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    while(a.at(i)%2 == 0){
      ++judge.at(i);
      a.at(i) /= 2;
    }
  }

  if(n == 1){
    cout << judge.at(0) << endl;
  }else{
    int res=judge.at(0);
    for(int j=1;j<n;j++){
      res = min(res,judge.at(j));
    }
    cout << res << endl;
  }

}


Measured memory_bytes: 256