akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    int a;
    cin >> a;
    set<int> s;
    
    while(s.count(a) == 0){
        s.it(a);
        if(a&1){
            a = 3 * a + 1;
        }else{
            a = a/2;
        }  
    }
    P(sz(s)+1);
	return  0;
}

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

unordered_map<int, unordered_map<int, unordered_map<int, int>>> ex;

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

ll A, B, C;

void del(int x, int y, int z) {
	ex[x][y][z] = 1;
}

bool find(int x, int y, int z) {
	if (x < 0 || A <= x) return false;
	if (y < 0 || B <= y) return false;
	if (z < 0 || C <= z) return false;
	return !ex[x][y].count(z);
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> A >> B >> C >> N;
	ll res = A * B * 2 + B * C * 2 + C * A * 2;
	while (N--) {
		int x, y, z;
		cin >> x >> y >> z;
		int c0 = 0, c1 = 0;
		for (int i = 0; i < 6; i++) {
			(find(x + dx[i], y + dy[i], z + dz[i]) ? c1 : c0) += 1;
		}
		res += c1 - c0;
		del(x, y, z);
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3988
#include <stdio.h>
int main(){
  int a,b,c,ans=0;
  scanf("%d",&a);
  scanf("%d",&b);
  if(b == 1){
      ans=0;
      printf("%d",ans);
  }else{
  c = a-b;
  ans = c;
  printf("%d",ans);
}
  return 0;
}

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

using namespace std;



int main() {
    int i;
    string s;
    cin>>s;
    for(i=0;i<4;i++) cout<<s[i];
    cout<<' ';
    for(;i<(int)(s.size());i++) cout<<s[i];
    cout<<endl;
}


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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> v(k);
  vector<int> w(k);
  for(int i=0; i<k; i++) v[i] = a+i;
  for(int i=0; i<k; i++) w[i] = b-k+1+i;
  
  set<int> s;
  for(int i=0; i<k; i++) {
    if(a<=v[i] && v[i]<=b) s.insert(v[i]);
    if(a<=w[i] && w[i]<=b) s.insert(w[i]);
  }
  for(auto t : s) cout << t << endl;
  return 0;
}

Measured memory_bytes: 3588
//============================================================================
// Name        : AtcoderDpE.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX = 100001;
int n, w, bw, bv;
ll dp[MAX];

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

	cin >> n >> w;

	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;

	for (int i = 0; i < n; ++i) {
		cin >> bw >> bv;

		for(int j = MAX - 1; j >= bv; j--){
			dp[j] = min(dp[j], dp[j - bv] + bw);
		}
	}

	int best = -1;
	for (int i = 0; i < MAX; ++i){
		if(dp[i] <= w){
			best = i;
		}
	}

	printf("%d\n", best);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  ll n,p;
  cin >> n >> p;

  ll ans = 1;
  rep(i,n) {
    ans *= 2;
  }
  bool flag = true;
  rep(i,n) {
    int a;
    cin >> a;
    if(a % 2 == 1) flag = false;
  }

  if(flag) {
    if(p == 0){
      cout << ans << endl;
      return 0;
    }
    else {
      cout << 0 << endl;
      return 0;
    }
    
  }
  else {
    cout << ans / 2 << endl;
  }
  
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
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; }

