akhauriyash/Code-Regression huggingface dataset:
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (n,k) = scan "%d %d" Tuple2.make
let arr = scan_array ~sep:' ' Int.of_string

let () =
  let sets = powerset (0++^n)
             |> ListL.filter ~f:(fun l -> List.length l = k)
             |> ListL.map ~f:(List.sort Int.compare) in
  ListL.map sets ~f:(fun set ->
      ListL.fold_left (0++^n) ~init:(0, 0)
        ~f:(fun (pred, n) i ->
            if ListL.exists set ~f:((=) i) then
              if pred < arr.(i) then (arr.(i), n) else (pred+1, n + pred+1 - arr.(i))
            else
              (max pred arr.(i), n)))
  |> List.map Tuple2.second
  |> List.min
  |> Printf.printf "%d\n"


Measured memory_bytes: 6912
#include<stdio.h>
int main(){
    int n;
    int a[1000];
    int max=0;
    int min=9999;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        if(max<=a[i]){
            max=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]<=min){
            min=a[i];
        }
    }
    int x=max-min;
    printf("%d\n",x);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

long long M=0;

void calc2(int N){
  if (N==3) {
    M+=2;
  } else if (N==4) {
    M+=4;
  } else if (N%2 == 0) {
    M+=2*N -4;
    calc2(N-2);
  } else {
    M+=N-1;
    calc2(N-1);
  }
}

void calc(int N, int geta){
  int i;
  if (N==3) {
    cout << 1+geta << " " << 3 + geta << endl;
    cout << 2+geta << " " << 3 + geta << endl;
  } else if (N==4) {
    cout << 1+geta << " " << 2 + geta << endl;
    cout << 1+geta << " " << 3 + geta << endl;
    cout << 4+geta << " " << 2 + geta << endl;
    cout << 4+geta << " " << 3 + geta << endl;
  } else if (N%2 == 0) {
    for (i=0;i<N-2;++i) {
      cout << 1+geta << " " << i+2 + geta << endl;
      cout << N+geta << " " << i+2 + geta << endl;
    }
    geta++;
    calc(N-2, geta);
  } else {
    for (i=0;i<N-1;++i) {
      cout << i+1+geta << " " << N + geta << endl;
    }
    calc(N-1, geta);
  }
}

int main(){
  int i,N,geta=0;
  cin >> N;
  calc2(N);
  cout << M << endl;
  calc(N, geta);
  return 0;
}


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

int frecv[200002];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i)
    {
        int x;
        cin >> x;
        frecv[x]++;
    }

    for (int i = 1; i <= n; ++i)
        cout << frecv[i] << '\n';
}


Measured memory_bytes: 4344
# D
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=int)

count = 0
index = 1
for i in range(N):
    if A[i] == index:
        index+=1
    else:
        count+=1

if count==N:
    print(-1)
else:
    print(count)

