akhauriyash/Code-Regression huggingface dataset:
def solve():
    A = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    B = [int(input()) for _ in range(N)]
    for b in B:
        for a in A:
            if b in a:
                a[a.index(b)] = 0

    print(judge(A))


def judge(A):
    if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
        return 'Yes'
    elif A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
        return 'Yes'
    elif A[0][0] == 0 and A[1][0] == 0 and A[2][0] == 0:
        return 'Yes'
    elif A[0][1] == 0 and A[1][1] == 0 and A[2][1] == 0:
        return 'Yes'
    elif A[0][2] == 0 and A[1][2] == 0 and A[2][2] == 0:
        return 'Yes'
    for i in range(3):
        if A[i].count(0) == 3:
            return 'Yes'
    return 'No'




if __name__ == '__main__':
    solve()


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

vector<P> bridges;
vector<ll> ans;


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

    cout << (s.compare( "2019/04/30") <= 0 ? "Heisei" : "TBD") << endl;

}



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

int main() {
  int A1, A2, A3;
  int sum;
  
  cin >> A1 >> A2 >> A3;
  sum = A1 + A2 + A3;
  
  if (sum >= 22) 
    cout << "bust" << endl;
  else
    cout << "win" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 507;
int dist[N][N];

vector <ii> v = { {0, -1}, {0, 1}, {-1, 0}, {1, 0} };
bool bad[N][N];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            dist[i][j] = min(min(i, j), min(n - i - 1, n - j - 1));
            bad[i][j] = 1;
        }   
    }   

    int ans = 0;
    for (int t = 0; t < n * n; ++t) {
        int who;
        cin >> who;
        --who;

        int i = who/n;
        int j = who%n;

        bad[i][j] = 0;
        ans += dist[i][j];
        queue <ii> q;
        q.push(mp(i, j));
        while (q.size()) {
            auto p = q.front(); q.pop();
            int i = p.f, j = p.s;            
            for (auto e : v) {
                int x = i + e.f, y = j + e.s;
                if (0 <= x && x < n && 0 <= y && y < n && dist[i][j] + bad[i][j] < dist[x][y]) {
                    dist[x][y] = dist[i][j] + bad[i][j];
                    q.push(mp(x, y));
                }
            }   
        }
    }   
    cout << ans << endl;
}

Measured memory_bytes: 5872
#include <iostream>

int main()
{
    // ある家同士の距離が最も長いところを避けて真っ直ぐ
    using namespace std;

    int k, n, f = 0, a;

    cin >> k >> n;
    //cout << k << " " << n << endl;

    int h[n];

    // 最初の1つだけ手動
    cin >> h[0];

    for(int i = 1; i < n; i++)
    {
        cin >> h[i];

        if (h[i] - h[i-1] > f)
        {
            f = h[i] - h[i-1];
        }
    }

    if (h[0] + k - h[n - 1] > f)
    {
        f = h[0] + k - h[n - 1];
    }

    a = k - f;
    cout << a << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    int N; cin >> N;
    vector < int > a(N + 1);
    REP(i,N) cin >> a[i + 1];

    vector < int > ans(N + 1, 0);

    for (int i = N; i >= 1; i--) {
        int sum = 0;
        for (int j = i; j <= N; j += i) {
            sum += ans[j];
        }
        if (a[i] != sum % 2) {
            ans[i] = 1;
        }
    }

    vector < int > M;
    for (int i = 1; i <= N; i++) {
        if (ans[i] > 0) M.push_back(i);
    }    

    cout << M.size() << endl;
    REP(i,M.size()) cout << M[i] << endl;

    return 0;
}


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

int zz[100005],n;
char dat[100005];

bool check(){
	if(!((dat[0]=='x')==zz[1]^zz[n-1]^zz[0])) return false;
	if(!((dat[n-1]=='x')==zz[n-2]^zz[n-1]^zz[0])) return false;
	return true;
}

int main(){
	scanf("%d%s",&n,dat);
	
	dat[0];
	
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			zz[1]=i;
			zz[0]=j;
			for(int k=1;k<n-1;k++)
				zz[k+1]=zz[k-1]^zz[k]^(dat[k]=='x');
			if(check()){
				for(int k=0;k<n;k++) printf("%c",zz[k]?'W':'S');
				return 0;
			}
		}
	}
	
	printf("-1\n");
	return 0;
} 

Measured memory_bytes: 768
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
from functools import reduce

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

a.sort()

count = Counter(a)

b = [1]*(max(a) + 1)

for aa in a:
    for j in range(2*aa,len(b), aa):
        b[j] = 0