int w[100], v[100];
int dp[105][201010];
int main(){
  int N, W;
  cin >> N >> W;
  rep(i, 0, N) cin >> w[i] >> v[i];
  rep(i, 0, N + 1) rep(j, 0, 101010) dp[i][j] = 1e9 + 1;
  dp[0][0] = 0;
  rep(i, 0, N) rep(j, 0, 101010) {
    chmin(dp[i + 1][j], dp[i][j]);
    chmin(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
  }
  int ans = 0;
  rep(i, 0, 101010) if(dp[N][i] <= W) chmax(ans, i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 79232
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for k in range(M)]
mx=[]
c=[]
for j in range(N):
    if(s[j] not in c):
        c.append(s[j])
for j in range(M):
    if (t[j] not in c):
        c.append(t[j])
for j in range(len(c)):
    mx.append(s.count(c[j])-t.count(c[j]))
if(max(mx)<0):print(0)
else:print(max(mx))

Measured memory_bytes: 3064
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    i64 a, b;
    cin >> a >> b;
    forn(i, n - 1) {
        i64 c, d;
        cin >> c >> d;
        i64 k = max((a - 1) / c + 1, (b - 1) / d + 1);
        a = c * k;
        b = d * k;
    }
    cout << a + b << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
def main():
    N,K=map(int,input().split())
    R,S,P=map(int,input().split())
    T=input()
    L=['']*N
    score=0
    for i in range(N):
        if T[i]=='r':
            if i>=K and L[i-K]=='p':
                pass
            else:
                score+=P
                L[i]='p'
        elif T[i]=='s':
            if i>=K and L[i-K]=='r':
                pass
            else:
                score+=R
                L[i]='r'
        else:
            if i>=K and L[i-K]=='s':
                pass
            else:
                score+=S
                L[i]='s'
    print(score)


main()


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

using ll  = long long;
using pii = pair<int,int>;
#define dbg(n) cout<<'\n'<<#n<<" is "<<n<<'\n';
#define pb push_back
#define all(v) v.begin(), v.end()
#define cs(i) cout<<"Case "<<i+1<<": \n"; 
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define valid(x,y) (x>=0 and x<row and y>=0 and y<col and arr[x][y]=='.')
const int N   = 1e3+5;
const int INF = 0x7fffffff;
const int mod= 1e9+7;
int row,col;
int dp[N][N];
char arr[N][N];

int main(){
    int n,t,hold=0;
    cin>>row>>col;
    for(int i=0;i<row;i++)
        cin>>arr[i];
    dp[0][0]=1;
    for(int i=0;i<row;i++){
        for(int j=0;j<col;j++){
            if(valid(i,j)){
                if(valid(i+1,j)) dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
                if(valid(i,j+1)) dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
            }
        }
    }
    cout<<dp[row-1][col-1]<<endl;
    return 0;
}

Measured memory_bytes: 5120
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    long long count=b;
    rep(i,a){
        if(count>0){
            cout<<c;
            count--;
        }
        else{
            cout<<99999999;
        }
        if(i!=a-1){
            cout<<" ";
        }
        else{
            cout<<endl;
        }
    }
}



Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            if (s == t.Substring(0, s.Length)) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 25820
arr = list(map(int, input().rstrip().split()))
a = arr[0]
b = arr[1]
c = arr[2]
a = a + b
b = a - b
a -= b
a = a + c
c = a - c
a -= c
print(a, end = " ")
print(b, end = " ")
print(c)

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
  int n,x,y,t,i,tmp,ans=0;
  int nx=0,ny=0,nt=0;
  char s[][4]={"Yes","No"};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d",&t,&x,&y);
    tmp=t-nt-abs(x-nx)-abs(y-ny);
    if(tmp>=0 && tmp%2==0)ans=0;
    else ans=1;
    nt=t; nx=x; ny=y;
  }
  puts(s[ans]);
  return 0;
}


Measured memory_bytes: 128
<?php   

//#マスにとまったとき上下左右どこかしらに#があればいい
fscanf(STDIN,"%d%d",$h,$w);
$s_li=array();
for($i=0;$i<$h;$i++){
  $s_li[] = str_split(trim(fgets(STDIN)));
}

$flag=false;

for($i=0;$i<count($s_li);$i++){
 for($j=0;$j<count($s_li[$i]);$j++){
   if($s_li[$i][$j]=="#"){
     
    if($s_li[$i][$j+1]=="#" 
       || $s_li[$i][$j-1]=="#"
       || $s_li[$i-1][$j]=="#"
       || $s_li[$i+1][$j]=="#" ){
       //$flag=false;
     }else{
      //echo "hoge";
      $flag=true;
     }
     
	}
 }
}

//echo $flag;
if($flag){
  echo "No\n";
}else{
  echo "Yes\n";
}