Measured memory_bytes: 33956
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  if(A == B){
    cout << "Draw" << endl;
  }else if(A == 1){
    cout << "Alice" << endl;
  }else if(B == 1){
    cout << "Bob" << endl;
  }else if(A > B){
    cout << "Alice" << endl;
  }else if(B > A){
    cout << "Bob" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int a[SIZE][2];
VPII e[SIZE];
int an[SIZE];
void dfs(int x,int lt,int col){
    int now=1;
    REP(i,SZ(e[x])){
        int y=e[x][i].F;
        if(y==lt)continue;
        while(now==col)now++;
        dfs(y,x,now);
        an[e[x][i].S]=now++;
    }
}
int main(){
    int N;
    R(N);
    REPP(i,1,N){
        REP(j,2){
            R(a[i][j]);
        }
        REP(j,2){
            e[a[i][j]].PB({a[i][j^1],i});
        }
    }
    PII ma={0,0};
    FOR(i,1,N){
        ma=max(ma,{SZ(e[i]),i});
    }
    dfs(ma.S,ma.S,0);
    W(ma.F);
    FOR(i,1,N-1)W(an[i]);
    return 0;
}


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

typedef long long int in;

in tree[800005],dp[200005];

void update(in node,in s,in e,in ind,in val)
{
    if(s==e)
    {
        tree[node]=val;
    }
    else
    {
        in m=(s+e)/2;
        
        if(s<=ind && ind<=m)
        update(2*node,s,m,ind,val);
        else
        update(2*node+1,m+1,e,ind,val);
        
        tree[node]=max(tree[2*node],tree[2*node+1]);
    }
}

in query(in node,in s,in e,in l,in r)
{
    if(r<s||e<l)
    return 0;
    
    if(l<=s&&e<=r) 
    return tree[node];
    
    in m=(s+e)/2;
    
    in max1=query(2*node,s,m,l,r);
    in max2=query(2*node+1,m+1,e,l,r);
    
    in maxi=max(max1,max2);
    
    return maxi;
}

int main()
{
    in n,i,j;
    cin>>n;
    
    in h[n+2],v[n+2];
    
    for(i=1;i<=n;++i)
    cin>>h[i];
    
    for(i=1;i<=n;++i)
    cin>>v[i];
    
    for(i=1;i<=n;++i)
    {
        dp[i]=query(1,1,n,0,h[i]-1)+v[i];
        
        update(1,1,n,h[i],dp[i]);
    }
    
    cout<<query(1,1,n,1,n)<<"\n";
    
    return 0;
}


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

int a[105];

int main(){
    vector<int> number;
    bool salah = false;
    int N, sum = 0;
    cin >> N;
    for(int i=0; i<N; i++){
        int num;
        cin >> num;
        number.push_back(num);
        if(num > i+1) salah = true;
    }

    if(salah){
        cout << -1 << endl;
    } else {
        int count = N;
        while(count != 0){
            for(int i=count-1; i>=0; i--){
                if(number[i] == i+1){
                    number.erase(number.begin()+i);
                    a[count] = i+1; 
                    count--;
                    break;
                }
            }
        }
        for(int i=1; i<=N; i++){
            cout << a[i] << endl;
        }
    }
}

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

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int N = 3000;
ll a[N],b[N];
ll dp[N][N];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=m;i++) cin>>b[i];
	for(int i=0;i<=n;i++) dp[i][0]=1;
	for(int i=0;i<=m;i++) dp[0][i]=1;
	long long ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i]==b[j]){
				dp[i][j]=(dp[i][j]%mod+dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
				//cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
			}
			else{
				dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod-dp[i-1][j-1]+mod)%mod;
				//cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
			}
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i=0; i<n; i++){
      s.at(i) = 0;
    }
    int x;
    cin >> x;
    for(int i=0; i<x; i++){
        int a;
        cin >> a;
        s.at(a-1) += -1;
    }
    int y;
    cin >> y;
    for(int i=0; i<y; i++){
        int b;
        cin >> b;
        s.at(b-1) += 1;
    }
    int z;
    cin >> z;
    for(int i=0; i<z; i++){
        int c;
        cin >> c;
        s.at(c-1) += 2;
    }
    int ans=0;
    for(int i=0; i<n; i++){
        if(s.at(i) >= 2){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const ll inf = 1e9;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll ans=1;
  for (int i=1; i*i<=N; i++) {
    ans=i*i;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
import bisect

A, B, Q = map(int, input().split())
S = [-float("inf")]
T = [-float("inf")]
X = []

for i in range(A):
    S.append(int(input()))
S.append(float("inf"))

for i in range(B):
    T.append(int(input()))
T.append(float("inf"))


for i in range(Q):
    X.append(int(input()))

for x in X:
    si = bisect.bisect_left(S, x)
    ti = bisect.bisect_left(T, x)
    
    s01 = [S[si-1], S[si]]
    t01 = [T[ti-1], T[ti]]
    
    ans = float("inf")
    for ss in s01:
        for tt in t01:
            l = abs(ss - tt) + min(abs(ss - x), abs(tt - x))
            ans = min(ans, l)
    print(ans)

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

const ll INF = 1e10;
const int MAXV = 101010;
const int MAXE = 501010;
struct edge { ll from, to, cost; edge(int f, int t, int c) :from(f), to(t), cost(c) {} edge() {} };
edge es[MAXE];
ll d[MAXV];
int V, E;

bool shortest_path(int s) {
    for (int i = 0; i < V; ++i) d[i] = INF;
    d[s] = 0;
    int num = 0;
    while (true) {
        bool update = false;
        for (int i = 0; i < E; ++i) {
            edge e = es[i];
            if (d[e.from] != INF and d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if (update) {
            num++;
            if (num >= V) {
                return false;
            }
        }
        if (!update) break;
    }
    return true;
}

// // 負の閉路検出
// bool find_negative_loop() {
//     fill(d, d+V, 0);
//     for (int i = 0; i < V; ++i) {
//         for (int j = 0; j < E; ++j) {
//             edge e = es[j];
//             if (d[e.to] > d[e.from] + e.cost) {
//                 d[e.to] = d[e.from] + e.cost;
//
//                 // n回目にも更新があるなら負の経路がある
//                 if (i == V - 1) return true;
//             }
//         }
//     }
//     return false;
// }

int main() {
    int s;
    cin >> V >> E >> s;
    rep(i, E) {
        int x, y, d;
        cin >> x >> y >> d;
        edge e1(x, y, d);
        es[i] = e1;
    }

    // if (find_negative_loop()) {
    //     cout << "NEGATIVE CYCLE" << endl;
    //     return 0;
    // }

    bool tmp = shortest_path(s);

    if (!tmp) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }

    rep(i, V) {
        if (d[i] == INF) {
            cout << "INF" << endl;
        }
        else cout << d[i] << endl;
    }
}



Measured memory_bytes: 3132
N = int((input()))
V = list(map(int,input().split()))
C = list(map(int,input().split()))

sa_VC = [0]*N
ans = 0

for j in range(N):
    sa_VC[j] = V[j] - C[j]
    if sa_VC[j] > 0 :
        ans += sa_VC[j]

print(ans)


Measured memory_bytes: 3060
require 'set'
loop do
    n = gets.to_i
    break if n == 0
    wall = (1..2).map { [-1] + gets.split.map(&:to_i) }
    queue = [[0, 1], [1, 1]]
    reached = Set[*queue]
    jump = 0
    ans = nil
    until queue.empty?
        new_queue = []
        until queue.empty?
            w, h = queue.shift
            h -= 1 until wall[w][h] != 2
            h += 1 while h < n && wall[w][h] == 1 && wall[w][h+1] == 1
            if h == n
                ans = jump
                break
            end
            [0, 1, 2].each do |d|
                next if h + d > n
                new_pos = [1 - w, h + d]
                if !reached.include?(new_pos)
                    reached << new_pos
                    new_queue << new_pos
                end
            end
        end
        break if ans
        jump += 1
        queue = new_queue
    end
    puts ans ? ans : 'NA'
end



Measured memory_bytes: 7068
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, K; cin >> N >> K; vl hs(N+1, 0); REP(i, N) cin >> hs[i+1];
    vl dp(N+1, 0); dp[1] = 0;
    FOR(i, 2, N+1){
        ll tmp = LINF;
        for (int j = 1; j <= K; j++) {
            if(i - j >= 1){
                tmp = min(tmp, dp[i-j] + abs(hs[i] - hs[i-j]));
            }
        }
        dp[i] = tmp;
    }
    cout << dp[N] << endstr;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Program
{

    void Solve()
    {
        var N = io.Int;
        var f =
            Enumerable.Range(1, 9)
                .Where(x => N % x == 0)
                .Select(x => N / x)
                .Any(x => x < 10);
        WriteLine(f ? "Yes" : "No");
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();
    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

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

int main() {
  int H , N;
  cin >> H >> N;
  vector<int> a(N);
  long long int sum = 0;
  for (int i = 0; i <N; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  if (sum >= H) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}

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

long long div(long long n) {
    int t = 0;
    while(n > 1) {
        n /= 2;
        t++;
    }
    return t;
}

int main() {
    long long h;
    cin >> h;

    long long t = div(h);
    
    long long res = pow(2, t + 1) - 1;
    cout << res << endl;

    return 0;
}

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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	
	if(a==c){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}

	

	return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(ll i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF (INT_MAX / 2)

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)*b;
}

int main(void){
    ll d;
    ll max_v=-INF;
    ll max_i=0;
    cin>>d;
    vector<ll>c(d);
    vector<vector<ll>>s(d,vector<ll>(26));
    rep(i,d){
        cin>>c[i];
    }
    rep(i,d){
        max_v=-INF;
        rep(j,26){
            cin>>s[i][j];
            if(max_v<s[i][j]){
                max_v=s[i][j];
                max_i=j+1;
            }
        }
        cout<<max_i<<endl;
    }
}
/*

*/


Measured memory_bytes: 3720
#include<stdio.h>

int main(void){
    int i,x;
    
    for(i=1;i<=10000;i++){
        scanf("%d",&x);
        if(x!=0){
            printf("Case %d: %d\n",i,x);
        }else{
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2036
def sumOfDigits(n):
    ans = 0
    while n > 0:
        ans += n%10
        n = n // 10
    return(ans)

import sys
N = int(sys.stdin.readline().rstrip())
min = 1000000
for i in range(1, N):
    a = sumOfDigits(i)
    b = sumOfDigits(N-i)
    if min > a + b:
        min = a + b
print(min)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    int n;
    cin >> n;
    long long ans = 0;
    rep(i,1,n+1){
        if(i%3 != 0 && i%5 != 0 ){
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
///******* In the name of Allah *******///

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

int main()
{
    int a,b,c,m,n,i,j,k,l,sum,div;
    cin>>a>>b>>c;
    sum = a + b + c;
    if(sum>=22)
    {
        cout<<"bust"<<endl;
    }
    else
    {
        cout<<"win"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 1)

class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.size = [1]*n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.size[y] += self.size[x]
            self.p[x] = y
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)


n,m,k = map(int,input().split())
uf = UnionFind(n)
ans = [0] * n
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    uf.unite(a,b)
    ans[a] -= 1
    ans[b] -= 1

for i in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if uf.same(c,d):
        ans[c] -= 1
        ans[d] -= 1

for i in range(n):
    p = uf.find(i)
    ans[i] += uf.size[p] - 1

print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 39900
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	LL n,m;
	cin >>n>>m;
	vector<pair<LL,LL>> ab(n);
	vector<LL> a(n);
	vector<LL> cou(10001,0);
	for (LL i = 0; i < n; i++) {
		cin >>ab[i].first>>ab[i].second;
		a[i]= ab[i].first;
	}

	sort(ab.begin(),ab.end());
	sort(a.begin(), a.end());
	LL ans=0,in2=0;
	for (LL i = 0; i <m; i++) {
		LL key=i+2;
		auto it=lower_bound(a.begin(),a.end(),key);
		LL index=it-a.begin();
		index--;
		if (index < 0) {
			continue;
		}
		LL ma=0,k=0;
		for (LL j = index; j >= in2; j--) {
			cou[ab[j].second]++;
			/*if (ma <= ab[j].second) {
				ma = ab[j].second;
				k=j;
			}*/
		}

		for (int l = cou.size()-1; l >= 0; l--) {
			if (cou[l] > 0) {
				cou[l]--;
				ans+=l;
				//cout <<l<<endl;
				break;
			}
		}

		/*ab[k].second=0;
		ans+=ma;*/
		in2=index+1;
	}
	cout <<ans<<endl;
	return 0;
}

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

int main(){
    int k,n;
    scanf("%d %d",&n,&k);
    int a[n];
    for(int i = 0;i < n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    if(n>k){
        while(k--&&n--)
            a[n]=0;
        ll sum = 0;
        for(int i = 0;i < n;i++)
            sum+=1LL*a[i];
        printf("%lld",sum);
    }
    else {
        printf("0\n");
    }
  return 0;
}


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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    int n;
    ci >> n;

    co << 180 * (n - 2) << en;
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG 0
#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
 
lli abs2(lli a){
	if(a>=0)return a;
	else return -a;
}

lli calc(lli a,lli b){
	if(a%b==0)return b;
	return calc(b,a%b);
}
 
int main(){
	lli n,x;
	vector<lli> y;
	vector<lli> z;
	cin>>n>>x;
	REP(i,n){
		lli tmpX;
		cin>>tmpX;
		y.push_back(tmpX);
	}
	lli ans = abs2(y[0]-x);
	REP(i,n){
		ans = calc(ans,abs2(y[i]-x));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define NOT_ZERO 1
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long ll;
typedef unsigned short int usi;

int main()
{
    int n, h, w;
    int i, j;

    scanf("%d %d %d",&n, &h, &w);

    printf("%d",(n-h+1)*(n-w+1));

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

long long a, b, n; 

long long calc(long long x) {
  long long tmp = a * x / b; 
  long long tmp2 = a * (x/b);
  return tmp - tmp2;
}

int main() {
  cin >> a >> b >> n;

  cout << calc(min(n, b-1)) << endl;

  return 0;
}

// EOF


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;

int main(){
	int i;
	char ch;
	string s;
	cin>>s;
	set<char> values;
	for(i=0; i<s.size(); i++) values.insert(s[i]);
	for(ch='a'; ch<='z'; ch++){
		if(values.find(ch)==values.end()){
			cout<<ch<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300;
// (a, b, c) => cost
// 1個乗った皿がa個、2個乗った皿がb個、3個乗った皿がc個のときの残りの操作の期待値
double dp[MAX_N + 1][MAX_N + 1][MAX_N + 1];
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    int A = 0, B = 0, C = 0;
    for(int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        if(tmp == 1) A++;
        if(tmp == 2) B++;
        if(tmp == 3) C++;
    }
    dp[0][0][0] = 0;
    for(int c = 0; c <= N; c++) {
        for(int b = 0; b <= N; b++) {
            for(int a = 0; a <= N - b - c; a++) {
                double p = double(a + b + c) / double(N);
                if(p ==  0) continue;
                dp[a][b][c] = N;
                if(a > 0) {
                    dp[a][b][c] += double(a) * dp[a - 1][b][c];
                }
                if(b > 0) {
                    dp[a][b][c] += double(b) * dp[a + 1][b - 1][c];
                }
                if(c > 0) {
                    dp[a][b][c] += double(c) * dp[a][b + 1][c - 1];
                }
                dp[a][b][c] /= double(N) * p;
            }
        }
    }
    cout << std::fixed << std::setprecision(15) << dp[A][B][C] << endl;
    return 0;
}

Measured memory_bytes: 213248
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]"):
    result = N - sum(A)
    if result >= 0:
        print(result)
    else:
        print(-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void rd(int &v){char ch;for(ch='*';ch<'0'||ch>'9';ch=getchar());for(v=0;ch>='0'&&ch<='9';ch=getchar()) v=v*10+ch-'0';}
int n,d;
int main()
{
	cin>>n>>d;
	d=d+d+1;
	int ans=0;
	if(n%d) ans++;
	ans+=n/d;
	cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
int d[55];

int main()
{
   cout << fixed << setprecision(10);
   cin >> N;
   REP(i, N) cin >> d[i];
   ll sum = 0;
   REP(i, N-1) {
      for (int j = i + 1; j < N; j++) {
         sum += d[i] * d[j];
         eprintf("%d\n", d[i] * d[j]);
      }
   }
   cout << sum << endl;
   return 0;
}



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

int dp[101][76];

int main() {
  int N;
  cin >> N;
  map<int, int> mp;
  for (int i = 2; i <= N; i++) {
    int n = i;
    for (int p = 2; p <= N; p++) {
      while (n % p == 0) {
        mp[p]++;
        n /= p;
      }
    }
  }

  vector<int> nums;
  for (auto p : mp) {
    nums.push_back(p.second);
  }
  int len = nums.size();

  dp[0][1] = 1;
  for (int i = 0; i < len; i++) {
    for (int d1 = 1; d1 <= 75; d1++) {
      for (int d2 = 1; d2 <= 75; d2++) {
        if (d1 * d2 <= 75 && nums[i] >= d2 - 1) {
          dp[i + 1][d1 * d2] += dp[i][d1];
        }
      }
    }
  }

  cout << dp[len][75] << endl;
  return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 300005, INF = 0x3f3f3f3f, P = 998244353;

int n;
char a[N];

int getv(char c) {
	if (c == 'R') {
		return 0;
	}
	if (c == 'G') {
		return 1;
	}
	if (c == 'B') {
		return 2;
	}
	return -1;
}

int main() {
	read(n);
	readStr(a + 1);
	int c[3] = {0, 0, 0}, ans = 1;
	for (int i = 1; i <= 3 * n; ++i) {
		int v = getv(a[i]);
		int t = INF;
		for (int j = 0; j < 3; ++j) {
			if (c[j] > c[v]) {
				t = std::min(t, c[j] - c[v]);
			}
		}
		if (t < INF) {
			ans = 1ll * ans * t % P;
		}
		++c[v];
		t = std::min({c[0], c[1], c[2]});
		for (int j = 0; j < 3; ++j) {
			c[j] -= t;
		}
	}
	for (int i = 1; i <= n; ++i) {
		ans = 1ll * ans * i % P;
	}
	print(ans);
}


Measured memory_bytes: 4224
MOD = 10**9+7

h,w,a,b = map(int,input().split())

n = h+w
fac = [1]*(n+1)
fac_inv =  [0]*(n+1)

for i in range(n):
    fac[i+1] = (fac[i] * (i+1)) %MOD
fac_inv[-1] = pow(fac[-1],MOD-2,MOD)
for i in range(n,0,-1):
    fac_inv[i-1] = (fac_inv[i] * i) % MOD
    
def comb(n,k):
    if k<0 or k>n:
        return 0
    x = (fac[n] * (fac_inv[k] * fac_inv[n-k])%MOD)%MOD
    return x

ans = 0

for i in range(w-b):
    
    ans += comb((h-a-1) + b+i, b+i) * comb((a-1) + (w - b-i-1), a-1) %MOD
    ans %= MOD
    
print(ans)

Measured memory_bytes: 18804
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N;
	cin>>N;
	map<int,int> a[2];
	rep(i,N){
		int x;
		cin>>x;
		a[i%2][x]++;
	}
	using P = pair<int,int>;
	vector<P> x,y;
	for(P p:a[0]) x.pb(P(p.sc,p.fs));
	for(P p:a[1]) y.pb(P(p.sc,p.fs));
	x.pb(P(0,-1));
	y.pb(P(0,-2));
	sort(all(x),greater<P>());
	sort(all(y),greater<P>());
	int ans = N;
	rep(i,2) rep(j,2) if(x[i].sc != y[j].sc) chmin(ans,N-x[i].fs-y[j].fs);
	cout<<ans<<endl;
}

Measured memory_bytes: 6136
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>

int main(void){
    int a,b,c,x;
    std::cin >> a >> b >> c >> x;

    int counter = 0;
    for(int gohyaku = 0; gohyaku <= a; gohyaku++){
        for(int hyaku = 0; hyaku <= b; hyaku++){
            for(int gojyuu = 0; gojyuu <= c; gojyuu++){
                if(gohyaku*500 + hyaku*100 + gojyuu*50 == x){
                    counter++;
                }
            }
        }
    }

    std::cout << counter;
    return 0;
}



Measured memory_bytes: 888
#include <iostream>
using namespace std;
string s1,s2;
char voc[]="mcxi";

string i2mcxi(int n){
	int b=1000;
	string res="";
	for(int i=0;i<4;i++,b/=10){
		int t=n/b;
		if(t==0)continue;
		if(t>1)res+=(t+'0');
		res+=voc[i];
		n=n%b;
	}
	return res;
}
int mcxi2i(char c){
	if(c=='m')return 1000;
	else if(c=='c')return 100;
	else if(c=='x')return 10;
	else if(c=='i')return 1;
}
int conv(string s){
	int res=0;
	int n=1;
	for(string::iterator it=s.begin();it!=s.end();it++){
		if((*it)>'0'&&(*it)<='9')n=(*it)-'0';
		else{
			res+=n*mcxi2i(*it);
			n=1;
		}
	}
	return res;
}
void solve(){
	cout<<i2mcxi(conv(s1)+conv(s2))<<endl;
}
int main(){
	int n;
	cin>>n;
	for(;n>0;n--){
		cin>>s1>>s2;
		solve();
	}
	return 0;
}

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

#define MAX 100000

int main() {
	int N;
	cin >> N;
	int t[MAX + 1], x[MAX + 1], y[MAX + 1];
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	bool flg = true;
	for (int i = 1; i <= N; i++) {
		int dt = t[i] - t[i - 1];
		int dx = abs(x[i] - x[i - 1]);
		int dy = abs(y[i] - y[i - 1]);
		if (dx + dy > dt || (dx + dy) % 2 != dt % 2) {
			flg = false;
			break;
		}
	}
	cout << (flg ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 1408
from operator import itemgetter
N=int(input())

xyh=[list(map(int,input().split())) for _ in range(N)]
count=0

xyh.sort(key=itemgetter(2),reverse=True)
for h in xyh:
    if h[2]==0:
        count+=1
for px in range(101):
    for py in range(101):
        judge=0
        base=0
        for i in xyh:
            if i[2]>=1:
                if base==0:
                    base=i[2]+abs(i[0]-px)+abs(i[1]-py)
                    judge+=1
                elif base==i[2]+abs(i[0]-px)+abs(i[1]-py):
                    judge+=1
            else:
                if max(base-abs(i[0]-px)-abs(i[1]-py),0)==0:
                    judge+=1

        if judge==N:
            print(px,py,base)
            break
            


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long               ll;
const int mod = 1e9+7;
#ifndef M_PI
const double M_PI = acos(-1.0);
#endif

const int nmax = 1e5 +5;

int sizes[nmax];

int main(){
	int n;
	cin>>n;
	int min_col = 0;
	ll cur_size = 0;
	for(int i=1; i<=n; ++i){
		scanf("%d", sizes+i);
	}
	sort(sizes+1, sizes+n+1);
	for(int i=1; i<=n; ++i){
		int n_size=sizes[i];
		if(cur_size*2 < n_size){
			min_col = i;
		}
		cur_size += n_size;
	}
	cout<<n+1-min_col<<'\n';
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

ll num[1000010];
int n,m,A,B;
int cnt[2];
int tate[2][510];
int yoko[2][510];
int naname[2][2];

int k;
void check(int f){
	int i=((num[k]>>9)>>(f*18))&511;
	int j=((num[k]   )>>(f*18))&511;
	if(i==0)return;
	
	tate[f][i]++;
	if(tate[f][i]==n)cnt[f]++;
	yoko[f][j]++;
	if(yoko[f][j]==n)cnt[f]++;
	if(i==j){
		naname[f][0]++;
		if(naname[f][0]==n)cnt[f]++;
	}
	if(i+j==n+1){
		naname[f][1]++;
		if(naname[f][1]==n)cnt[f]++;
	}
}

void nxt(){
	scanf("%d",&k);
	check(0);
	check(1);
}

int main(){
	scanf("%d%d%d%d",&n,&A,&B,&m);
	
	//は？
	if(n==1){
		int x,y;
		scanf("%d%d",&x,&y);
		rep(i,0,m){
			int k;
			scanf("%d",&k);
			if(x==k&&A==1 || y==k&&B==1 ){
				if(x==k&&A==1 && y==k&&B==1)puts("DRAW");
				else puts(x==k&&A==1?"USAGI":"NEKO");
				return 0;
			}
		}
		puts("DRAW");
		return 0;
	}
	//
	
	rep(i,1,n+1)rep(j,1,n+1){
		int t;
		scanf("%d",&t);
		num[t]|=(i<<9|j);
	}
	rep(i,1,n+1)rep(j,1,n+1){
		int t;
		scanf("%d",&t);
		num[t]|=(i<<9|j)<<18;
	}
	rep(i,0,m){
		nxt();
		if(cnt[0]>=A||cnt[1]>=B){
			if(cnt[0]>=A&&cnt[1]>=B){
				puts("DRAW");
			}else{
				puts(cnt[0]>=A?"USAGI":"NEKO");
			}
			return 0;
		}
	}
	puts("DRAW");
}


Measured memory_bytes: 9536
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int plan1 = a * n;
  int plan2 = b;
  if (plan1 > plan2)
    cout << plan2 << endl;
  else
    cout << plan1 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	long mod = 1_000_000_007;
	long[][][][] dp;
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		long l = fs.nextLong();
		long r = fs.nextLong();
		
		dp = new long[61][2][2][2];
		dp[60][0][0][0] = 1;
		for(int i = 59; i >= 0 ; i--) {
			for(int j = 0; j < 2; j++) {
				for(int k = 0; k < 2; k++) {
					for(int s = 0; s < 2; s++) {
						long pre = dp[i+1][j][k][s];
						long lb = (l >> i) & 1;
						long rb = (r >> i) & 1;
						
						for(int x = 0; x < 2; x++) {
							for(int y = 0; y < 2; y++) {
								if(x == 1 && y == 0) {
									continue;
								}
								int nj = j;
								int nk = k;
								int ns = s;
								
								if(s == 0 && x != y) {
									continue;
								}
								if(x == 1 && y == 1) {
									ns = 1;
								}
								
								if(j == 0 && lb == 1 && x == 0) {
									continue;
								}
								if(lb == 0 && x == 1) {
									nj = 1;
								}
								if(k == 0 && rb == 0 && y == 1) {
									continue;
								}
								if(rb == 1 && y == 0) {
									nk = 1;
								}
								
								dp[i][nj][nk][ns] = (dp[i][nj][nk][ns] + pre) % mod;
							}
						}
					}
				}
			}
		}
		
		long ans = 0;
		for(int j = 0; j < 2; j++) {
			for(int k = 0; k < 2; k++) {
				for(int s = 0; s < 2; s++) {
					ans = (ans + dp[0][j][k][s]) % mod;
				}
			}
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

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

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

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

int main() {
  // Input
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  // Compute
  // Output after 0times line
  for (int i = 0; i < N; i++) {
    cout << A.at(i);
    if (i < N-1) {
      cout << " ";
    }
    else {
      cout << endl;
    }
  }
  
  int v;
  for (int i = 1; i < N; i++) {
    v = A.at(i);
    int j = i - 1;
    while (j >= 0 && A.at(j) > v) {
      A.at(j+1) = A.at(j);
      j--;
    }
    A.at(j+1) = v;
    
    for (int k = 0; k < N; k++) {
      cout << A.at(k);
      if (k < N-1) {
        cout << " ";
      }
      else {
        cout << endl;
      }
    }
  }
      
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    string s;
    cin >> s;
    Int n = (Int)s.size();
    Int res = n * (n - 1) / 2;
    map<char, Int> mp;
    for (Int i = 0; i < n; i++) mp[s[i]]++;
    for (auto v : mp) {
        Int sub = v.se * (v.se - 1) / 2;
        sub = max(sub, (Int)0);
        res -= sub;
    }
    dump(res + 1);
    return 0;
}

Measured memory_bytes: 640
A,B = map(int,input().split())
def f(n):
    res1 = 0
    res2 = 0
    if (n // 2) % 2 == 1:
        res1 = 1
    if n % 2 == 1:
        res2 = n-1
    return res1^res2

ans = f(A)^f(B+1)
print(ans)

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

int main()
{
  string s;
  cin >> s;
  
  if (!(s.at(0) == 'A' && s.at(1) >= 'a'))
  {
    cout << "WA";
    return 0;
  }
  
  bool Ced = false;
  for (int i = 2; i < s.size(); i ++)
  {
    if (s.at(i) == 'C')
    {
      if (!Ced) 
      {
        if (i != s.size() - 1)
          Ced = true;
        else
        {
          cout << "WA";
          return 0;
        }
      }
      else
      {
        cout << "WA";
        return 0;
      }
    }
    else if (s.at(i) < 'a')
    {
      cout << "WA";
      return 0;
    }
  }
  
  if (!Ced)
    cout << "WA";
  else
    cout << "AC";
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>

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

int N, M;
int D[1234];
int C[1234];
long long int memo[1234][1234];

long long int dp(int i, int j) {
	if (i == 0) return 0;
	if (j == 0) return 1145141919810;
	if (memo[i][j] != -1) return memo[i][j];
	return memo[i][j] = min(dp(i - 1, j - 1) + D[i - 1] * C[j - 1], dp(i, j - 1));
}

int main() {

	memset(memo, 0xff, sizeof(memo));

	scanf("%d %d", &N, &M);

	rep(i, N) scanf("%d", &D[i]);
	rep(i, M) scanf("%d", &C[i]);

	printf("%lld\n", dp(N, M));

	return 0;
}

Measured memory_bytes: 14640