c = 0
for d in count.items():
    if d[1] == 1 and b[d[0]] == 1: c += 1

print(c)

Measured memory_bytes: 38680
struct MP {
    next: Vec<i32>,
}

impl MP {
    fn new(s: &Vec<usize>) -> MP {
        let n = s.len();
        let mut next = Vec::with_capacity(n + 1);
        next.push(-1);
        let mut j = -1;
        for i in 0..n {
            while j >= 0 && s[i] != s[j as usize] {
                j = next[j as usize];
            }
            j += 1;
            next.push(j);
        }

        MP { next }
    }
}

fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let a: Vec<usize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };
    let b: Vec<usize> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let c: Vec<usize> = {
        let mut c = Vec::with_capacity(n * 2);
        for i in 0..(n * 2) {
            c.push(a[i % n] ^ a[(i + 1) % n]);
        }
        c
    };
    let d: Vec<usize> = {
        let mut d = Vec::with_capacity(n);
        for i in 0..n {
            d.push(b[i % n] ^ b[(i + 1) % n]);
        }
        d
    };

    let mp = MP::new(&d);
    
    let mut i = 0;
    for j in 0..(c.len() - 1) {
        while i >= 0 && c[j] != d[i as usize] {
            i = mp.next[i as usize];
        }
        i += 1;
        if i == n as i32 {
            let k = j - (n - 1);
            println!("{} {}", k, a[k] ^ b[0]);
            i = mp.next[i as usize];
        }
    }
}

Measured memory_bytes: 12644
#include<cstdio>
#define MAXN 100005
int n,x,l[MAXN];
int gcd(int a,int b){
	if(b==0) return a;
	int ret=gcd(b,a%b);
	return ret;
}
int abs(int a){
	if(a<0)
		a=-a;
	return a;
}
int main(){
	int a,ans;
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		l[i]=abs(x-a);
	}
	ans=gcd(l[1],l[2]);
	for(int i=3;i<n;i++)
		ans=gcd(ans,l[i]);
	printf("%d\n",ans);
}

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

int main(){ 
  ll n, k;
  cin >> n >> k;
  cout << min(n % k, abs(n % k - k)) << endl;
  return 0;
} 

Measured memory_bytes: 256
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 {
		MyScanner sc = new MyScanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		int c=0;
		for(int i=0; i<n-1; i++) {
			if(x-a[i]>=0) {
				x-=a[i];
				c++;
			}
		}
		if(x==a[n-1]) c++;
		System.out.println(c);
 	}
	
	static void printArray(int[] a) {
		int n=a.length;
		for(int i=0; i<n; i++) {
			if(i==0) System.out.print(a[i]);
			else System.out.print(" "+a[i]);
		}
		System.out.println();
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s) 
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		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 double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef double db;
typedef pair<int,int> pii;
const int mod = 1e9 +7;
const int win[7] = {0, 1, 0, 1, 1, 1, 1};
void q(void)
{
	cout << 1 << endl;
}

void solve()
{
	ll x;
	cin >> x;
	for(ll i=-500; i<=500; i++)
		for(ll j=i+1; j<=500; j++)
			if(j*j*j*j*j - i*i*i*i*i == x)
				{
					cout << j << " " << i << endl;
					return;
				}
}
int main()
{
		solve();
}

Measured memory_bytes: 3556
def bubble_sort(card_list):
    # フラグを使わないので、card_list がどの程度ソート済みかに
    # 関わらず、常に N ^ 2 のオーダーになる。
    for i in range(len(card_list)):
        for j in range(len(card_list)-1, i, -1):
            if int(card_list[j][1]) < int(card_list[j-1][1]):
                card_list[j-1], card_list[j] = card_list[j], card_list[j-1]

def selection_sort(card_list):
    for i in range(len(card_list)):
        minj = i
        for j in range(i+1, len(card_list)):
            if int(card_list[j][1]) < int(card_list[minj][1]):
                minj = j
        
        if minj != i:
            card_list[minj], card_list[i] = card_list[i], card_list[minj]


def is_stable(before, after):
    """ソートが安定だったかどうかを判定する。

    ソート前と後のリスト in, out をとる。リスト中に全く同じカードはないと仮定している。
    """
    for i in range(len(before)):
        for j in range(i+1, len(before)):
            for a in range(len(after)):
                for b in range(a+1, len(after)):
                    if before[i][1] == before[j][1] and before[i] == after[b] and before[j] == after[a]:
                        return False

    return True



N = int(input())
orig_card_list = input().split()

b_card_list = orig_card_list.copy()
s_card_list = orig_card_list.copy()

bubble_sort(b_card_list)
selection_sort(s_card_list)

