akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> nextk(n + 1, vector<int>(21));
  for (int i = 0; i < n + 1; i++) nextk[i][0] = i;
  map<ll, int> bef;
  map<ll, int> first;
  for (int i = 0; i < n; i++) {
    if (bef.find(a[i]) == bef.end()) {
      first[a[i]] = i;
      bef[a[i]] = i;
    } else {
      nextk[bef[a[i]]][0] = i + 1;
      bef[a[i]] = i;
    }
  }

  for (int k = 1; k <= 20; k++) {
    for (int i = 0; i < n + 1; i++) {
      nextk[i][k] = nextk[nextk[i][k - 1]][k - 1];
    }
  }

  vector<ll> c;
  c.push_back(0);
  ll now = 0;
  while (now < n && nextk[now][20] < n) {
    ll v = a[nextk[now][20]];
    c.push_back(v);
    now = first[v] + 1;
  }

  k--;
  int p = c[k % c.size()];

  first[0] = -1;
  vector<int> ans;
  vector<bool> used(202020);
  for (int i = first[p] + 1; i < n; i++) {
    if (used[a[i]]) {
      while (a[i] != ans.back()) {
        used[ans.back()] = false;
        ans.pop_back();
      }
      used[ans.back()] = false;
      ans.pop_back();
    } else {
      ans.push_back(a[i]);
      used[a[i]] = true;
    }
  }

  if (ans.size() == 0) {
    return 0;
  }

  cout << ans[0];
  for (int i = 1; i < ans.size(); i++) cout << " " << ans[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 54900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

int main(){
    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy";
    }else if(S == "Cloudy"){
        cout << "Rainy";
    }else{
        cout << "Sunny";
    }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,W;
  cin >> n >> W;
  vi value(n), weight(n);
  rep(i, n) cin >> weight[i] >> value[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));
  rep(i, n){
    rep(w, W + 1){
      if(w >= weight[i]) dp[i + 1][w] = max(dp[i][w - weight[i]] + value[i], dp[i][w]);
      else dp[i + 1][w] = dp[i][w];
    }
  }
  cout << dp[n][W] << endl;
}

Measured memory_bytes: 80256
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {

//		long ans = 0;
//		long ans2 = 0;
		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);


//		long n = sc.nextLong();
//		long m = sc.nextLong();
//		long k = sc.nextLong();

		int n = sc.nextInt();
//		int m = sc.nextInt();
//		int k = sc.nextInt();
//		int v = sc.nextInt();
//		String s = sc.next();


//		String string = sc.next();
//		StringBuilder s = new StringBuilder(string);
//		String string2 = sc.next();
//		StringBuilder s2 = new StringBuilder(string);

		boolean f = false;

		String[] s = new String[n];

		int[] a = new int[n];
//		long[] a = new long[n];

//		int[][] a = new int[n][m];



//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}

		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			a[i] = sc.nextInt();
		}
		String x = sc.next();

//		if() {
//
//		} else {
//
//		}


		for(int i = 0; i < n; i++) {
			if(f)ans += a[i];
			if(x.equals(s[i])) {
				f = true;
			}
		}

		System.out.println(ans);

		sc.close();
	}


}

Measured memory_bytes: 22868
#include <iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int S, W;
    cin >> S >> W;
    if (W >= S) {
        cout << "unsafe" << endl;
    } else cout << "safe" << endl;
    
}

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

int main() {
  int N,M;
  cin >> N >> M;

  // N要素の配列
  vector<int> A(N);

  // 入力処理
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }

  int d ;
  for (int i =0; i <N; i++){
    d += A.at(i) ;}
  int sum = 0;

  // 合計点を計算
  for (int i = 0; i < N; i++) {
  if (A.at(i)*4*M >= d) {
    // ①ここにプログラムを追記
    sum ++;
  }
  }
    if (sum >= M) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
}
  




Measured memory_bytes: 256
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A < B:
    a_max = A + V*T
    b_max = B + W*T
    if a_max >= b_max:
        print('YES')
    else:
        print('NO')
