akhauriyash/Code-Regression huggingface dataset:
[N,M] = [int(s) for s in input().rstrip().split(' ')]
L_H = [int(s) for s in input().rstrip().split(' ')]
L_map = [0]*N
for i in range(M):
    [A_i,B_i] = [int(s) for s in input().rstrip().split(' ')]
    L_map[A_i-1] = max(L_map[A_i-1],L_H[B_i-1])
    L_map[B_i-1] = max(L_map[B_i-1],L_H[A_i-1])
ans = 0
for n in range(N):
    if L_map[n] == 0:
        ans += 1
    else:
        if L_H[n] > L_map[n]:
            ans += 1
print(ans)

Measured memory_bytes: 20052
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val bellman_ford :
    (* 頂点数n *)
    int ->
    (* 辺のリスト
       頂点は0からn-1までの整数でなくてはならない
       2n回呼び出されるので，リストを作るのに時間がかかるならメモ化すること *)
    (int * int * Weight.t) church_list ->
    (* 始点 *)
    int ->
    (* 頂点を受け取り，そこまでの距離を返す関数
       頂点に到達するパスが無ければinfを返し，
       そこに到達するまでに負閉路があればneg_infを返す *)
    (int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let bellman_ford n es s =
    (* 距離を覚えるやつ *)
    let d = Array.make n Weight.inf in
    (* 経路に負閉路が含まれる頂点を覚えるやつ *)
    let neg = Array.make n false in
    (* 始点より終点のインデックスが大きくなる辺を集めた隣接リスト *)
    let inc = Array.make n [] in
    (* 始点より終点のインデックスが小さくなる辺を集めた隣接リスト *)
    let dec = Array.make n [] in
    es.fold (fun (u, v, c) () ->
      if u <= v
      then inc.(u) <- (v, c) :: inc.(u)
      else dec.(u) <- (v, c) :: dec.(u)) ();
    d.(s) <- Weight.zero;
    (* 残りの反復回数 *)
    let i = ref (n / 2) in
    (* 更新が行われたか *)
    let is_modified = ref true in
    (* 最初の方のループでの各辺の処理 *)
    let f u (v, c) = 
      let open Weight in
      if
        (* 原点から到達できない頂点は更新しない *)
        0 < Weight.compare inf d.(u)
        (* c は u から v への辺の重さ
           d.(u) + c < d.(v) *)
        && 0 < Weight.compare d.(v) (d.(u) + c)
      then (d.(v) <- d.(u) + c; is_modified := true) in
    while 0 < !i && !is_modified do
      is_modified := false;
      (* インデックスが増加する辺の処理 *)
      for u = 0 to n - 1 do
        List.iter (f u) inc.(u)
      done;
      (* インデックスが減少する辺の処理 *)
      for u = n - 1 downto 0 do
        List.iter (f u) dec.(u)
      done;
      decr i
    done;
    (* 負閉路を見付けるループでの各辺の処理 *)
    let f u (v, c) = 
      if neg.(u) then neg.(v) <- true;
      let open Weight in
      if 0 < Weight.compare inf d.(u) && 0 < Weight.compare d.(v) (d.(u) + c)
      then (d.(v) <- d.(u) + c; neg.(v) <- true; is_modified := true) in
    (* 負閉路を見付けるループ *)
    i := (n + 1) / 2;
    while 0 < !i && !is_modified do
      is_modified := false;
      (* インデックスが増加する辺の処理 *)
      for u = 0 to n - 1 do
        List.iter (f u) inc.(u)
      done;
      (* インデックスが減少する辺の処理 *)
      for u = n - 1 downto 0 do
        List.iter (f u) dec.(u)
      done;
      decr i
    done;
    fun v -> if neg.(v) then Weight.neg_inf else d.(v)
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let inf = min_int
  let neg_inf = max_int
  let ( + ) = ( + )
  let compare x y = compare y x
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m p ->
  let abc = Array.init m @@ fun _ ->
    Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c - p in
  let d = G.bellman_ford n { G.fold = fun f -> Array.fold_right f abc } 0 (n - 1) in
  if max_int <= d
  then print_endline "-1"
  else Printf.printf "%d\n" @@ max 0 d


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

using namespace std;
using i64 = int64_t;

int main(){
    vector<int> a(2);
    for(auto&& v:a)cin >> v;
    sort(a.begin(), a.end());
    if(a[0] == 2)cout << 1 << endl;
    else if(a[1] == 2)cout << 3 << endl;
    else cout << 2 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC";
    else cout << "ABC";
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, uint>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

void solve(){
    int N, K;
    ll X[101], Y[101];
    cin >> N >> K;
    for(int i = 0; i < N; ++i) cin >> X[i] >> Y[i];

    set<int> xx, yy;
    for(int i = 0; i < N; ++i) xx.insert(X[i]);
    for(int i = 0; i < N; ++i) yy.insert(Y[i]);

    ll ans = -1;
    for(int sx : xx){
        for(int sy : yy){
            for(int tx : xx){
                for(int ty : yy){
                    if (sx <= tx && sy <= ty) {
                        ll area = 1LL * (tx - sx) * (ty - sy);
                        int c = 0;
                        for(int i = 0; i < N; ++i){
                            if (sx <= X[i] && X[i] <= tx && sy <= Y[i] && Y[i] <= ty){
                                c++;
                            }
                        }
                        if (K <= c) {
                            if (ans < 0) ans = area;
                            ans = min(ans, area);
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{ll to,cost;};
#define MAX 2005
ll inf = 20000000;
ll INF = inf*3000LL;

int N,M,K;
vector<edge> G[MAX];

ll DP[MAX][MAX];
ll dp[MAX][MAX][2];
ll V[MAX];

bool visited[MAX];
vector<ll> A,B;

void calc(bool flg){
  int size=A.size();
  for(int i=0;i<size;i++)
    for(int j=0;j<=size;j++)
      for(int k=0;k<2;k++)
        dp[i][j][k]=-INF;
  
  dp[0][flg][flg]=0;
  for(int i=1;i<size;i++){
    for(int j=0;j<=size;j++){
      //not select i
      dp[i][j][0]=max(dp[i-1][j][1],dp[i-1][j][0]);

      if(j==0)continue;
      //select i
      ll cost=max(dp[i-1][j-1][0],dp[i-1][j-1][1]+B[i-1]);
      
      if(i+1==size&&A.size()==B.size()&&flg){
        cost+=B[i];
      }
      
      dp[i][j][1]=max(dp[i][j][1],cost);
    }
  }

  for(int i=0;i<size;i++)
    for(int j=0;j<=size;j++)
      for(int k=0;k<2;k++)
        V[j]=max(V[j],dp[i][j][k]);
}

void dfs(int pos,int prev){
  if(visited[pos])return;
  visited[pos]=true;
  A.push_back(pos);
  for(int i=0;i<(int)G[pos].size();i++){
    if(G[pos][i].to==prev)continue;
    B.push_back(G[pos][i].cost);
    dfs(G[pos][i].to,pos);
    break;
  }
}

int search(int p){
  map<int,bool> mp;
  while(!mp[p]){
    mp[p]=true;
    for(int i=0;i<(int)G[p].size();i++){
      edge e=G[p][i];
      if(mp[e.to])continue;
      p=e.to;
      break;
    }
  }
  return p;
}

int main(){
  cin>>N>>M>>K;
  for(int i=0;i<M;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    if(c==0)c=-INF;
    G[a].push_back((edge){b,c});
    G[b].push_back((edge){a,c});
  }
  
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      DP[i][j]=-INF;
  DP[0][0]=0;

  int C=0;
  for(int i=1;i<=N;i++){
    if(visited[i])continue;
    A.clear();
    B.clear();
    
    dfs( search(i) ,0);
    
    int size=A.size();
    for(int j=0;j<=size;j++)V[j]=-INF;
    calc(true);
    calc(false);
    /*
    for(int i=0;i<A.size();i++)cout<<A[i]<<' ';cout<<endl;
    for(int i=0;i<B.size();i++)cout<<B[i]<<' ';cout<<endl;
    for(int i=0;i<A.size();i++)cout<<V[i]<<' ';cout<<endl;
    cout<<endl;
    */
    C++; 
    for(int j=0;j<=K;j++)
      for(int k=0;k<=min(j,size);k++)
        DP[C][j]=max(DP[C][j],DP[C-1][j-k]+V[k]);
  }
 
  if(DP[C][K] < -inf) cout << "Impossible" << endl;
  else cout << DP[C][K] << endl;
  return 0;
}

Measured memory_bytes: 95820
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>

struct Point{ double x, y; };

Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

int ccw(const Point &p0, const Point &p1, const Point &p2) // P0, P1, P2 counter_clockwise.
{
	double d1 = (p1.x - p0.x) * (p2.y - p0.y);
	double d2 = (p2.x - p0.x) * (p1.y - p0.y);
	if(d1 == d2) return 0;
	return (d1 > d2 ? 1 : -1);
}

double inpro(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vx) + (v1.vy * v2.vy);
}

double det2(const Vector &v1, const Vector &v2)
{
	return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

bool crit(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
{
    if((p0.x > p2.x) && (p0.x > p3.x) && (p1.x > p2.x) && (p1.x > p3.x)) return true;
    if((p0.x < p2.x) && (p0.x < p3.x) && (p1.x < p2.x) && (p1.x < p3.x)) return true;

    if((p0.y > p2.y) && (p0.y > p3.y) && (p1.y > p2.y) && (p1.y > p3.y)) return true;
    if((p0.y < p2.y) && (p0.y < p3.y) && (p1.y < p2.y) && (p1.y < p3.y)) return true;
    return false;
}

int main()
{
    int q;
    scanf("%d", &q);
    double x0, y0, x1, y1, x2, y2, x3, y3;
    for(int i = 0; i < q; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        Point P0 = set_p(x0, y0), P1 = set_p(x1, y1), P2 = set_p(x2, y2), P3 = set_p(x3, y3);
        Vector V01 = set_v(P0, P1), V23 = set_v(P2, P3);
        if(ccw(P0, P1, P2) * ccw(P0, P1, P3) > 0 || ccw(P2, P3, P0) * ccw(P2, P3, P1) > 0){
            printf("0\n");
        }else {
			if(det2(V01, V23) == 0 && crit(P0, P1, P2, P3)){ printf("0\n"); }
			else{ printf("1\n"); }
        }
    }
    return 0;
}

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

int main(){
        int n,a,b;
        cin >> n >> a >> b;
        for(int i=0;i<10000;i++){
                if(a+1 != b){
                        a=a+1;
                }else if(a != 1){
                        a=a-1;
                }else{
                        cout << "Borys" << endl;
                        break;
                }

                if(b-1 != a){
                        b=b-1;
                }else if( b != n){
                        b=b+1;
                }else{
                        cout << "Alice" <<endl;
                        break;
                }
        }
        return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

flag = True
count = 0
while(flag):
    flag = False
    for i in range(1, N):
        if(a[-i] < a[-i-1]):
            hold = a[-i]
            a[-i] = a[-i-1]
            a[-i-1] = hold
            flag = True
            count += 1
print(" ".join(list(map(str, a))))
print(count)

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

int N;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  vector<int> v;
  for (int i = 11; i <= 55555; i += 5) {
    int no = 0;
    for (int j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        no++;
        break;
      }
    }
    if (!no) v.emplace_back(i);
  }  
  for (int i = 0; i < N; i++) {
    cout << v[i] << " \n"[i + 1 == N];
  }

  return 0;
}

Measured memory_bytes: 256
/*input
9
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mss map <string,string>
#define msl map <string,ll>
#define mll map <ll,ll>
#define mcl map <char,ll>
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define sz(a) int((a).size())
#define pb push_back
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())     
#define rep(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define N 998244353
#define PI acos(-1.0)
//if (s.find('R') != std::string::npos)
//s.replace(s.find("10"), sizeof("10") - 1, "");
using namespace std;
bool comp(pair<string,ll>a,pair<string,ll>b){
  if(a.first==b.first) return a.second>b.second;
  return a.first<b.first;
}
long long  int exponentiation(long long  int base, long long  int exp) 
{ 
  if (exp == 0) 
    return 1; 
 
  if (exp == 1) 
    return base % N; 
  long long int t = exponentiation(base, exp / 2); 
  t = (t * t); 
  if (exp % 2 == 0) 
    return t;
  else  
    return ((base ) * t) ; 
}

int main()
{
  // added the two lines below 
  ios_base::sync_with_stdio (false); 
  cin.tie(NULL);
  cout.tie(0);
 
  ll n;
  cin>>n;
  cout<<pow(n,3);
  
}







Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  cin>>n;
  rep(i,n){
    vector<int>in(3);
    rep(i,3)cin>>in[i];
    sort(all(in));
    string ans;
    if(in[0]*in[0]+in[1]*in[1]==in[2]*in[2])ans="YES";
    else ans="NO";
    cout<<ans<<endl;
  }


}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

int main(void) {
    ll N;
    string S;
    cin >> N >> S;

    ll w = 0, b = 0;
    ll bb = 0;
    ll ww = 0;
    bool first_w = true;
    rep(i, N) {
        if (S[i] == '#') {
            b++;
        }
        else {
            w++;
        }
    }

    ll lb = 0, lw = 0, rb = b, rw = w;
    ll ans = min(b, w);
    rep(i, N) {
        if (S[i] == '#') {
            lb++; rb--;
        }
        else {
            lw++; rw--;
        }

        ans = min(lb + rw, ans);
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T="keyence";
  cin>>S;
  for(int i=0;i<=T.size();i++){
    if(S.substr(0,i)==T.substr(0,i) && S.substr(S.size()-(7-i))==T.substr(i)){
      puts("YES");
      return 0;
    }
  }
  puts("NO");
}

Measured memory_bytes: 3616
#include <iostream>
#include <queue>
#include <vector>
#include <stack>
#include <string>
#define N 10001
using namespace std;
typedef long long ll;
ll a[N];
stack<ll> q;
char c;
ll l=0;
main(){
	register int i,j;
	string s;
	cin>>s;
	for(i=0;i<s.length();i++){
		if(s[i]=='0'||s[i]=='1')q.push(s[i]-'0');
		else{
			if(!q.empty())q.pop();
		}
	}
	while(!q.empty()){
		a[++l]=q.top();
		q.pop();
	}
	for(i=l;i>=1;i--)
	cout<<a[i];
	cout<<endl;
	return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  auto comp = [&](int i, int j) { return B.at(i) < B.at(j); };
  priority_queue<int, vector<int>, decltype(comp)> pque(comp);
  for (int i = 0; i < N; i++) {
    if (A.at(i) < B.at(i)) pque.push(i);
  }
  ll answer = 0;
  while (!pque.empty()) {
    int i = pque.top(); pque.pop();
    int v = B.at((N+i-1) % N) + B.at((i+1) % N);
    int x = (B.at(i) - A.at(i)) / v;
    if (x == 0) {
      cout << "-1\n";
      return 0;
    }
    answer += x;
    B.at(i) -= v * x;
    if (B.at(i) > A.at(i)) pque.push(i);
  }
  cout << answer << endl;
  return 0;
}



Measured memory_bytes: 2936
import java.util.Scanner;
public class Main{
    public void solve(){
        int a,b,men,syu;
        Scanner sc=new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
        men=a*b;
        syu=a*2+b*2;
        System.out.println(men+" "+syu);
    }
    public static void main(String[]args){
        Main obj =new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
    A[i]*=-1;
  }
  
  vector<int> vec;
  vec.push_back(A[0]);
  FOR(i,1,N){
    auto iter=upper_bound(ALL(vec),A[i]);
    if(iter==vec.end()){
      vec.push_back(A[i]);
    }else{
      *iter=A[i];
    }
  }

  cout << vec.size() << endl;
}

Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    vector<ll> x(n,0);
    vector<ll> y(m,0);
    for(ll i=0;i<n;++i)cin>>x[i];
    for(ll i=0;i<m;++i)cin>>y[i];
    ll X=0,Y=0;
    for(ll i=1;i<=n-1;++i){
        X+=(x[i]-x[i-1])%MOD*i%MOD*(n-i)%MOD;
        X%=MOD;
    }
    for(ll i=1;i<=m-1;++i){
        Y+=(y[i]-y[i-1])%MOD*i%MOD*(m-i)%MOD;
        Y%=MOD;
    }
    prt(X*Y%MOD)

    return 0;
}


Measured memory_bytes: 1792
//////////////////////////////////////
////       ABHINASH GIRI          ////
/////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define pr 4294967296   // 2^32
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define high 1000000001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             -1e18
#define pinf              1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define e               1000000000
#define w(x)            int t; cin>>t; while(t--)
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define co(x) cout<<(x)<<"\n"
#define endl "\n"
typedef unsigned long int  ul;
typedef unsigned long long int ull;
typedef unsigned long long  int  li;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<long int> vl;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long int,long int>> vpl;
typedef vector<pair<long long int,long long int>> vpll;
typedef long long ll;
bool cmp(pair<char,int>a,pair<char,int>b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first>b.first;
}

ll  power(ll  a,ll  b){
    if(b==0)
        return 1;
    if(b==1)
        return a;
    else{
        ll  res=power(a,b/2);
        if(b%2)
        {
            return (res*res*(a));}
        else
        {return (res*res);}
    }
}
ll  gcd(ll  a,ll  b){
    if(b==0)
        return a;
    return gcd(b,a%b);
}


ll cost(vl &v,int n,vll dp)
{
    //cout<< " solving for n="<<n<<endl;
    if(n==1)
    {
        return 0;
    }
    if(n==2)
    {
        return abs(v[2]-v[1]);
    }
    ll a,b;
    if(!dp[n-1])
    {
        a=cost(v,n-1,dp);
        dp[n-1]=a;
    }
    else a=dp[n-1];
    if(!dp[n-2])
    {
        b=cost(v,n-2,dp);
        dp[n-2]=b;
    }
    else b=dp[n-2];

    return min(a+abs(v[n]-v[n-1]),b+abs(v[n]-v[n-2]));
}
int main() {
    std::chrono::time_point<std::chrono::high_resolution_clock> start_timer, end_timer;
    start_timer = std::chrono::high_resolution_clock::now();
    bool show_time = false;  //  change it to true when needed;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif

    /* Cook your Code  */
   fast;
   int n;
   cin>>n;
   vl v(n+1,0);
   v[0]=0;
    for (int i = 1; i <=n ; ++i) {
        cin>>v[i];
    }
    vll dp(n+1,0);
    dp[2]=abs(v[2]-v[1]);
    for (int j = 3; j <=n ; ++j) {
        dp[j]= min(dp[j-1]+abs(v[j]-v[j-1]),dp[j-2]+abs(v[j]-v[j-2]));
    }
    cout<<dp[n]<<endl;
    end_timer = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer-start_timer).count();
    if(show_time)
    {cout << "\\nElapsed Time: " << elapsed_time << "ms\\n";}

    return 0;
}

Measured memory_bytes: 1792
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        int count = 0;

        for (int i = 0; i <= A; i++) {
            for (int j = 0; j <= B; j++) {
                for (int k = 0; k <= C; k++) {
                    if (500 * i + 100 * j + 50 * k == X)
                        count++;
                }
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(count);

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  string s;
  cin >> s;
  REP(i, SZ(s)) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>

using namespace std;

int main() {

	string s;
	cin >> s;
	unordered_map<char, int> unorder_map;
	for (auto i = 0; i < s.size(); ++i)
	{
		unorder_map[s[i]]++;
	}
	auto flag1 = false, flag2 = false;
	if ((unorder_map['S'] > 0 && unorder_map['N'] > 0) 
		|| (unorder_map['S'] <= 0 && unorder_map['N'] <= 0))
	{
		flag1 = true;
	}
	if ((unorder_map['E'] > 0 && unorder_map['W'] > 0)
		|| (unorder_map['E'] <= 0 && unorder_map['W'] <= 0))
	{
		flag2 = true;
	}
	if (flag1 && flag2)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;


}

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

using namespace std;

int main()
{
	string S, T, answer;
	int N;
	cin >> N >> S >> T;
	for (int count = 0; count < N; count++)
	{
		answer.push_back(S.at(count));
		answer.push_back(T.at(count));
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

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 a, b, n;
	cin >> a >> b >> n;
	ll x = min(b - 1, n);
	ll ans = floor(a * x / b) - a * floor(x / b);
	cout << ans;
}

/*

*/


Measured memory_bytes: 3624
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (auto & a: A) {
        cin >> a;
    }
    bool aprroved = true;
    for (auto & a: A) {
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                aprroved = false;
            }
        }
    }
    if (aprroved) {
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
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};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> R(N,0), G(N,0), B(N,0);
    ll ans = 0;
    rrep(i,N-1) {
        if(S[i+1] == 'R') R[i] = R[i+1] + 1;
        else R[i] = R[i+1];
    }
    rrep(i,N-1) {
        if(S[i+1] == 'G') G[i] = G[i+1] + 1;
        else G[i] = G[i+1];
    }
    rrep(i,N-1) {
        if(S[i+1] == 'B') B[i] = B[i+1] + 1;
        else B[i] = B[i+1];
    }
    rep(i,N) repi(j,i+1,N) {
        bool r, g, b;
        r = g = b = false;
        if(S[i] == 'R' || S[j] == 'R') r = true;
        if(S[i] == 'G' || S[j] == 'G') g = true;
        if(S[i] == 'B' || S[j] == 'B') b = true;
        if(r && g) {
            ans += B[j];
            if(j+(j-i) < N && S[j+(j-i)] == 'B') ans--;
        } else if(r && b) {
            ans += G[j];
            if(j+(j-i) < N && S[j+(j-i)] == 'G') ans--;
        } else if(g && b) {
            ans += R[j];
            if(j+(j-i) < N && S[j+(j-i)] == 'R') ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n;
int main(){
cin >>n;
vector<int> dp(n+1,1000000);
dp[0]=0;
int ni[5];int si[6];
int num[12];
ni[0]=9;si[0]=6;
for(int i=1;i<5;i++){
  ni[i]=ni[i-1]*9;
}
for(int i=1;i<6;i++){
  si[i]=si[i-1]*6;
}
for(int i=0;i<11;i++){
  if(i<5) num[i]=ni[i];
  else num[i]=si[i-5];
}
num[11]=1;
sort(num,num+12);
for(int i=0;i<=n;i++){
  for(int j=0;j<12;j++){
       if(i-num[j]>=0){
         dp[i]=min(dp[i-num[j]]+1,dp[i]);
       }
  }
}
cout << dp[n]<<endl;
}


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

using namespace std;

int n, t;

int main()
{
	while (cin >> t >> n && n)
	{
		int goukei = 0;
		for (int i = 0; i < n; i++)
		{
			int st, et;
			cin >> st >> et;
			goukei += et - st;
		}
		if(goukei >= t)
			cout << "OK" << endl;
		else cout << -(goukei - t) << endl;
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while (t--)
#define rep(i,a,n) for(ll i = a ; i < n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.f << "->" << x.s << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    ll n; cin >> n;
    set<string> se;

    while(n--) {
    	string s; cin >> s;
    	se.ins(s);
    }

    cout << se.size();
}

Measured memory_bytes: 19168
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll H, W;
	cin >> H >> W;

	char s[200][200];

	repn(i, H)repn(j, W) cin >> s[i][j];


	ll dp[200][200] = {};

	if (s[1][1] == '#') { dp[1][1] = 1; }
	else { dp[1][1] = 0; }

	for (ll i = 2; i <= H; i++) {
		if (s[i][1] == '#'&&s[i - 1][1] == '.') { dp[i][1] = dp[i - 1][1] + 1; }
		else { dp[i][1] = dp[i - 1][1]; }
		//cout << i << 1 << dp[i][1]<<endl;
	}

	for (ll i = 2; i <= W; i++) {
		if (s[1][i] == '#'&&s[1][i - 1] == '.') { dp[1][i] = dp[1][i-1] + 1; }
		else { dp[1][i] = dp[1][i-1]; }
		//cout << 1 << i << dp[1][i] << endl;
	}


	for(ll i=2; i<=H; i++)for(ll j=2;j<=W; j++)  {
		if (s[i][j] == '.') { dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]); }

		else {
			ll X = dp[i - 1][j];
			ll Y = dp[i][j-1];

			if (s[i - 1][j] == '.') { X++; }
			if (s[i][j - 1] == '.') { Y++; }

			dp[i][j] = min(X, Y);
		}


		//cout <<i<<j<< dp[i][j] << endl;


	}

	cout << dp[H][W];


	system("PAUSE");

}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s; cin>>s;
    if(s[0]=='S'){
        cout<<"Cloudy"<<endl;
    }else if(s[0]=='C'){
        cout<<"Rainy"<<endl;
    }else{
        cout<<"Sunny"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,ans=1;
  cin>>x;
  for(int i=2;i<=x;i++){
    int t=i*i;
    while(t*i<=x){
      t*=i;
      //cout<<t<<endl;
    }
    if(t<=x)ans=max(ans,t);
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
ll MAX(ll a,ll b,ll c){return max(a,max(b,c));}
ll MIN(ll a,ll b,ll c){return min(a,min(b,c));}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n,k;
    cin >> n >> k;
    500*n >= k ? cout << "Yes" << endl : cout << "No" << endl;
}

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

const int maxn=2e5+7;
int n,mx;
string s[maxn];
map<string,int> f;
set<string> g;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		cin>>s[i];
		mx=max(mx,++f[s[i]]);
	}
	for(int i=1;i<=n;++i) {
		if(f[s[i]]==mx) {
			g.insert(s[i]);
		}
	}
	set<string>::iterator it=g.begin();
	do {
		cout<<*it<<endl;
	}while(++it!=g.end());
}

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

int main(){
	int n;
	cin >> n;
	int a[n];
	
	for (int i=0; i<n; i++)  cin >> a[i];
	
	int cnt=0, i;
	
	do{
		for(i=0;i<n;i++)
		   if(a[i]%2==1){
		   	cout<<cnt;
		   	return 0;
		   }
		   else
		      a[i]=a[i]/2;
		      
		cnt++;
	}while (1);
	
	cout<<n;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

typedef pair<int,int> P;

enum Type{
	Query,
	Event,
};

struct Info{
	Info(int arg_time,int arg_value_1,int arg_value_2,Type arg_type,int arg_query_id){
		time = arg_time;
		value_1 = arg_value_1;
		value_2 = arg_value_2;
		type = arg_type;
		query_id = arg_query_id;
	}
	bool operator<(const struct Info &arg) const{
		if(time != arg.time){
			return time > arg.time;
		}else{
			return query_id > arg.query_id;
		}
	}

	int time,value_1,value_2,query_id;
	Type type;
};

bool ans[100000];

int main(){

	int N,M,num_query;

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

	priority_queue<Info> Q;

	int day,from,to;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d",&day,&from,&to);
		Q.push(Info(day+1,from,to,Event,-1));
	}

	for(int i = 0; i < num_query; i++){
		scanf("%d %d %d",&day,&from,&to);
		Q.push(Info(day,from,to,Query,i));
	}

	set<P> SET;
	set<P>::iterator it_1,it_2;
	for(int i = 1; i <= N; i++)SET.insert(make_pair(i,i));
	SET.insert(make_pair(BIG_NUM,BIG_NUM));

	int new_left,new_right;
	P tmp;

	while(!Q.empty()){

		if(Q.top().type == Event){

			it_1 = SET.lower_bound(make_pair(Q.top().value_1,-1));
			it_2 = SET.lower_bound(make_pair(Q.top().value_2,-1));

			tmp = *it_1;
			if(tmp.first == Q.top().value_1){
				new_left = tmp.first;
			}else{
				it_1--;
				tmp = *it_1;
				new_left = tmp.first;
			}

			tmp = *it_2;
			if(tmp.first == Q.top().value_2){
				new_right = tmp.second;
			}else{
				it_2--;
				tmp = *it_2;
				new_right = tmp.second;
			}

			it_2++;
			SET.erase(it_1,it_2);

			SET.insert(make_pair(new_left,new_right));

			}else{

			if(Q.top().value_2 <= Q.top().value_1){
				ans[Q.top().query_id] = true;
				Q.pop();
				continue;
			}

			it_1 = SET.lower_bound(make_pair(Q.top().value_1,-1));
			it_2 = SET.lower_bound(make_pair(Q.top().value_2,-1));

			tmp = *it_1;

			if(tmp.first == Q.top().value_1){
				//Do nothing
			}else{
				it_1--;
			}

			tmp = *it_2;
			if(tmp.first == Q.top().value_2){
				//Do nothing
			}else{
				it_2--;
			}

			if(it_1 == it_2){
				ans[Q.top().query_id] = true;
			}else{
				ans[Q.top().query_id] = false;
			}
		}

		Q.pop();
	}

	for(int i = 0; i < num_query; i++){
		if(ans[i]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}

	return 0;
}



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

int main() {
 int N,M,C;
  cin>>N>>M>>C;
  vector<int>B(M);
   for(int i=0;i<M;i++){cin>>B.at(i);}
  vector<vector<int>>A(N,vector<int>(M));
   for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>A.at(i).at(j);}}
  int count=0,SUM=0;
  for(int i=0;i<N;i++){   
    for(int j=0;j<M;j++){
      SUM+=A.at(i).at(j)*B.at(j);}
    if(SUM+C>0){count++;}
    SUM=0;}        
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  int a;
  string res = "second";
  for(int i = 0; i < n; ++i){
    cin >> a;
    if(a%2 == 1){
      res = "first";
      break;
    }
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
class C:
    def __init__(self):
        self.value = []
    def append(self, n):
        self.value.append(n)

    def popleft(self):
        if not self.value:
            return -1
        else:
            ret = self.value[0]
            del self.value[0]
            return ret
    def popover(self, n):
        ret = -1
        for i, v in enumerate(self.value):
            if v > n:
                ret = v
                del self.value[i]
                break
        return ret

    def empty(self):
        return self.value == []

    @property
    def length(self):
        return len(self.value)

def main():
    while True:
        n = int(input())
        if n == 0:
            break
        taro_bool = [False] * (2 * n + 1)
        taro = C()
        hanako = C()
        for i in range(n):
            v = int(input())
            taro_bool[v] = True
        for i in range(1, 2 * n + 1):
            if taro_bool[i]:
                taro.append(i)
            else:
                hanako.append(i)
                
        ba = taro.popleft()
        teban = 1 # 0太郎 1花子
        playing = [taro, hanako]
        while not taro.empty() and not hanako.empty():
            if ba == 0:
                ba = playing[teban].popleft()
            else:
                x = playing[teban].popover(ba)
                ba = x if x > 0 else 0
            teban ^= 1
    
        print(hanako.length)
        print(taro.length)


if __name__ == '__main__':
    main()




Measured memory_bytes: 5608
package main

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

const INFTY = 2000000000

var sc = bufio.NewScanner(os.Stdin)
var L, R = make([]int, 500000+2), make([]int, 500000+2)
var count int

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func main() {

	sc.Split(bufio.ScanWords)
	n := nextInt()
	A := make([]int, n)
	for i := range A {
		A[i] = nextInt()
	}
	mergeSort(A, 0, n)

	result := strings.TrimRight(fmt.Sprintf("%+v", A)[1:], "]")
	fmt.Println(result)
	fmt.Println(count)
}
func mergeSort(A []int, left int, right int) {
	if left+1 < right {
		mid := (right + left) / 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)
	}
}
func merge(A []int, left int, mid int, right int) {
	n1 := mid - left
	n2 := right - mid
	for i := 0; i < n1; i++ {
		L[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		R[i] = A[mid+i]
	}
	L[n1] = INFTY
	R[n2] = INFTY
	i := 0
	j := 0
	for k := left; k < right; k++ {
		count++
		if L[i] <= R[j] {
			A[k] = L[i]
			i++
		} else {
			A[k] = R[j]
			j++
		}
	}
}



Measured memory_bytes: 45032
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll P = 1e9+7;
const ll N = 1e6+7;

bool check(vector<ll> &v, ll i){
	if(v[i] == v[i+1] and v[i+1] == v[i+2] and v[i] == 0) return true;
	return false;	
}

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

	ll t=1;
	// cin>>t;

	while(t--){
		ll n;
		cin>>n;

		vector<ll> v;
		ll a,b;
		for(ll i=0;i<n;++i){
			cin>>a>>b;
			v.push_back(a-b);
		}

		// for(auto &x : v) cout<<x<<" ";
		// cout<<"\n";  

		bool ok = false;
		for(ll i=0;i<n-2;++i){
			if(check(v,i)) {ok = true;}
		}

		if(ok) cout<<"Yes\n";
		else cout<<"No\n";

	}

	return 0;
}	


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

int main(){
	vector<vector<int>> c(3, vector<int>(3));
	int sum = 0;
	REP(i, 3){
		REP(j, 3){
			cin >> c[i][j];
			sum += c[i][j];
		}
	}
	vector<int> a(3);
	vector<int> b_1(3);
	vector<int> b_2(3);
	vector<int> b_3(3);

	if(sum % 3 != 0){
		cout << "No" << endl;
		return 0;
	}else{
		REP(a1, 101){
			REP(a2, 101){
				REP(a3, 101){
					a[0] = a1;
					a[1] = a2;
					a[2] = a3;
					b_1[0] = c[0][0] - a1;
					b_1[1] = c[0][1] - a1;
					b_1[2] = c[0][2] - a1;
					b_2[0] = c[1][0] - a2;
					b_2[1] = c[1][1] - a2;
					b_2[2] = c[1][2] - a2;
					b_3[0] = c[2][0] - a3;
					b_3[1] = c[2][1] - a3;
					b_3[2] = c[2][2] - a3;

					if(b_1[0] == b_2[0] && b_1[1] == b_2[1] && b_1[2] == b_2[2] && b_3[0] == b_2[0] && b_3[1] == b_2[1] && b_3[2] == b_2[2]){
						cout << "Yes" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "No" << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
long long f[1<<16],a[1<<16];
int s[17][17],b[1<<16];
int lowbit(int x)
{
    return x&-x;
}
int main()
{
    int p,i,j,n,x,y,z;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
            scanf("%d",&s[i][j]);
        b[1<<(n-i)]=i;
    }
    for(i=1;i<(1<<n);i++)
    {
        x=lowbit(i);
        y=b[x];
        z=x^i;
        a[i]=a[z];
        while(z)
        {
            p=lowbit(z);
            a[i]+=s[y][b[p]];
            z-=p;
        }
    }
    for(i=0;i<(1<<n);i++)
    {
        //f[i]=a[i];
        for(j=i;j;j=(j-1)&i)
            f[i]=max(f[i],a[j]+f[i^j]);
    }

    printf("%lld",f[(1<<n)-1]);
    return 0;
}

Measured memory_bytes: 1280
n, m, x = gets.split.map(&:to_i)
costs = Array.new
effects = Array.new
n.times do
  effect = gets.split.map(&:to_i)
  cost = effect.shift
  costs.push cost
  effects.push effect
end

# 可能なのは高々2**n通りで、n<=12

min_cost = Float::INFINITY
(0...(2**n)).each do |i|
  cost_sum = 0
  effect_sum = Array.new(m, 0)
  (0...n).each do |bit|
    mask = 1 << bit
    if (i & mask) > 0
      cost_sum += costs[bit]
      m.times do |j|
        effect_sum[j] += effects[bit][j]
      end
    end
  end
  if effect_sum.select{|e| e < x}.empty?
    if cost_sum < min_cost
      min_cost = cost_sum
    end
  end
end

puts min_cost.infinite? ? -1 : min_cost


Measured memory_bytes: 14656
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set



signed main(){
    ll n;cin>>n;
    char s[500000];cin>>s;
    //それぞれのアルファベットのインデックス
    vector<set<ll>> alph(26);
    vector<ll> a(n);
    REP(i,n){alph[ll(s[i]-'a')].insert(i);a[i]=ll(s[i]-'a');}
    ll q;cin>>q;
    vector<ll> ans;
    REP(_,q){
        ll x;cin>>x;
        if(x==1){
            //iを--し忘れていた
            ll i;char c;cin>>i>>c;i--;
            ll j=ll(c-'a');ll k=a[i];a[i]=j;
            //ここで永遠にバグらせた
            alph[k].erase(i);
            alph[j].insert(i);
        }else{
            ll ans=0;
            ll l,r;cin>>l>>r;l--;r--;
            REP(i,26){
                auto y=alph[i].lower_bound(l);
                if(y!=alph[i].end())if(*y<=r)ans++;
            }
            cout<<ans<<endl;
        }
    }
}

Measured memory_bytes: 31240
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;

ll n, m;

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

    cin >> n >> m;

    if(n == 1 || m == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    ll ans = m * (n / 2);
    if(n & 1)
        ans += (m + 1) / 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256