print(*b_card_list)
if is_stable(orig_card_list, b_card_list):
    print('Stable')
else:
    print('Not stable')

print(*s_card_list)
if is_stable(orig_card_list, s_card_list):
    print('Stable')
else:
    print('Not stable')


Measured memory_bytes: 5620
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
s = input()

s = s[::-1]

ans = []
ima = 0
while ima != n:
    flag = False
    for i in range(m):
        tmp = m - i
        if ima + tmp > n:
            continue
        elif s[ima+tmp] ==str(1):
            continue
        else:
            ima += tmp
            ans.append(tmp)
            flag = True
            break
    if flag == False:
        print(-1)
        exit()  

print(*ans[::-1])



Measured memory_bytes: 6304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int count = 0;
        int ans = 0;
        for(int i=1;i<=n;i=i+2){
            for(int j=1;j<=i;j++){
                if((i % j) == 0){
                    count++;
                }
            }
            if(count == 8){
                ans++;
            }
            count = 0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100100100;
const int MOD=(int)1e9+7;
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)

int main(){
    int n;
    cin>>n;
    string s;
    set<string>S;
    for(int i=0; i<n; i++){
        cin>>s;
        S.insert(s);
    }
    cout<<S.size()<<endl;
}

Measured memory_bytes: 19236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  map<string,int> s;
  int mx=0;
  rep(i,n){
    string str;cin>>str;
    if(s.find(str)!=s.end()){
      s[str]++;
      mx=max(mx,s[str]);
    }else{
      s[str]=0;
    }
  }
  vector<string> ans;

  for(auto it=s.begin();it!=s.end();++it){
    if(it->second==mx){
      ans.push_back(it->first);
    }
  }
  sort(all(ans));
  for(auto it=ans.begin();it!=ans.end();++it){
    cout<<*it<<endl;
  }
  return 0;
}

Measured memory_bytes: 28020
import java.util.Scanner;

//解説を参考した
public class Main{

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

        final int H = sc.nextInt();
        final int W = sc.nextInt();
        final int K = sc.nextInt();

        String[] s = new String[H];

        for(int i = 0; i < H; i++) s[i] = sc.next();

        int ans = 0;
        for (int is = 0; is < (1 << H); is++) {
            for (int js = 0; js < (1 << W); js++) {

                int count = 0;
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        //マスが消されているならcontinueする
                        if (((is >>> i) & 1) > 0)
                            continue;
                        if (((js >>> j) & 1) > 0)
                            continue;
                        if (s[i].charAt(j) == '#')
                            ++count;
                    }
                }
                if (count == K) ++ans;

            }
        }

        System.out.println(ans);
    }

}


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

int main() {
   string S;
   cin >> S;
   if (S[0]=='R'&&S[1]=='R'&&S[2]=='R') cout << 3 << endl;
   else if ((S[0]=='R'&&S[1]=='R')||(S[1]=='R'&&S[2]=='R')) cout << 2 << endl;
   else if ((S[0]=='R'||S[1]=='R'||S[2]=='R')||(S[0]=='R'&&S[2]=='R')) cout << 1 << endl;
   else cout << 0 << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}

class Dice
{
public:
  int top,front,right;
  Dice(){top=1;front=2;right=3;}
  void setDice(int t,int f,int r){top=t;front=f;right=r;}
  void North(){setDice(front,7-top,right);}
  void East(){setDice(7-right,front,top);}
  void West(){setDice(right,front,7-top);}
  void South(){setDice(7-front,top,right);}
  void Right(){setDice(top,right,7-front);}
  void Left(){setDice(top,7-right,front);}
};