Measured memory_bytes: 4728
#include<stdio.h>
int main(){
  int n,d[110],min=1e9,i,j,s;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  for(i=-100;i<101;i++){
    for(j=s=0;j<n;j++)s+=(d[j]-i)*(d[j]-i);
    if(min>s)min=s;
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {
    
    int h, w;
    int c[10][10];
    int a;

    cin >> h >> w;

    for(int i = 0; i < 10; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    for(int k = 0; k < 10; k++) {
        for(int i = 0; i < 10; i++) {
            for(int j = 0; j < 10; j++) {
                chmin(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }    

    int sum = 0;

    for(int i = 0; i < h*w; i++) {
        cin >> a;
        if(~a) sum += c[a][1];
    }

    cout << sum << endl;
  
    return 0;
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int n;
int h[505][505];
bool rm[505][505];

template<class T>
struct Q {
	int h = 0, t = 0;
	T q[250005];
	void reset() { h = t = 0; }
	int size() { return t - h; }
	T front() { // assert(h < t);
		return q[h]; }
	bool empty() { return size() == 0; }
	void pop() { h++; }
	void push(T x) { q[t++] = x; }
};

Q<pii> qq;
const int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	read(n);
	
	// calculate initial cost
	rep(i, 1, n + 1) rep(j, 1, n + 1) {
		h[i][j] = min(
				min(i - 1, n - i),
				min(j - 1, n - j));
	}

	ll ans = 0;
	rep(i, 0, n * n) {
		int t; cin >> t; --t;
		qq.reset();
		int p = t / n + 1, q = t % n + 1;
		ans += h[p][q];
		rm[p][q] = 1;
		qq.push({p, q});
		while (!qq.empty()) {
			int x, y; tie(x, y) = qq.front(); qq.pop();
			rep(d, 0, 4) {
				int nx = x + dir[d][0], ny = y + dir[d][1];
				int nd = h[x][y] + int(!rm[x][y]);
				if (nd < h[nx][ny]) {
					h[nx][ny] = nd;
					qq.push({nx, ny});
				}
			}
		}
	}

	die(ans);
}


Measured memory_bytes: 6728
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2753>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

vector<ll> solve(){
    vector<ll> res;
    ll n,m; cin >> n >> m;
    for(int i = 0; i <= n/2; i++) res.push_back(0);
    for(int i = n/2+1; i < n; i++) res.push_back(m);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 3196
/**
 *    author:  FromDihPout
 *    created: 2020-07-28
**/

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


const long long INF = 1e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(3 * n);
    for (int i = 0; i < 3 * n; i++) {
        cin >> a[i];
    }
    
    vector<long long> pref(n + 1), suff(n + 1);
    priority_queue<int> next;
    for (int i = 0; i < n; i++) {
        pref[0] += a[i];
        next.push(-a[i]);
    }
    int index = 1;
    for (int i = n; i < 2 * n; i++) {
        pref[index] = pref[index - 1];
        int smallest = -next.top();
        if (a[i] > smallest) {
            next.pop();
            next.push(-a[i]);
            pref[index] -= smallest;
            pref[index] += a[i];
        }
        index++;
    }
    
    next = priority_queue <int>();
    for (int i = 3 * n - 1; i >= 2 * n; i--) {
        suff[0] += a[i];
        next.push(a[i]);
    }
    index = 1;
    for (int i = 2 * n - 1; i >= n; i--) {
        suff[index] = suff[index-1];
        int largest = next.top();
        if (a[i] < largest) {
            next.pop();
            next.push(a[i]);
            suff[index] -= largest;
            suff[index] += a[i];
        }
        index++;
    }
    
    long long ans = -INF;
    for (int i = 0; i <= n; i++) {
        ans = max(ans, pref[i] - suff[n-i]);
    }
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 6716
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n;
    cin >> n;
    vector<int> scores;
    int sum = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x;
        if(x % 10 != 0){
            scores.push_back(x);
        }
    }
    sort(scores.begin(), scores.end());
    
    if(scores.size() == 0){
        cout << 0;
        exit(0);
    }
    
    if(sum % 10 == 0){
        cout << sum - scores[0];
    }else{
        cout << sum;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
A = zz()
ans = 0
for i, a in enumerate(A):
    if(((i+1) % 2 == 1) and(a % 2 == 1)):
        ans += 1
print(ans)


Measured memory_bytes: 27148
#include<bits/stdc++.h>
using namespace std;
main()
{
string s;
cin>>s;int r=0;
int cou=0;
for(int i=0;i<3;i++)
	if(s[i]=='R')
	r++;
	if(r==1)
	cout<<r<<endl;
	else if(r==2)
	{
		if(s[0]==s[1]||s[1]==s[2])
		cout<<r<<endl;
		else cout<<r-1<<endl;
	}
	else if(r==3)
	cout<<r<<endl;
	else cout<<r<<endl;
}

Measured memory_bytes: 3636
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum K = 32;
alias Circle = Tuple!(long, "a", long, "b");

void main() {
  try {
    for (; ; ) {
      const N = readInt();
      const T = readLong();
      auto C = new Circle[N];
      foreach (i; 0 .. N) {
        C[i].a = readLong();
        C[i].b = readLong();
      }
      
      long[] zeros;
      Circle[] cs;
      foreach (ref c; C) {
        if (c.a == 0) {
          zeros ~= c.b + 1;
        } else {
          cs ~= c;
        }
      }
      
      zeros.sort();
      const zerosLen = cast(int)(zeros.length);
      auto zerosSum = new long[zerosLen + 1];
      foreach (j; 0 .. zerosLen) {
        zerosSum[j + 1] = zerosSum[j] + zeros[j];
      }
      debug {
        writeln("zerosSum = ", zerosSum);
      }
      
      // (b + 1) / a
      cs.sort!((c0, c1) => ((c0.b + 1) * c1.a < (c1.b + 1) * c0.a));
      
      auto dp = new long[K + 1];
      dp[] = T + 1;
      dp[0] = 0;
      foreach (ref c; cs) {
        foreach_reverse (k; 0 .. K) {
          chmin(dp[k + 1], (c.a + 1) * dp[k] + (c.a + c.b + 1));
        }
      }
      debug {
        writeln("cs = ", cs);
        writeln("dp = ", dp);
      }
      
      int ans;
      foreach (j; 0 .. zerosLen + 1) foreach (k; 0 .. K + 1) {
        if (dp[k] + zerosSum[j] <= T) {
          chmax(ans, j + k);
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 12924
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    swap(a, b);
    swap(a, c);
    printf("%d %d %d\n", a, b, c);
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
string s;
cin>>s;
int a=700;
if(s[0]=='o')
a=a+100;
if(s[1]=='o')
a=a+100;
if(s[2]=='o')
a=a+100;
cout<<a;
system ("pause");
return 0;
}

Measured memory_bytes: 504
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
S=[input() for _ in range(N)]
A,B,BA=0,0,0
ans=0
for s in S:
    ans+=s.count('AB')
    if s[0]=='B' and s[-1]=='A':
        BA+=1
    elif s[0]=='B':
        B+=1
    elif s[-1]=='A':
        A+=1
ans+=min(A,B)+BA-int(A==B==0 and BA>0)
print(ans)

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

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

const int inf = 1'000'000'000;

int main() {
  map<string, int> memo;
  int n;

  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    // mapのキーは一意の値しか取れない
    memo[s] += 1;
  }

  int maxv = 0;
  for (const auto &x : memo) {
    int v = x.second;
    if (v > maxv) maxv = v;
  }
  // 頻度が最大のものが複数あった場合にも対応可能なように
  for (auto it = memo.begin(); it != memo.end(); it++) {
    // itはイテレータなので、キーか値かを選択する
    if (it->second == maxv) {
      cout << it->first << endl;
    }
  }
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MAX_N 510

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


vector<vll> cumSum(MAX_N, vll(MAX_N, 0));

ll solve(ll p, ll q){
  ll sum = 0;
  for(ll i = p; i <= q; i++){
    if(p == 0)
      sum += cumSum[i][q];
    else
      sum += cumSum[i][q] - cumSum[i][p-1];
  }
  return sum;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,m,a;
  cin >> n >> m >> a;
  ll l,r;
  vector<vll> trainField(MAX_N, vll(MAX_N));
  REP(i, m){
    cin >> l >> r;
    l--;
    r--;
    trainField[l][r]++;
  }
  
  vll p(a),q(a);
  REP(i, a){
    cin >> p[i] >> q[i];
    p[i]--;
    q[i]--;
  }
  
  REP(i, MAX_N)
    cumSum[i][0] = trainField[i][0];
  
  REP(i, MAX_N){
    REP1(j, MAX_N)
      cumSum[i][j] += cumSum[i][j-1] + trainField[i][j];
  }
  
  
  REP(i, a)
    cout << solve(p[i],q[i]) << endl;
  
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << endl
#define prtd(n, var)     cout << fixed << setprecision(n) << var << endl
#define prt2(v1, v2)     cout << v1 << " " << v2 << endl
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << endl
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << endl

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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<bool> isac(n);
  vector<int> wa(n);
  rep(i,n){
    isac[i]=false;
    wa[i]=0;
  }

  int ac=0;
  int tot_wa=0;
  rep(i,m){
    int tmp;
    string judge;
    cin >> tmp >> judge;
    if(!isac[tmp-1]){
      if(judge[0]=='A'){
        ac++;
        tot_wa+=wa[tmp-1];
        isac[tmp-1]=true;
      } else {
        wa[tmp-1]++;
      }
    }
  }

  cout << ac << " " << tot_wa;
}


Measured memory_bytes: 640
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
	do {\
		std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
		debug_impl(__VA_ARGS__);\
		std::cerr << std::noboolalpha;\
	} while (false)
#else
#define debug(...) {}
#endif

int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n, m; std::cin >> n >> m;
	lint ans = 1;
	loop(m) ans *= 2;
	ans *= (1900*m + 100*(n-m));
	std::cout << ans << std::endl;
	return 0;
}

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

vector<long long int>RMQ;
long long int n;

void init( int n_ ) {
	n = 1LL;
	while( n < n_ ) {
		n <<= 1LL;
	}
	RMQ = vector<long long int>( 2LL * n - 1, powl( 2LL, 31LL ) - 1LL );
}

//k???????????????a????????´
void update( long long int k, long long int a ) {
	k += n - 1;
	RMQ[k] = a;
	while( k > 0 ) {
		k = (k - 1) / 2;
		RMQ[k] = min( RMQ[k * 2 + 1], RMQ[k * 2 + 2] );
	}
}

long long int query( long long int a, long long int b, long long int k, long long int l, long long int r ) {
	if( r <= a || b <= l ) {
		return powl( 2LL, 31LL ) - 1LL;
	}
	if( a <= l && r <= b ) {
		return RMQ[k];
	} else {
		long long int vl = query( a, b, k * 2 + 1, l, (l + r) / 2 );
		long long int vr = query( a, b, k * 2 + 2, (l + r) / 2, r );
		return min( vl, vr );
	}
}

int main() {
	long long int n_, q;
	cin >> n_ >> q;
	init( n_ );
	for( size_t i = 0; i < q; i++ ) {
		long long int c, x, y;
		cin >> c >> x >> y;
		if( c == 0 ) {
			update( x, y );
		} else {
			cout << query( x, y + 1, 0, 0, n ) << endl;
		}
	}
}

Measured memory_bytes: 4880
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  string s;
  cin>>s;
  unsigned long count=0;
  REP(i,s.size()){
    if((i%2==1&&s[i]=='0')||(i%2==0&&s[i]=='1')) count++;
  }
  cout << min(count, s.size()-count);
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <cstdlib>
#include <string>
using namespace std;

int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	int sa;
	if (a > b)sa = a - w - b;
	else sa = b - w - a;
	if (sa <= 0)cout << 0 << endl;
	else cout << sa << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char picture[100][101];
	int high, wide;
	int i;
	
	scanf("%d %d", &high, &wide);
	
	for(i=0; i<high; i++)
		scanf("%s", picture[i]);
	
	for(i=0; i<wide+2; i++)
		putchar('#');
	putchar('\n');
	for(i=0; i<high; i++){
		putchar('#');
		printf("%s", picture[i]);
		putchar('#');
		putchar('\n');
	}
	for(i=0; i<wide+2; i++)
		putchar('#');
	putchar('\n');
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll s,c;

int main(){
	cin>>s>>c;
	if(s*2>=c){
		cout<<c/2<<endl;
		return 0;
	}
	cout<<(c-2*s)/4+s<<endl;
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

struct dish {
	LL s;
	LL a;
	LL b;

	bool operator>(const dish &D2) const {
		if (s > D2.s) {
			return true;
		}
		return false;
	};
};



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

	vector<dish> t(n);

	for (int i = 0; i < n; i++) {
		LL a, b; cin >> a >> b;
		LL s = a + b;
		t[i]={s,a,b};
	}

	sort(t.begin(), t.end(),greater<dish>());

	LL ans = 0;
	for (int i = 0; i < n; i++) {
		if (i%2== 0) {
			ans += t[i].a;
		}
		else {
			ans -= t[i].b;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define N 1777771
using namespace std;
typedef unsigned long long ull;
ull s[1000][1000],p[1000][1000];
ull roll[1000][1000],roll2[1000][1000];
string s1[1000],p1[1000];
int main(){
  int h,w,h1,w1;
  cin>>h>>w;

  for(int i=0;i<h;i++)cin>>s1[i];

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)s[i][j]=s1[i][j];

  cin>>h1>>w1;
  for(int i=0;i<h1;i++)cin>>p1[i];

  for(int i=0;i<h1;i++)
    for(int j=0;j<w1;j++)p[i][j]=p1[i][j]; 



  ull a=0;
  for(int i=0;i<h1;i++)
    for(int j=0;j<w1;j++)a=a*N+p[i][j];

  for(int j=0;j<h;j++){
    ull b=0,g=1;
    for(int i=0;i<w1;i++)b*=N,b+=s[j][i],g*=N;
    roll[j][w1-1]=b;
    for(int i=w1;i<w;i++){
      b*=N,b+=s[j][i],b-=s[j][i-w1]*g;
      roll[j][i]=b;
    }
  }

  for(int j=w1-1;j<w;j++){
    ull b=0,g=1,n=1;
    for(int i=0;i<w1;i++)n*=N;
    for(int i=0;i<h1;i++)b*=n,b+=roll[i][j],g*=n;
    roll2[h1-1][j]=b;
    for(int i=h1;i<h;i++){
      b*=n,b+=roll[i][j],b-=roll[i-h1][j]*g; 
      roll2[i][j]=b;
    }
  }


  for(int i=h1-1;i<h;i++)
    for(int j=w1-1;j<w;j++)
      if(a==roll2[i][j])printf("%d %d\n",i-h1+1,j-w1+1);

    return 0;
}

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

using namespace std;

//Shortcut
#define long long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define X first
#define Y second
#define sz size
#define ft(i , a , b) for (long i = (long)a ; i <= (long)b ; i++)
#define fd(i , a , b) for (long i = (long)a ; i >= (long)b ; i--)
#define lt(i , a , b , c) for (long i = (long)a ; i <= (long)b ; i += (long)c)
#define ld(i , a , b , c) for (long i = (long)a ; i >= (long)b ; i -= (long)c)
#define pll pair <long , long>
#define pls pair <long , string>
#define vtl vector <long>
#define vts vector <string>
#define vtp vector <pll>
#define dql deque <long>
#define mll map <long , long>
#define prio priority_queue<pll , vector<pll > , greater<pll> >
#define pushpq(a , b) push({(long) a , (long) b})

//Variable
const long mxN = 1e5 + 5;
const long base = 311;
const long oo = 1e15;
const long MOD = 1e9 + 7;
const long d4i[4] = {-1 , 0 , 1 , 0} , d4j[4] = {0 , 1 , 0 , -1};
const long d8i[8] = {-1 , -1 , 0 , 1 , 1 , 1 , 0 , -1} , d8j[8] = {0 , 1 , 1 , 1 , 0 , -1 , -1 , -1};

long TestCase;
long n , k;
long a[mxN];
bool dp[mxN];

void Solve() {
    cin >> n >> k;
    ft(i , 1 , n) cin >> a[i];
    ft(i , 0 , k) {
        ft(j , 1 , n) {
            if (a[j] > i) continue;
            if (!dp[i - a[j]]) dp[i] = true;
        }
    }
    if (dp[k]) cout << "First";
    else cout << "Second";
}

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
    //cin >> TestCase;
    TestCase = 1;
    while(TestCase--)
        Solve();
    return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
const ll N = 1003;
string a[N];
ll dp[N][N];



int32_t main(){
    IOS;
    ll i,j,k,n,m,p,q;
    cin >> n >> m;
    fori2(n) cin >> a[i];
    dp[1][1] = 1;
    fori2(n){
        forj2(m){
            if(i==1 && j==1 || a[i][j-1] == '#') continue;
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= md;
        }
    }
    cout << dp[n][m] <<"\n";

} 

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

int main(){
    int x;
    cin>>x;
    
    bool flag=true;
    
    while(flag){
        bool exist=true;
        if(x==2) break;
        if(x%2==0){
            x++;
            continue;
        }
        int num=sqrt(x);
        for(int i=3;i<=num;i+=2){
            if(x%i==0){
                x++;
                exist=false;
            }
        }
        if(exist) break;
    }
    
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio> 
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a,p;
int main()
{
	scanf("%d%d",&a,&p);
	printf("%d",(a*3+p)/2);
	return 0;
} 

Measured memory_bytes: 256
n = int(input())
s = input()
x = 0
y = s.count('.')
c = min(n-y, y)
for i in range(n):
    t = s[i] == '#' #＃であればｔがTrueになる
    x += t
    y -= 1 - t
    c = min(c, x+y)
print(c)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    int n, y;
    cin >> n >> y;
    y /= 1000;

    int a, b, c;
    bool flg = false;
    rep(i, n + 1) {
        rep(j, n - i + 1) {
            a = i;
            b = j;
            c = n - i - j;
            if (c < 0) continue;

            int sum = a*10 + b*5 + c;
            if (y == sum && !flg) {
                cout << a << ' ' << b << ' ' << c << endl;
                flg = true;
                break;
            }
        }
    }

    if (!flg) cout << "-1 -1 -1" << endl;
}


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

int main(){
  int a,b;
    cin>>a>>b;
  if(a==0)
    cout<<b+b/100<<endl;
  if(a==1)
    cout<<100*b+b/100*100<<endl;
  if(a==2)
    cout<<10000*b+b/100*10000<<endl;
}

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

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char target[1000][100];
int money[1000];
char str[100];

int main() {
  int n, m;
  while (scanf("%d %d", &n, &m), n) {
  REP(i, n) {
    scanf("%s %d", target[i], &money[i]);
  }
  int sum = 0;
  while (m--) {
    scanf("%s", str);
    REP(i, n) {
      REP(j, 8) {
        if (target[i][j] != '*' && target[i][j] != str[j]) { goto next; }
      }
      sum += money[i];
      break;
next:;
    }
  }
  printf("%d\n", sum);
}
}

Measured memory_bytes: 0
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

a_list.sort()
max_num = a_list[-1]

if max_num < K:
    print("IMPOSSIBLE")
    exit()

exist = a_list.count(K)
if exist >= 1:
    print("POSSIBLE")
    exit()

from fractions import gcd
gcd_num = gcd(a_list[-1], a_list[-2])

for a in a_list:
    gcd_num= gcd(gcd_num, a)
if K%gcd_num == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main() {
	ll a, b, n;
	cin >> a >> b >> n;
	cout << a * min(b - 1, n) / b << endl;	
}


Measured memory_bytes: 3636