else:
    a_min = A - V*T
    b_min = B - W*T
    if a_min <= b_min:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
int main(void)

{
    int64_t a,b,c,x,r,tmp;

    cin >> a >> b;

    x = a * b;
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 cout<< x/b <<endl;
  return 0;
}
	
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int a(0),b,c,ans(0),tmp(0);
  	string s;
  	
  	cin >> a;
  	vector<int>x(a);
  	for(int i = 1;i < a+1;i++){
      cin >> b;
      if(i % 2 != 0){
        if(b % 2 != 0){
          ans++;
        }
      }
    }
  cout << ans;
  
}
   


Measured memory_bytes: 3628
#include <stdio.h>
#define N 100000
#define F 50000
#define FOUND 1
#define NOT_FOUND 0

int binarySearch(int *,int,int);

int main(){
  int array[N];
  int i,a,b,c,key,cnt=0;
  
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&array[i]);
  }

  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&key);
    c=binarySearch(array,key,a);
    if(c==1) cnt++;
  }

  printf("%d\n",cnt);
  
  return 0;
}

int binarySearch(int *A,int key,int n){
  int left=0;
  int right=n;
  int mid=0;
  while(left<right){
    mid=(left + right)/2;
    if(A[mid] == key){
      return FOUND;
    } else if(key<A[mid]){
      right = mid;
    }
    else{
      left = mid + 1;
    }
  }
  return NOT_FOUND;
}




Measured memory_bytes: 2108
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "from", int, "to", int, "cost");

void main() {
    int N, M;
    scan(N, M);

    auto es = new Edge[](M);
    auto adj = new int[][](N, 0);

    foreach (i ; 0 .. M) {
        int ai, bi, ci;
        scan(ai, bi, ci);
        ai--, bi--;
        es[i] = Edge(ai, bi, -ci);
        adj[bi] ~= ai;
    }

    auto reachable = new bool[](N);

    void dfs(int v) {
        reachable[v] = true;
        foreach (u ; adj[v]) if (!reachable[u]) {
            dfs(u);
        }
    }

    dfs(N - 1);

    es = es.filter!(e => reachable[e.to]).array;
    M = es.length.to!int;

    auto ans = bellman(N, es)[N - 1];

    writeln(ans < inf6 ? (-ans).to!string : "inf");
}

long[] bellman(int N, Edge[] es) {
    auto dist = new long[](N);
    dist[] = inf6;
    dist[0] = 0;

    foreach (i ; 0 .. N - 1) {
        foreach (e ; es) {
            if (dist[e.from] < inf6 && dist[e.from] + e.cost < dist[e.to]) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }

    foreach (e ; es) {
        if (dist[e.from] < inf6 && dist[e.from] + e.cost < dist[e.to]) {
            return repeat(inf6, N).array;
        }
    }

    return dist;
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 2428
from operator import add

n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for _ in range(n)]
cost = []
for i in range(2 ** n):
  total = 0
  algo = [0] * m
  for j in range(n):
    if ((i >> j) & 1):
      algo = map(add, algo, books[j][1::])
      total += books[j][0]

  count = 0
  for k in algo:
    if k >= x:
      count += 1
  
  if count == m:
    cost.append(total)

if cost != []:
  print(min(cost))
else:
  print(-1)

Measured memory_bytes: 9428
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

constexpr int INF = 1e8;

int main() {

    int N, M;
    cin >> N >> M;

    vector<vector<int >> graph(N, vector<int>(N, INF));
    vector<pair<int, pair<int, int>>> edges(M);

    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges[i] = (make_pair(c, make_pair(a, b)));
        graph[a][b] = c;
        graph[b][a] = c;
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        int cost = edges[i].first;
        int u = edges[i].second.first;
        int v = edges[i].second.second;
        if(cost > graph[u][v]){
            ans++;
        }
    }

    cout << ans <<endl;

}

































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