int main()
{
  int n;
  string s;
  while(cin >> n,n)
  {
    Dice d;
    int ans = 1;
    REP(i,n)
    {
      cin >> s;
      switch (s[0]) {
        case 'N':
        d.North();
        break;
        case 'E':
        d.East();
        break;
        case 'W':
        d.West();
        break;
        case 'S':
        d.South();
        break;
        case 'R':
        d.Right();
        break;
        case 'L':
        d.Left();
        break;
      }
      ans += d.top;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3124
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

type pair struct {
	x int
	y int
}

func average(pairs []pair) float64 {
	n := len(pairs)
	maxEdg := float64(calcEdgeNum(n - 1))
	allPaternNum := float64(calcFactorial(n))
	lengths := calcLengths(pairs)
	var sum float64 = 0
	num := allPaternNum * float64(n-1) / maxEdg
	for _, l := range lengths {
		sum += l * num
	}
	return sum / allPaternNum
}

func calcFactorial(n int) int {
	r := 1
	for i := 2; i <= n; i++ {
		r = r * i
	}
	return r
}

func calcEdgeNum(n int) int {
	r := 1
	for i := 2; i <= n; i++ {
		r = r + i
	}
	return r
}

func calcLengths(pairs []pair) []float64 {
	n := len(pairs)
	maxEdg := calcEdgeNum(n - 1)
	ls := make([]float64, maxEdg)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			maxEdg--
			ls[maxEdg] = calcLength(pairs[i], pairs[j])
		}
	}
	return ls
}

func calcLength(from, to pair) float64 {
	xx := from.x - to.x
	yy := from.y - to.y
	return math.Sqrt(float64(xx*xx + yy*yy))
}

func main() {
	n := nextInt()
	pairs := make([]pair, n)
	for i := 0; i < n; i++ {
		pairs[i] = pair{nextInt(), nextInt()}
	}
	r := average(pairs)
	fmt.Println(r)
}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

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

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y)
{
  x+=y;
  if (x>=mod)
    return x-mod;
  return x;
}
inline int sub(int x,int y)
{
  x-=y;
  if (x<0)
    return x+mod;
  return x;
}
inline int mul(int x,int y)
{
  return (x*1ll*y)%mod;
}
inline int power(int x,int y)
{
  int ans=1;
  while(y)
    {
      if (y&1) ans=mul(ans,x);
      x=mul(x,x);
      y>>=1;
    }
  return ans;
}
inline int inv(int x)
{
  return power(x,mod-2);
}
inline int gcd(int x, int y)
{
  return(y!=0)?gcd(y, x%y):x;
}

/*------------CODE-----------*/

int main()
{
  IOS;
  int n;
  cin >> n;
  cout << setprecision(10) << fixed << 2*PI*n << endl;
  return 0;
}


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

int main() {

	int N;
	cin >> N;

	int d[2][100];
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++) {
			cin >> d[i][j];
		}
	}

	int maxv = 0;

	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j <= i; j++) sum += d[0][j];
		for (int j = i; j < N; j++) sum += d[1][j];
		maxv = max(maxv, sum);
	}

	cout << maxv << endl;
}

Measured memory_bytes: 256
import sys

N,K = map(int,input().split())

ans = []

for i in range(N-1):

    i += 2

    ans.append([1,i])

nsum = (N-1)*(N-2) // 2

if K == 0:
    print ( N * (N-1) //2 )
    for i in range(1,N+1,1):
        for j in range(i+1,N+1,1):
            print (i,j)
    sys.exit()

if K > nsum:
    print (-1)
    sys.exit()

for i in range(2,N+1,1):

    for j in range(i+1,N+1,1):

        if nsum == K:
            print (len(ans))
            for x,y in ans:
                print (x,y)
            sys.exit()

        ans.append([i,j])
        nsum -= 1

        
            


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

int main() {
  int a,b,c,k; cin >> a >> b >> c >> k;
  int x = max({a,b,c});
  rep(i,k) x *= 2;
  cout << a + b + c + x - max({a,b,c});
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    // calculation
    int lower = max(a, c), upper = min(b, d);
    cout << max(0, upper - lower) << "\n";
    
    return 0;
}


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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}



#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define  MAX              100007




int dp[100002];