anslist = [1]*N
for i in range(M):
  A,B = map(int,input().split())
  #print (Hlist[A-1])
  #print (Hlist[B-1])
  if Hlist[A-1]<Hlist[B-1]:
    anslist[A-1]=0
  elif Hlist[A-1]>Hlist[B-1]:
    anslist[B-1]=0
  elif Hlist[A-1]==Hlist[B-1]:
    anslist[A-1]=0
    anslist[B-1]=0
    
#print (anslist)
print (sum(anslist))

Measured memory_bytes: 20108
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


struct UnionFind {
    vector<ll> par;
        
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
    
    ll find(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    
    bool same(ll x, ll y) {
        return find(x) == find(y);
    }
    
    bool unite(ll x, ll y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    ll size(ll x) {
        return -par[find(x)];
    }

    void print(ll x){
        rep(i,x){
            cout<<par[i]<<endl;
        }
        return ;
    }
};


void solve(){
    string s;
    cin>>s;
    ll a[10]={};
    rep(i,4){
        a[i]=s[i]-'0';
    }
    rep(bit,8){
        ll sum=a[0];
        string t;
        t+=s[0];
        rep(i,3){
            if(bit&(1<<i)){
                sum+=a[i+1];
                t+='+';
                t+=s[i+1];
            }
            else{
                sum-=a[i+1];
                t+='-';
                t+=s[i+1];
            }
        }
        if(sum==7){
            cout<<t<<"=7"<<endl;
            return ;
        }
    }
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
import collections
N=int(input())
S=[]
for i in range(N):
   S.append(str(input())) 
c=collections.Counter(S)
c_sorted=sorted(c.items(),key=lambda x:x[0])
s=max(c.values())
for i in c_sorted:
    if i[1]==s:
        print(i[0])

Measured memory_bytes: 48436
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int n, m, x;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &x);
    n -= x;
  }
  if (n < 0) {
    puts("-1");
  } else {
    printf("%d\n", n);
  }
  return 0;
}


Measured memory_bytes: 3792
#define KAKUSUKO

#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N;
int D[MAX_N];
bool exist[MAX_N];


//x^nをmodのもとで計算する
ll mod_pow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll res = mod_pow((x*x) % mod, n/2, mod);
    if (n & 1) res = (res*x) % mod;
    return res;
}