int main()
{	
	
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n=Int;

    int arr[n+1];

    For(n) arr[i]=Int;

    dp[0] = 0;
    dp[1] = abs(arr[0]  - arr[1]);

    for(int i = 2;i<n;i++)
    {
    	dp[i]=min(dp[i-1]+abs(arr[i-1]- arr[i]) , dp[i-2]+abs(arr[i-2]- arr[i]) );
    }

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




Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc162/tasks/abc162_d

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 4000;

int N;
char S[N_MAX + 1];

ll rc, gc, bc;
ll ec;

map<char, int> mp{ {'R', 1}, {'G', 2}, {'B', 4} };

void solve() {
  rc = gc = bc = ec = 0;
  REP(i, N) {
    if (S[i] == 'R') rc++;
    if (S[i] == 'G') gc++;
    if (S[i] == 'B') bc++;
    FOR(j, i + 1, N - 1) {
      int k = 2 * j - i;
      if (k >= N) continue;
      if ((mp[S[i]] | mp[S[j]] | mp[S[k]]) == 7) ec++;
    }
  }
  // printf("%lld %lld %lld %lld\n", rc, gc, bc, ec);
  ll ans = rc * gc * bc - ec;
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  scanf("%s", S);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int a[105];
    cin>>n;
    double sum=0;
    for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
    sum/=n;
    double mi=1e9;
    int ans;
    for(int i=0;i<n;i++)
        if(fabs(a[i]-sum)<mi) mi=fabs(a[i]-sum),ans=i;
        cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)

typedef long long ll;
typedef unsigned long long ull;

int main(){
  ios_base::sync_with_stdio(0);
  int q;
  while(cin >> q, q != -1){
    double ans = q / 2.0;
    while(100000 * fabs(pow(ans, 3) - q) >= q){
      ans = ans - (pow(ans, 3) - q) / (3 * pow(ans, 2));
    }
    printf("%.6f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1240
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  n,k = list(map(int,input().split()))
  #a = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = n
  zen = n
  count = 0
  lis = []
  
  if k == 1:
    print(0)
  elif n <= abs(n-k):
    print(n)
  else:
    ans = n % k
    if ans > 2:
      while 1:
        hi = abs(ans-k)
        if hi < zen:
          zen = hi
          ans = hi

        else:
          print(ans)
          exit()
    else:
      print(ans)
    
      
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
import java.util.ArrayDeque

fun main(args: Array<String>) {
    val INF = 1000000000
    val (H, W) = readInputLine().split(" ").map { it.toInt() }
    
    val map = Array(H) { readInputLine().toCharArray() }
    val dist = Array(H) { IntArray(W) { 1000000000 } }
    var maxDist = 0
    
    val queue = ArrayDeque<Pair<Int, Int>>()
    
    for (i in 0 until H) {
        for (j in 0 until W) {
            if (map[i][j] == '#') {
                dist[i][j] = 0
                queue.add(Pair(i, j))
            }
        }
    }

    while (!queue.isEmpty()) {
        val (y, x) = queue.poll()!!
        
        val nowDist = dist[y][x]
        
        if (nowDist > maxDist) {
            maxDist = nowDist
        }
        
        for (i in -1..1) {
            if (y + i < 0 || y + i >= H) {
                continue
            }
            for (j in -1..1) {
                if (x + j < 0 || x + j >= W) {
                    continue
                }
                if ((i == 0 && j == 0) || (i * j != 0)) {
                    continue
                }
                
                if (nowDist + 1 < dist[y + i][x + j]) {
                    dist[y + i][x + j] = maxDist + 1
                    queue.add(Pair(y + i, x + j))
                }
            }
        }
    }
    
    println(maxDist)
}

fun readInputLine(): String {
    return readLine()!!
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli a , b ;
    cin >> a >> b ;
    cout << (a != b ? max(a , b) * 2 - 1 : a + b) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def slove():
    n, q = map(int,input().split())
    tree = [ [] for _ in range(n) ]
    for _ in range(n-1):
        a, b = map(int,input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    score = [0]*n
    for _ in range(q):
        a, b = map(int,input().split())
        score[a-1] += b
    dfs(0,-1,tree,score)
    #print(score)
    print(" ".join(str(_) for _ in score))



def dfs(me,parent,tree,score):
    for child in tree[me]:
        if child == parent:
            continue
        score[child] += score[me]
        dfs(child,me,tree,score)

if __name__ == "__main__":
    slove()

Measured memory_bytes: 232224
<?php
$a = explode(" ",fgets(STDIN));
$n = $a[0];
$k = $a[1];
$h = [];

for($i=0;$i<$n;$i++){
	fscanf(STDIN,"%d",$h[$i]);
}
sort($h);
$ans = 10000000000;
for($u=0;$u<=$n-$k;$u++){
	$ans1 = $h[$u+$k-1]-$h[$u];
	$ans = $ans>$ans1?$ans1:$ans;
}
echo $ans;

Measured memory_bytes: 18932
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  printf("%s\n", (a % 3 == 0 || b % 3 == 0 || ((a + b) % 3 == 0)) ? "Possible" : "Impossible");
  return 0;
}


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

#define mp make_pair
#define pb push_back
#define p push

#define FOR(a, c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) (1e5+5)

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector <vector<int>> vvi;
typedef vector<long long> vl;
typedef vector <pair<int, int>> vpi;
typedef vector <pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <vi> graph;

int k = 5;

int main (){
    IOS
    ll n ;
    cin >>n;
     int cc =1,count =0;
    for (int cur ,i = 0; i <n ; ++i) {
        cin>>cur;
        if ( cur == cc){
            count++;
            cc++;
        }
    }
    if(count == 0){
        cout <<-1;
        return 0;
    }

    cout << (n-count );

    return 0;
}

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

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
typedef long long ll;

/* 2017/01/21 問題 -----  ABC044 D /Link http://abc043.contest.atcoder.jp/tasks/arc059_b */
/* -----解説等-----
問題: 文字列 t について、t の長さが 2 以上であり、かつ t の中の文字のうち過半数が同じ文字であるとき、t をアンバランスであると呼ぶことにします。
例えば、voodoo や melee はアンバランスであり、noon や a はアンバランスではありません。

小文字のアルファベットからなる文字列 s が与えられます。
s にアンバランスな (連続する) 部分文字列が存在するか判定してください。
存在する場合は、s の中でそのような部分文字列が存在する位置を一つ示してください。

制約
2≦|s|≦105
s は小文字のアルファベットのみからなる。

出力
s にアンバランスな部分文字列が存在しない場合は、-1 -1 と出力せよ。
s にアンバランスな部分文字列が存在する場合は、そのような部分文字列の一つを sa,sa+1,…sb (1≦a<b≦|s|) として、a b と出力せよ。
そのような部分文字列が複数存在する場合は、いずれも正解とみなされる。



*/

string S;

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

    cin >> S;

    FOR(i, 1, S.size()) {
        if (S[i - 1] == S[i]) {
            cout << i << " " << i + 1 << endl;
            return 0;
        }
        else if (i > 1) {
            if (S[i - 2] == S[i]) {
                cout << i - 1 << " " << i + 1 << endl;
                return 0;
            }
        }

    }
    cout << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;
ll dp[10005]; // dp[i] := HPをi減らす時の最小の魔力消費量
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll H,N;
    cin >> H >> N;
    vector<ll> A(N),B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    rep(i,1e4+5)dp[i] = 1e18;
    dp[0] = 0;
    rep(a,1e1){
        for(int j=0;j<=1e4;j++){
            rep(i,N){
                if(j-A[i]>=0)dp[j] = min(dp[j],dp[j-A[i]]+B[i]);
            }
        }
    }
    ll ans = 1e18;
    for(int i=1e4+4;i>=H;i--){
        ans = min(ans,dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
function main(input) {
  const input_numbers = input.split(' ')
  const a = parseInt(input_numbers[0], 10)
  const b = parseInt(input_numbers[1], 10)

  if ((a * b) % 2 === 0) {
    console.log('Even') 
  } else {
    console.log('Odd')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main()
{
  int n;
  cin>>n;
  if(n==0){
  cout<<"0"<<endl;
  return 0;
  }
  vector<int> v(n);
  for(int&x: v)
  cin>>x;

  vector<int> dp(n);
  dp[0]=0;
  dp[1]=abs(v[1]-v[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


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

dic = {}
for i in range(1, n+1):
    dic[i] = -1

for i in range(m):
    s, c = map(int, input().split())
    if dic[s] == -1:
        dic[s] = c
    else:
        if dic[s] != c:
            print(-1)
            exit()

if m == 0:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    elif n == 3:
        print(100)
    exit()

if n > 1 and dic[1] == 0:
    print(-1)
    exit()
elif n > 1 and dic[1] == -1:
    print(1, end="")
else:
    print(dic[1], end="")

for i in range(2, n+1):
    if dic[i] == -1:
        print(0, end="")
    else:
        print(dic[i], end="")
print()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

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

  vector<int> a = {A, B, C};
  sort(all(a));

  int ans = a[2] - a[1];
  a[0] += ans;
  ans += (a[2] - a[0] + 1) / 2 + ((a[2] - a[0]) & 1);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
  string s;
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  for(int i = 0; i < n-1; i++) {
    if(a[i] == a[i+1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  
  cout << "YES" << endl;

}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n=0,a=0,b=0;
	int sum=0;
	string A,B;
	cin>>n;
	for (int i = 0; i < n; ++i) {
		cin>>A>>B;
		if(A==B){
			a++;b++;
		}else if(A<B){
			b+=3;
		}else{
			a+=3;
		}
	}
	cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 3208
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

ll f(ll n){
	if(n==1)return 1;
	return n*f(n-1)%MOD;
}

int main(void){
	ll N,x,k=0,ans=1;
	stack<ll> S;
	cin>>N;
	rep(i,N){
		cin>>x;
		k++;
		if(x>=k*2-1){
		}else{
			ans=ans*k%MOD;
			// cout<<ans<<endl;
			k--;
		}
	}
	if(k>0)ans=ans*f(k)%MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

S = sorted(set(list(input())))

ans = 'None'
for keyword in list("abcdefghijklmnopqrstuvwxyz"):
    hit = False
    for s in S:
        if s == keyword:
            hit = True
            break 
    
    if hit == False:
        ans = keyword
        break

print(ans)



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

int main() {
  int n;
  cin>>n;
  int ans[4] = {0,0,0,0};
  for(int i=0; i<n; i++) {
    string s;
    cin>>s;
    if(s=="AC") ans[0]++;
    else if(s=="WA") ans[1]++;
    else if(s=="TLE") ans[2]++;
    else ans[3]++;
  }

  cout<<"AC x "<<ans[0]<<endl;
  cout<<"WA x "<<ans[1]<<endl;
  cout<<"TLE x "<<ans[2]<<endl;
  cout<<"RE x "<<ans[3]<<endl;

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,ans;
vector<ll>cm;
int main(void){
	cin>>n;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			cm.PB(i);
			if(n/i!=i)cm.PB(n/i);
		}
	}
	for(int i=0;i<cm.size();i++){
		ll x=cm[i]-1;
		if(x!=0&&n/x==n%x)ans+=x;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}



int main(){
	ll n,x,t;
	cin>>n>>x>>t;
	if(n%x) cout<<(n/x + 1)*t<<endl;
	else cout<<(n/x)*t<<endl;

	
	
}
		 

Measured memory_bytes: 3620
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		// Input Example:
		//
		// N M
		// K1 A11 A12 ... A1k1
		// K2 A21 A22 ... A2k2
		// .
		// .
		// .
		// KN AN1 AN2 ... ANkN

		Scanner sc = new Scanner(System.in);
		// N people
		int N = sc.nextInt();
		
		// get two integers separated with half-width break
		// M kinds of foods
		int M = sc.nextInt();

		// int A[][] = new int[N][M]; 

		// Ki: the number of foods person i+1 like
		int K;

		// map[M]: the table of the likeness of each foods 
		int map[] = new int[M];

		for (int i=0; i<N; i++)
		{
			K = sc.nextInt();
			for (int j=0; j<K; j++)
			{
				int K_temp;
				K_temp = sc.nextInt();
				map[K_temp-1]++;
			}
		}

		int ans = 0;
		for (int i=0;i<M;i++)
		{
			if (map[i] == N)
			{
				ans++;
			}
		}
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 25172
import heapq
N,M = map(int,input().split())
days = [[] for _ in range(M + 1)]
for n in range(N):
	a,b = map(int,input().split())
	if a > M:
		continue
	days[a].append(-b)

total_reward = 0
q = []
for day in range(M + 1):
	this_day = days[day]
	for reward in this_day:
		heapq.heappush(q,reward)
	if len(q):
		total_reward -= heapq.heappop(q)
print(total_reward)

Measured memory_bytes: 17604
#include<stdio.h>
int main(void) {
	int m[10000];
	int f[10000];
	int r[10000];
	char kekka[10000];
	int total[10000];
	int i;
	int t;
	int k;

	for (i = 1; i <= 10000; i++) {
		scanf("%d %d %d", &m[i], &f[i], &r[i]);
		if ((m[i] == -1) && (f[i] == -1) && (r[i] == -1))break;
	}
	
	for (t = 1; t <= 10000; t++) {
		if (i == t)break;
		total[t] = m[t] + f[t];
		if ((m[t] == -1) || (f[t] == -1)) {
			kekka[t] = 'F';
		}
		else if (total[t] >= 80) {
			kekka[t] = 'A';
		}
		else if (total[t] >= 65) {
			kekka[t] = 'B';
		}
		else if (total[t] >= 50) {
			kekka[t] = 'C';
		}
		else if (total[t] >= 30) {
			if (r[t] >= 50) {
				kekka[t] = 'C';
			}
			else {
				kekka[t] = 'D';
			}
		}
		else {
			kekka[t] = 'F';
		}
	}
	for (k = 1; k <= 10000; k++) {
		if (i == k)break;
		printf("%c\n",kekka[k]);
	}

	return 0;
}

Measured memory_bytes: 624
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

def gcd(u,v):
    while v:
        u,v=v,u%v
    return u

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

g=0
for i in a:
    g=gcd(i,g)

if k%g or k>max(a): print("IMPOSSIBLE")
else: print("POSSIBLE")


Measured memory_bytes: 59504
import sys
 
if __name__ == '__main__':
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
 
    D = {}
    for i in cmds:
        if i[0] == "i":
            D[i[7:]] = 1
        elif i[0] == "f":
            if i[5:] in D:
                print("yes")
            else:
                print("no")

Measured memory_bytes: 137772
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int b0 = 0, b1 = 0, b2 = 1;
        int max = 1;
        int prev = sc.nextInt();
        for (int i = 1; i < N; i++) {
            int x = sc.nextInt();
            if (x != prev) {
                b2++;
            } else {
                int len = b0 + b1 + b2;
                if (max < len) max = len;
                b0 = b1;
                b1 = b2;
                b2 = 1;
            }
            prev = x;
        }
        int len = b0 + b1 + b2;
        if (max < len) max = len;
        System.out.printf("%d\n", max);
    }
}

Measured memory_bytes: 69780
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) throws Exception {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		int count = 0;
		for(int i=0; i<input.length(); i++) {
			if(input.charAt(i) == '1') count++;
		}
		System.out.println(count);
		br.close();
		
	}

}


Measured memory_bytes: 21332
#include<iostream>
#include<vector>
#define rep(i, a, n) for(long int i = a; i < n; i++)
using namespace std;
int main(){
  long int n, m = 0;
  cin >> n;
  long int a[n];
  vector<int> v(100000, 0);
  
  rep(i, 0, n){
    cin >> a[i];
    m += a[i];
    v[a[i]]++;
  }
  
  long int q;
  cin >> q;
  
  rep(i, 0, q){
    long int b, c;
    cin >> b >> c;
    long int d = c - b;
    cout << m + d * v[b] << "\n";
    m += d * v[b];
    v[c] += v[b];
    v[b] = 0;
  }
}

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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  ::cout << (int)floor(sqrt(n))*(int)floor(sqrt(n))<< std::endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*cout <<"Debug"
cout <<x-30<<' '<<y-30<<endl;*/
vector<string>v;
vector<int>ansl;
string s;
int ary[100005] = {0};
int lst[200][200];
int cnt = 0;
int d_x[] = {1, 1, 0, -1, -1, 0};
int d_y[] = {1, 0, -1, -1, 0, 1};
int t;
/*
void dfs(int x,int y,int lpcnt){
  mp[x][y] = 1;
  cout <<"Debug ";
  cout <<x-30<<' '<<y-30<<endl;
  cnt++;
  lpcnt++;
  int watasi = lpcnt;
  int used[6] = {0};
  for(int dx = 0;dx<6;dx++){
    int nx = x+d_x[dx],ny = y+d_y[dx];
    int dft = sqrt((nx-30)*(nx-30)+(ny-30)*(ny-30));
    if((dft<=30)&&(watasi < t)&&(mp[nx][ny] == 0)){
        dfs(nx,ny,watasi);
        used[dx] = 1;
    }
    for(int i = 0;i<6;i++){
      if(used[i]){
        if((nx == x + d_x[i])&&(ny == y + d_y[i])){
          dfs(nx,ny,watasi);
        }
      }
    }
    }
}
*/
int main(){
  int N;

  cin >>N;
  while(N != 0){
    int num = 1,flg = 0 ,ans = 0;
    int roueied[101] = {1000};
    for(int i = 0;i<200;i++){
      for(int j = 0;j<200;j++){
        lst[i][j] = 1000;
      }
    }
    for(int i = 1;i<=N;i++){
      int M;
      cin >>M;
      lst[i][0] = M;
      for(int j = 1;j<=M;j++){
        cin >>lst[i][j];
      }
    }

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

    for(int i = 1;i<=N;i++){
      if(lst[i][0] < k)continue;

      int visited[101];
      for(int j = 0;j<k;j++){
        visited[j] = 1;
      }

      for(int j = 1;j<=lst[i][0];j++){
        for(int z = 0; z < k ; z++){
          if(lst[i][j] == roueied[z]){
            visited[z] =  0;
          }

        }
      }
      
        if((accumulate(visited,visited+k,0) == 0 )&&(flg == 1)){
          ans = -1;
          break;
        }
        if(accumulate(visited,visited+k,0) == 0){
          flg = 1;
          ans = i;
        }

      }
      if((ans == -1)||(flg == 0)){
        ans = -1;
    }
    ansl.push_back(ans);
    cin >>N;
  }


  for(int i = 0;i<(int)ansl.size();i++){
    cout <<ansl[i]<<endl;
  }
  return 0;
}



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

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

int main() {
    string w;
    cin >> w;
    int cnt[26];
    for (int i = 0; i < 26; i++) {
        cnt[i] = 0;
    }
    for (int i = 0; i < w.size(); i++) {
        cnt[w[i] - 'a']++;
    }
    
    for (int i = 0; i < 26; i++) {
        if (cnt[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 384
<?php

$n = 0;
fscanf(STDIN, "%d", $n);

/*
$a = array();
for ($i = 0; $i < $n; $i++) {
  fscanf(STDIN, "%d", $a[$i]);
}
*/
$a = explode(' ', trim(fgets(STDIN)));

$sum_bunshi = 0;
for ($i = 0; $i < $n; $i++) {
  $data = 1 / $a[$i];
  $sum_bunshi += $data;
}

echo 1 / $sum_bunshi;


Measured memory_bytes: 5240