int main() {
    cin >> N;
    rep(i, N) cin >> D[i];

    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }

    sort(D, D + N);
    rep(i, N) exist[D[i]] = true;

    if (D[0] == D[1]) {
        cout << 0 << endl;
        return 0;
    }

    int first_not_exist_num = 0;
    while (first_not_exist_num < N && exist[first_not_exist_num]) ++first_not_exist_num;

    for (int i = first_not_exist_num; i < N; ++i) {
        if (exist[i]) {
            cout << 0 << endl;
            return 0;
        }
    }


    vector<ll> accum;
    accum.push_back(1);
    for (int i = 1; i < N; ++i) {
        int tmp = 1;
        while (i+1 < N && D[i] == D[i+1]) {
            ++tmp; ++i;
        }
        accum.push_back(tmp);
    }

    ll ans = 1;
    for (int i = 1; i < len(accum); ++i) {
        ans = mod(ans*mod_pow(accum[i-1], accum[i], MOD), MOD);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h> //ライブラリ全読み込み
using namespace std; //std:を省略できる

int main(){
    int x;
    int buf=1;
    cin >> x;
    while (x!=0){
        cout <<"Case "<<buf<<": "<<x<< endl;
        buf++;
        cin >> x;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
using namespace std;
int n;
vector<vector<int>> f;

bool input(){
  int x,y;
  cin>>x>>y;
  cin>>n;
  f.clear();
  if(x==y&&y==n&&n==0)return false;
  f.resize(x);
  for(int i=0;i<f.size();i++){
    f[i].resize(y);
  }
  for(int i=0;i<f.size();i++){
    for(int j=0;j<f[i].size();j++){
      cin>>f[i][j];
    }
  }
  return true;
}

bool inside(vector<vector<int>> &c,int x,int y){
  if(x<0)return false;
  if(y<0)return false;
  if(c.size()<=x)return false;
  if(c[x].size()<=y)return false;
  return true;
}

pair<int,int> solve(){
  vector<vector<int>> change;
  change.resize(f.size());
  for(int i=0;i<change.size();i++){
    change[i].resize(f[i].size());
  }
  change[0][0] = n-1;
  for(int i=0;i<change.size();i++){
    for(int j=0;j<change[i].size();j++){
      if(change[i][j] <= 0)continue;
      if(inside(change,i+1,j))change[i+1][j] += change[i][j]/2;
      if(inside(change,i,j+1))change[i][j+1] += change[i][j]/2;
      if(change[i][j]%2){
        if(f[i][j]==0){
          if(inside(change,i+1,j))change[i+1][j]++;
        }else{
          if(inside(change,i,j+1))change[i][j+1]++;
        }
      }
    }
  }
  /*
  for(auto i:f){
    for(auto j:i){
      cout<<j<<" ";
    }cout<<endl;
  }cout<<endl;
  for(auto i:change){
    for(auto j:i){
      cout<<j<<" ";
    }cout<<endl;
  }cout<<endl;
  */
  for(int i=0;i<change.size();i++){
    for(int j=0;j<change[i].size();j++){
      if(change[i][j]%2==1){
        f[i][j] = !f[i][j];
      }
    }
  }
  /*
  for(auto i:f){
    for(auto j:i){
      cout<<j<<" ";
    }cout<<endl;
  }cout<<endl;
  */
  pair<int,int> res(0,0);
  while(res.first<change.size()&&res.second<change[0].size()){
    if(f[res.first][res.second]==0){
      res.first++;
    }else{
      res.second++;
    }
  }
  res.first++;
  res.second++;
  return res;
}


int main(){
  while(input()){
    auto ans = solve();
    cout<<ans.first<<" "<<ans.second<<endl;
  }
}

Measured memory_bytes: 8980
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),k=sc.nextInt();
        int[] h=new int[n];
        for(int i = 0;i<n;i++)h[i]=sc.nextInt();
        Arrays.sort(h);
        int ans = h[n-1]-h[0];
        for(int i = 0;i+k-1<n;i++){
            if(ans>h[i+k-1]-h[i])ans=h[i+k-1]-h[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 59480
#include <stdio.h>

int digit(int x){
  if(x % 2 != 0) return 0;
  else       return 1 + digit(x/2);
}

int main(void){
  
  int ans,a,i,n;
  
  scanf("%d",&n);
  
  for( ans=0, i=0; i<n; i++){
    scanf("%d", &a);
    ans += digit(a);
  }
  
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 128
N = int(input())
arr = [int(i) for i in input().split()]
cost = [0 for _ in range(N)]
cost[0] = 0
cost[1] = abs(arr[1]-arr[0])
for i in range(2,N):
    cost1 = cost[i-1] + abs(arr[i] - arr[i-1])
    cost2 = cost[i-2] + abs(arr[i] - arr[i-2])
    cost[i] = min(cost1,cost2)
print(cost[N-1])

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

using namespace std;

typedef long long ll;

// Scan and Debug
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

const int MAX = 21, MSUB = 1 << MAX, MOD = 1000000007;
int n,
    dp[MSUB];
bool comp[MAX][MAX]; // comp[i][j] -> man i and woman j are compatible

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

    scan(n);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scan(comp[i][j]);

    int msub = (1 << n) - 1;
    dp[0] = 1;
    for (int i = 0; i < msub; i++) {
        int curMan = __builtin_popcount(i);
        for (int j = 0; j < n; j++) {
            if((i >> j) & 1)
                continue;

            if(comp[curMan][j]) {
                int &val = dp[i | (1 << j)];
                val = (val + dp[i]) % MOD;
            }
        }
    }

    printf("%d\n", dp[(1 << n) - 1]);

    return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int dp[ten5];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,small=0;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=0,now=0;
    set <int> sint;
    //float f,g,h;
    //char now,pre;
    //string a;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        if(sint.find(m)==sint.end())
            sint.insert(m);
        else
            sint.erase(m);
    }
    cout<<sint.size();
    return 0;
}





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

using namespace std;

int main(){
        string s,t;
        cin >> s >> t;
        if(s[0] == t[2] && s[2] == t[0] && s[1] == t[1]){
                cout << "YES" << endl;
        }else{
                cout << "NO" << endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX(a,b) (a>b?a:b)
int main(void){
	int i,n;
	long p;
	long t[1001],a[1001];
	unsigned long vote_t,vote_a;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	    scanf("%ld %ld",&t[i],&a[i]);
	    
	vote_t = t[0];
	vote_a = a[0];
	
	for(i=1;i<n;i++){
		p = MAX((vote_t+t[i]-1)/t[i],(vote_a+a[i]-1)/a[i]);
		vote_t = p*t[i];
		vote_a = p*a[i];
	}
	
	printf("%ld\n",vote_t + vote_a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int H, W; cin >> H >> W;
    vs S(H); REP(i, H) cin >> S[i];
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, -1, 0, 1};
    int ans = 0;
    REP(i, H)
    {
        REP(j, W)
        {
            if(S[i][j] == '#') continue;
            vvi d(H, vi(W, INF));
            d[i][j] = 0;
            queue<P> q;
            q.push(make_pair(i, j));
            while(!q.empty())
            {
                P p = q.front(); q.pop();
                REP(k, 4)
                {
                    int y = p.first + dy[k];
                    int x = p.second + dx[k];
                    if(0 <= y && y < H && 0 <= x && x < W && S[y][x] == '.' && d[y][x] == INF)
                    {
                        d[y][x] = d[p.first][p.second]+1;
                        ans = max(ans, d[y][x]);
                        q.push(make_pair(y, x));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){

	int n;

	while(cin >> n){
		int i, j, k, l;
		int count=0;

		for(i=0 ; i<10 ; i++){
			for(j=0 ; j<10 ; j++){
				for(k=0 ; k<10 ; k++){
					for(l=0 ; l<10 ; l++){
						if((i+j+k+l) == n)count++;
					}
				}
			}
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

def rev_mod(num):
	pow_num = MOD - 2
	ret = 1
	while pow_num > 0:
		if pow_num % 2:
			ret *= num
			ret %= MOD
		num *= num
		num %= MOD
		pow_num /= 2
	return ret

N, A, B, C = map(int, raw_input().split())

ans = 0

for loop in range(2):
    cnt = 0
    P = 1
    comb = 1
    PA = (A * rev_mod(A + B)) % MOD
    PB = (B * rev_mod(A + B)) % MOD
    PCm = 100 * rev_mod(100 - C) % MOD
    for i in range(N - 1):
        P *= PA
        P %= MOD

    for i in range(N):
        ans += PCm * (N + i) % MOD * P % MOD * comb % MOD * PA
        ans %= MOD
        P *= PB
        P %= MOD
        comb *= N + i
        comb %= MOD
        comb *= rev_mod(i + 1)
        comb %= MOD
    A, B = B, A
print ans

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

int main() {
    int h, a, x;
    cin >> h >> a;
  
    long long sum = 0;
    for(int i=0; i<a; i++) {
        cin >> x;
        sum += x;
    }
    
    if(sum >= h)
  	    cout << "Yes" << endl;
    else
        cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
//	freopen("output.txt","w",stdout);
	int a,b;
	cin>>a>>b;
	cout<<100<<" "<<100<<endl;
	rep(i,0,100)
	{
		rep(j,0,100)
		{
			if(i<50)putchar((i%2 && j%2 && --a>0)?'.':'#');
			else putchar((i%2 && j%2 && --b>0)?'#':'.');
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn = 1e6 + 5;
const long long mod = 1e9 + 7;
using namespace std;

char s[maxn];

int main(){
	scanf(" %s", s + 1);
	if(s[3] == s[4] && s[5] == s[6]) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define ull unsigned long long

int main(void){
  int n;
  int a[1000000]={};

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    int b;
    scanf("%d",&b);
    a[b]++;
  }

  ull ans=0;

  if(n%2==0){
    for(int i=0;i<n;i++){
      if(i%2==1&&a[i]!=2)
        goto ABC;
    }
  }
  else{
    if(a[0]!=1) goto ABC;
    for(int i=1;i<n;i++){
      if(i%2==0&&a[i]!=2)
        goto ABC;
    }
  }
  ans = 1;
  n/=2;
  while(n>0){
    ans *=2;
    ans%=1000000007;
    n--;
  }

  ABC:

  printf("%llu\n",ans);

  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

    // split the string in 2

    string s, s1, s2;
    cin >> s;

    // do both print min
    int n;
    n = s.size() / 2;

    if (s.size() % 2 == 0){
        s1 = s.substr(0, n);
        s2 = s.substr(n, s.size());
    } else {
        s1 = s.substr(0, n);
        s2 = s.substr(n + 1, s.size());
    }

    reverse(s2.begin(), s2.end());
    
    int s1Min = 0;

    for (int i = 0; i < s1.size(); i++){
        if (s1[i] != s2[i]) s1Min++;
    }

    cout << s1Min << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll Perm(ll x, ll y) {
    if(x < y || x < 0 || y < 0) {
        return 0;
    }
    ll res = 1;
    rep(i, y) {
        res *= x;
        res %= mod;
        x--;
    }
    return res;
}

vvl G;
ll n, k;
ll ans;

void dfs(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    if(p == -1) {  // 根の場合
        ans *= Perm(k-1, G[v].size());  // 根の色以外のk-1色から、根の子の数だけ選んで並べる順列数通り塗り方がある
    }
    else {  // 根以外の場合
        ans *= Perm(k-2, G[v].size()-1);  // 親と、親の親以外の色のk-2色から「親の子の数」だけ選んで並べる順列数通り塗り方がある
    }
    ans %= mod;
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        dfs(u, v);
        // 帰りの処理はこのへんに書く
    }
}

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

    G.resize(n);
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }

    ans = k;  // 根はk色から好きな色で塗れる
    const ll root = 0;
    dfs(root);

    out(ans);
    re0;
}

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

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

const long long MOD = 1000000007;

void solve(long long N, std::vector<long long> A){
    ll sum=0;
    ll d=1;
    rep(i,60){
        ll c=0;
        for(int j=0;j<N;j++){
              (A[j]&1)?c++:1;
              A[j]=A[j]>>1;
        }
        sum+=(c*(N-c)%MOD*d)%MOD;
        d=2*d%MOD;
    }
    cout<<sum%MOD<<endl;
}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

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

  int cells = 0;
  vector<vector<char>> grid(H);
  rep(i,0,H-1) {
    vector<char> row(W);
    rep(j,0,W-1) {
      cin >> row[j];
      if (row[j] == '#') cells++;
    }
    grid[i] = row;
  }

  vector<vector<bool>> r_choices;
  for (int i = 0; i < 1 << H; ++i) {
    vector<bool> v;
    rep(j,0,H-1) {
      if (i & (1 << j)) v.push_back(1);
      else v.push_back(0);
    }
    r_choices.push_back(v);
  }

  vector<vector<bool>> c_choices;
  for (int i = 0; i < 1 << W; ++i) {
    vector<bool> v;
    rep(j,0,W-1) {
      if (i & (1 << j)) v.push_back(1);
      else v.push_back(0);
    }
    c_choices.push_back(v);
  }

  int ans = 0;
  for (vector<bool> r : r_choices) {
    for (vector<bool> c : c_choices) {
      int t = cells;
      rep(i,0,H-1) {
        if (r[i]) {
          rep(j,0,W-1) {
            if (grid[i][j] == '#') t--;
          }
        }
      }
      rep(i,0,W-1) {
        if (c[i]) {
          rep(j,0,H-1) {
            if (grid[j][i] == '#') t--;
          }
        }
      }
      rep(i,0,H-1) {
        rep(j,0,W-1) {
          if (r[i] && c[j] && grid[i][j] == '#') t++;
        }
      }
      if (t == K)
        ans++;
    }
  }

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


Measured memory_bytes: 3632
import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, D, A, *XH = map(int, read().split())
    monster = [0] * N
    for i, (x, h) in enumerate(zip(*[iter(XH)] * 2)):
        monster[i] = (x, (h + A - 1) // A)

    monster.sort()

    pos = []
    damage = []
    left = right = 0

    cum_damage = 0
    ans = 0

    for x, h in monster:
        left = right
        right = bisect_left(pos, x)
        cum_damage -= sum(damage[left:right])

        if h > cum_damage:
            pos.append(x + 2 * D)
            damage.append(h - cum_damage)
            ans += h - cum_damage
            cum_damage += h - cum_damage

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 148056
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
    String str3 = sc.next();
    if(str1.charAt(str1.length()-1) == str2.charAt(0) &&
      str2.charAt(str2.length()-1) == str3.charAt(0)){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

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

//?????????
#define AG 200
#define BG 300
#define CG 500
//?????????
#define AM 380
#define BM 550
#define CM 850
//??????????????????
#define AN 5
#define BN 4
#define CN 3
//??????????????????
#define AP 20
#define BP 15
#define CP 12

int main(){
	int g;
	int a,b,c;
	int total;
	int money,work;
	
	while(1){
	 cin>>g;
	 if(g==0){break;}
	 a=0;b=0;c=0;
	 total=0;money=0;
	 
	 for(c=0;c*CG<=g;c++){
	  for(b=0;c*CG+b*BG<=g;b++){
		total=c*CG+b*BG;
		a=(g-total)/200;
		total+=a*AG;
		if(total!=g){continue;}
		//???????¨????
		work=(a/AN)*AN*AM*(100-AP)/100+(a%AN)*AM + (b/BN)*BN*BM*(100-BP)/100+(b%BN)*BM + (c/CN)*CN*CM*(100-CP)/100+(c%CN)*CM;
		if(money==0 || money>work){money=work;}
	  }
	 }
	 
	 cout<<money<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type Node struct {
	id     int
	weight int
}

func init() {
	sc.Split(bufio.ScanWords)
}

type NodeHeap []Node

func (h NodeHeap) Len() int           { return len(h) }
func (h NodeHeap) Less(i, j int) bool { return h[i].weight < h[j].weight }
func (h NodeHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *NodeHeap) Push(x interface{}) {
	*h = append(*h, x.(Node))
}

func (h *NodeHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()

	list := make([][]int, n)
	seen := make([]bool, n)
	for i := range list {
		list[i] = make([]int, n)
		for j := range list[i] {
			list[i][j] = scanInt()
		}
	}

	start := Node{id: 0, weight: 0}
	h := &NodeHeap{start}
	heap.Init(h)

	sum := 0
	for h.Len() > 0 {
		node := heap.Pop(h).(Node)
		if seen[node.id] {
			continue
		}
		seen[node.id] = true
		sum += node.weight

		for i, w := range list[node.id] {
			if w < 0 {
				continue
			}
			heap.Push(h, Node{id: i, weight: w})
		}
	}

	fmt.Println(sum)
}



Measured memory_bytes: 1980
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

A = inpl()
B = inpl()
if A[0] != B[0]:
    print(1)
else:
    print(0)

# -----------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll t;
  // cin>>t;
  t=1;
  while(t--){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n), dp(k+1,0);
    forn(i,0,n)
      cin>>a[i];
    forn(i,0,k){
      if(dp[i] == 0){
        forn(j,0,n){
          if(i+a[j] <= k)
            dp[i+a[j]] = 1;
        }
      }
    }
    ll ans = dp[k];
    if(ans == 1)
      cout<<"First\n";
    else
      cout<<"Second\n";
  }
  return 0;
}


Measured memory_bytes: 3984
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		char[][] a = new char[n][n];
		char[][] b = new char[m][m];
		String ans = "";

		for (int i = 0; i < n; i++) {
			String tmp = scanner.next();
			for (int j = 0; j < n; j++) {
				a[j][i] = tmp.charAt(j);
			}
		}

		for (int i = 0; i < m; i++) {
			String tmp = scanner.next();
			for (int j = 0; j < m; j++) {
				b[j][i] = tmp.charAt(j);
			}
		}

		for (int i = 0; i < n - m + 1; i++) {
			for (int j = 0; j < n - m + 1; j++) {
				out_of_loop: for (int s = 0; s < m; s++) {
					for (int k = 0; k < m; k++) {
						if (a[j + k][i + s] != b[k][s]) {
							ans = "No";
							break out_of_loop;
						} else {
							ans = "Yes";
						}
					}
				}
				if (ans.equals("Yes")) {
					System.out.println(ans);
					return;
				}
			}
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 21716
W, H, x, y = map(int, input().split())

center_x = float(W)/2
center_y = float(H)/2

if center_x == float(x) and center_y == float(y):
    num = 1
else:
    num = 0

area = float(W)*float(H)/2
print(area, end=' ')
print(num)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,m,d=map(int,input().split())
    if d==0:
        val=n/n**2
    else:
        val=2*(n-d)/n**2
    print(val*(m-1))
    
resolve()

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

int main(){
  int N; cin >> N;
  string S; cin >> S;
  int K; cin >> K;
  for(int i=0; i<N; i++){
    if(S[i]!=S[K-1]){cout << '*';}
    else{cout << S[K-1];}
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

int A,B,a,b,c;

scanf("%d %d",&A,&B);
a=A+B;
b=A-B;
c=A*B;

if(a>=b && a>=c){
   printf("%d\n",a);
}
else if(b>=a && b>=c){
    printf("%d\n",b);
}

else{
     printf("%d\n",c);
}


return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

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

//---------------------------------------------------------------------------------------------------
struct Process {
    string name;
    int time;
    Process(string n, int t) : name(n), time(t) {}
};

signed main() {
    int N, Q;
    cin >> N >> Q;
    queue<Process> que;
    rep(i, 0, N) {
        string name;
        cin >> name;
        int time;
        cin >> time;
        que.push(Process(name, time));
    }

    vector<Process> ans;
    int now = 0;
    while (!que.empty()) {
        auto p = que.front();
        que.pop();
        if (p.time <= Q) {
            now += p.time;
            ans.push_back(Process(p.name, now));
        } else {
            now += Q;
            p.time -= Q;
            que.push(p);
        }
    }
    for (const auto &p : ans) {
        cout << p.name << " " << p.time << "\n";
    }
}



Measured memory_bytes: 7192
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

int n;
string s;
ll m,a,r,c,h;
ll name[5];
int P[10]={0,0,0,0,0,0,1,1,1,2};
int Q[10]={1,1,1,2,2,3,2,2,3,3};
int R[10]={2,3,4,3,4,4,3,4,4,4};

int main(){
    cin>>n;
    rep(i,0,n){
        cin>>s;
        if(s[0]=='M') m++;
        if(s[0]=='A') a++;
        if(s[0]=='R') r++;
        if(s[0]=='C') c++;
        if(s[0]=='H') h++;
    }
    name[0]=m;name[1]=a;name[2]=r;name[3]=c;name[4]=h;

    ll ans=0;
    rep(i,0,10) ans+=name[P[i]]*name[Q[i]]*name[R[i]];

    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
Blue_Cards = []
for i in range(N):
    Blue_Cards. append(input())
M = int(input())
Red_Cards = []
for n in range(M):
    Red_Cards. append(input())
Q = 0
for l in range(N):
    P = int(Blue_Cards. count(Blue_Cards[l]))-int(Red_Cards. count(Blue_Cards[l]))
    if P > Q:
        Q = P
print(Q)


Measured memory_bytes: 3060