akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

int main(){
while(1){
 string stra;
 cin>>stra;
 int pointA=0;
 int pointB=0;

 if(stra[0]=='0'){
	break;
 }
 for(int i=1;i<stra.size();i++){
	if(stra[i]=='A'){
		pointA++;
	}
	if(stra[i]=='B'){
		pointB++;
	}
 }
 if(pointA>pointB){
	pointA++;
 }
 else{
	pointB++;
 }
 cout<<pointA<<' '<<pointB<<'\n';
}
return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 202;
const int MAXC = 10000007;
const ll MOD = 1000000007;

int n, a[MAXN];
vector<int> b;
vector<int> odd, even;
vector<int> edg[MAXN];

bool sieve[MAXC];
vector<int> prime;
void build_prime () {
    for (int i=2; i<MAXC; i++) {
        if (!sieve[i]) {
            prime.emplace_back(i);
        }
        for (int j=0; j<SZ(prime)&&i*prime[j]<MAXC; j++) {
            sieve[i*prime[j]] = true;
            if (i % prime[j] == 0) {
                break;
            }
        }
    }
}

bool vis[MAXN];
int yp[MAXN];

bool match (int nd) {
    if (vis[nd]) {
        return false;
    }
    vis[nd] = true;
    for (auto v : edg[nd]) {
        if (yp[v] == -1 || match(yp[v])) {
            yp[v] = nd;
            return true;
        }
    }
    return false;
}
/*********************GoodLuck***********************/
int main () {
    IOS();
    build_prime();
    sieve[1] = true;
    cin >> n;
    REP1 (i, n) {
        cin >> a[i];
    }

    a[0] = -1;
    REP1 (i, n) {
        if (a[i] != a[i-1] + 1) {
            b.emplace_back(a[i]);
        }
        if (a[i] != a[i+1] - 1) {
            b.emplace_back(a[i]+1);
        }
    }

    for (auto v : b) {
        if (v & 1) {
            odd.emplace_back(v);
        } else {
            even.emplace_back(v);
        }
    }

    REP (i, SZ(odd)) {
        REP (j, SZ(even)) {
            if (!sieve[abs(odd[i] - even[j])]) {
                edg[i].emplace_back(j);
            }
        }
    }

    memset(yp, -1, sizeof(yp));

    int cnt = 0;
    REP (i, SZ(odd)) {
        memset(vis, 0, sizeof(vis));
        if (match(i)) {
            cnt++;
        }
    }

    #ifdef tmd
    debug(SZ(odd));
    for (auto v : odd) {
        cout << v << " ";
    }
    cout << endl;

    debug(SZ(even));
    for (auto v : even) {
        cout << v << " ";
    }
    cout << endl;

    debug(cnt);
    #endif
    cout << cnt + ((SZ(odd)-cnt)/2 + (SZ(even)-cnt)/2)*2 + (SZ(odd)-cnt)%2*3 << endl;

    return 0;
}


Measured memory_bytes: 16240
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int &i:A)cin>>i;
  sort(A.rbegin(),A.rend());
  int a=0,b=0;
  for(int i=0;i<N;i++){
    if(i%2==0)a+=A[i];
    else b+=A[i];
  }
  cout<<a-b<<endl;
}

Measured memory_bytes: 3588
S = input()
j = 0
m = S[0]
ls = []
for i in range(len(S)):
  if m!=S[i]:
    ls += [i-j]
    j = i
    m = S[i]
ls += [len(S)-j]
N = len(ls)
if N<3:
  print(max(ls))
else:
  ans = float('inf')
  sls = [ls[0]]
  for i in range(1,N):
    sls += [sls[-1]+ls[i]]
  for i in range(N-1):
    ans = min(ans,max(sls[i], sls[-1]-sls[i]))
  print(ans)

Measured memory_bytes: 43016
import sys
sys.setrecursionlimit(300000)
from itertools import accumulate

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, M, K = MI()
A = LMI()
B = LMI()

a = list(accumulate([0, *A]))
b = list(accumulate([0, *B]))

ans = 0
j = M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 135584
#include <iostream>
#include <cassert>
#define REP(i,l,n) for(int i=l;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define MAX 100
using namespace std;
int ans;
int n,pointer;
char input[MAX];
int evalE();
int evalT();
int evalF();
int main(){
  cin >> n;
  rep(i,n){
    pointer = 0;
    cin >> input;
    ans = evalE();
    cout << ans <<endl;
  }
  return 0;
}
int evalE(){
  int value = evalT();
  while(true){
    if(input[pointer] == '+'){
      pointer++;
      value += evalT();
    }else if(input[pointer] == '-'){
      pointer++;
      value -= evalT();
    }else{
      break;
    }
  }
  return value;
}
int evalT(){
  int value = evalF();
  while(true){
    if(input[pointer] == '*'){
      pointer++;
      value *= evalF();
    }else if(input[pointer] == '/'){
      pointer++;
      value /= evalF();
    }else{
      break;
    }
  }
  return value;
}
int evalF(){
  int value = 0;
  if(input[pointer] == '('){
    pointer++;
    value = evalE();
    assert(input[pointer] == ')');
    pointer++;
  }
  while(input[pointer]>='0'&&input[pointer]<='9'){
    value *= 10;
    value += (int)(input[pointer++] - '0');
  }
  return value;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0;i<s.size();i++)
    {
    	ans=ans+(s[i]-48);
    }
    if(ans%9==0)
    cout<<"Yes";
    else
    cout<<"No";
	return 0;
}

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N, A, B;
        N = scanner.nextInt();
        A = scanner.nextInt();
        B = scanner.nextInt();
        if ( B - A < 0) { // 2 4 10 与 1 7 10 这种情况不同，在只有1节的情况下长度不能发生变化，但是在1节以上则可以
            System.out.println("0");
            return;
        }
        if (N == 1) {
            if (A == B) {
                System.out.println("1");
            } else {
                System.out.println("0");
            }
            return;
        }
        long min = 0, max = 0;
        for (int i = 0; i < N - 1; i++) {
            min += A;
            max += B;
        }
        min += B;
        max += A;
        System.out.println(max - min + 1);
    }
}

Measured memory_bytes: 22612
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char[] c = str.toCharArray();
		int A = str.length();
		int Z = 0;

		for(int i=0; i<str.length(); i++){
			String s = String.valueOf(str.charAt(i));
			if(s.equals("A")){
				if(A>i){
					A=i;
				}
			}else if(s.equals("Z")){
				if(Z<i){
					Z=i;
				}
			}
		}

		System.out.println(Z-A+1);
	}
 
}

Measured memory_bytes: 31704
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull A=9999973,B=950527;

int H,W;
char T[1005][1005];
ull t[1005][1005];
ull t2[1005][1005];
int h,w;
char U[1005][1005];


int main(){
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++)scanf("%s",T[i]);
  scanf("%d %d",&h,&w);
  for(int i=0;i<h;i++)scanf("%s",U[i]);
  
  ull target=0;  
  for(int i=0;i<h;i++){
    ull key=0;
    for(int j=0;j<w;j++){
      key=key*B+U[i][j];
    }
    target=target*A+key;
  }

  ull C=1;
  for(int i=0;i<w;i++)C*=B;
  
  for(int i=0;i<H;i++){
    ull key=0;
    for(int j=0;j<W;j++){
      key=key*B+T[i][j];
      if(j-w>=0)key-=T[i][j-w]*C;
      t[i][j]=key;
      t2[i][j]=t[i][j];
    }
  }
  
  C=1;
  for(int i=0;i<h;i++)C*=A;
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i)t[i][j]+=t[i-1][j]*A;
      if(i-h>=0)t[i][j]-=t2[i-h][j]*C;
      if(t[i][j]==target){
        if(i-h+1>=0&&j-w+1>=0)
          printf("%d %d\n",i-h+1,j-w+1);
      }
    }
  }


  return 0;
}

Measured memory_bytes: 18904
#include <stdio.h>
int K,S;

int main()
{
    int x=0,y=0,z=0,sum=0;
    scanf("%d %d",&K,&S);

    for(x=0;x<=K;x++){
	for(y=0;y<=K;y++){
	    if(S-x-y<=K && S-x-y>=0)
		    sum++;
	}
    }

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

		



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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> A(N,0);
    bool check = 1;
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    reverse(A.begin(),A.end());
    int temp = A.at(0);
    for(int i = 0; i < N; i++) {
        if(A.at(i) - 1 > temp) {
            check = 0;
            break;
        }
        temp = min(temp, A.at(i));
    }
    if(check) {
    cout << "Yes" << endl;
    } else {
    cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

struct el{
    int u, v, c;
};

vector<el> elek;
vector<vector<int>> g1, g2;
vector<bool> volt1, volt2;

void Bejar(vector<vector<int>> &g, int akt)
{
    volt1[akt] = true;

    for(int i = 0; i < g[akt].size(); i++)
        if(!volt1[g[akt][i]])
            Bejar(g, g[akt][i]);

    return;
}

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

    int n, m, p;
    cin>>n>>m>>p;

    g1.resize(n);
    g2.resize(n);
    volt1.resize(n, false);
    volt2.resize(n, false);
    elek.resize(m);
    vector<int> v(n, -1000000000);

    for(int i = 0; i < m; i++)
    {
        int a, b, c;
        cin>>a>>b>>c;
        g1[a-1].push_back(b-1);
        g2[b-1].push_back(a-1);
        elek[i].u = a-1;
        elek[i].v = b-1;
        elek[i].c = c;
    }

    Bejar(g2, n-1);

    volt2 = volt1;
    volt1.assign(n, false);

    Bejar(g1, 0);

    if(!volt1[n-1])
    {
        cout<<"-1\n";
        return 0;
    }

    v[0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if(volt1[elek[j].u] && volt1[elek[j].v] && volt2[elek[j].u] && volt2[elek[j].v] && (v[elek[j].u]+elek[j].c-p > v[elek[j].v]))
                v[elek[j].v] = v[elek[j].u]+elek[j].c-p;
        }
    }

    bool jo = true;
    for(int j = 0; j < m; j++)
    {
        if(volt1[elek[j].u] && volt1[elek[j].v] && volt2[elek[j].u] && volt2[elek[j].v] && (v[elek[j].u]+elek[j].c-p > v[elek[j].v]))
            jo = false;
    }

    if(jo)
        cout<<max(0, v[n-1])<<"\n";
    else
        cout<<"-1\n";

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int ft_strlen(char *str)
{
        int len;

        len = 0;
        while (str[len] != '\0')
                len++;
        return (len);
}

int check_chenge_char(char *dest, char *src)
{
        int i;
        int count;

        i = 0;
        count = 0;
        while (dest[i] && src[i])
        {
                if (dest[i] != src[i])
                {
                        count++;
                }
                i++;
        }
        return (count);
}

int main(void)
{
        char    t[1001];
        char    s[1001];
        int             i;
        int             max;
        int             answer;
        int             temp;

        scanf("%s%s", t, s);
        i = 0;
        max = ft_strlen(t) - ft_strlen(s);
        answer = 1001;
        while (i <= max)
        {
                temp = check_chenge_char(&t[i], s);
                if (temp < answer)
                {
                        answer = temp;
                }
                i++;
        }
        printf("%d\n", answer);
        return (0);
}

Measured memory_bytes: 1732
n,m=map(int,input().split())
c=[]
for i in range(m):
    c.append(list(map(int,input().split())))
ans=[-1 for i in range(n)]
cnt=0
if m==0:
    cnt=2
for i in range(m):
    if ans[c[i][0]-1]==-1:
        ans[c[i][0]-1]=c[i][1]
    else:
        if ans[c[i][0]-1]==c[i][1]:
            continue
        else:
            cnt+=1
            break
if cnt==1:
    print(-1)
elif cnt==2:
    if n==1:
        print(0)
    else:
        c='1'
        for i in range(n-1):
            c+='0'
        print(c)
else:
    if [1,0] in c and n!=1:
        print(-1)
    else:
        if ans[0]==-1:
            ans[0]=1
        for i in range(n):
            if ans[i]==-1:
                ans[i]=0
            ans[i]=str(ans[i])
        aa=''.join(ans)
        print(aa)

Measured memory_bytes: 3064
N = int(input())
S = input()
ans = set()
for first in range(10):
    for second in range(10):
        f_flag = False
        s_flag = False
        for i in S:
            if f_flag is False:
                if int(i) == first:
                    f_flag = True
            elif s_flag is False:
                if int(i) == second:
                    s_flag = True
            else:
                ans.add(str(first)+str(second)+i)

print(len(ans))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,r=0;
    scanf("%d %d",&a,&b);
    r=a+b;
    r=r%2;
    if(r==0){
        printf("%d",(a+b)/2);
    }else{
        printf("IMPOSSIBLE");
    }
    return 0;
}

Measured memory_bytes: 256
# 1行目
p_str=input().split()
(N,K)=[int(n) for n in p_str]
# 2行目
p_str=input().split()
p_int=[int(n) for n in p_str]
(A,B)=(1,1)
for i in range(N-K):
  B=p_int[i]
  A=p_int[i+K]
  #  print(B,A,i)
  if B < A :
    print("Yes")
  else:
    print("No")
    


Measured memory_bytes: 31584
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  if (a > b || n == 1 && a != b) {
    cout << 0 << endl;
    return 0;
  }
  if (a == b) n--; else n -= 2;
  ll k = b - a + 1;
  cout << n * k - n + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;


/**
 * Lesson4D　n  個の整数 a i (i=1,2,...n) を入力し、それらの最小値、最大値、合計値を求めるプログラム
 * @author 前島佑介
 * @version 2014/12/1
 */
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		//入力値 １つ目 2列目の扱う数
		int intNum = 0;

		//最小値
		int intMin = 0;

		//最大値
		int intMax = 0;

		//合計
		double dbSum = 0;


		try{
			//キーボードからの入力準備
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			//キーボードからの入力をString型で受け取る初期化
			String strLine = br.readLine();

			//入力値 １つ目　2列目の扱う数
			intNum = Integer.parseInt(strLine);

			//キーボードからの入力をString型で受け取る
			strLine = br.readLine();

			//文字列の分割:入力値を" "で分ける
			//分けた文字列はstrLineAry[0]とstrLineAry[1]とstrLineAry[2]に分けられる
			String[] strLineAry = strLine.split(" ");

			//1つ目の値を最小値に入れておく
			intMin = Integer.parseInt(strLineAry[0]);

			//最大値にも最小値の値を入れておく
			intMax = intMin;

			//総数をカウントしていく
			dbSum += (double)intMin;

			//2つ目以降
			for(int i = 1; i < intNum; i++) {

				int intNum2 = Integer.parseInt(strLineAry[i]);

				//最小値より小さいなら
				if(intNum2 < intMin) {

					//これを最小値にする
					intMin = intNum2;
				}

				//最大値より大きいなら
				if(intMax < intNum2) {

					//これを最大値にする
					intMax = intNum2;
				}

				//総数をカウントしていく
				dbSum += (double)intNum2;
			}

			//小数5桁まで
		    DecimalFormat insDF = new DecimalFormat("0");

			//出力
			System.out.println(intMin + " " + intMax + " " + insDF.format(dbSum));

			//例外処理
		}catch(IOException e) {

			//例外時の出力
			System.out.println(e);

		}catch(NumberFormatException e) {

			//数値以外の入力値で出力
			System.out.println("数値で入力して下さい");
		}
	}
}

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

int main(){

    string s;

    cin >> s;

    if(s=="A"){
        cout << "T";
    }
    else if(s=="C"){
        cout << "G";
    }
    else if(s=="G"){
        cout << "C";
    }
    else{
        cout << "A";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,c,s;

int main(){
  ll ans=0;
  cin >> n >> k>>c;
  string s;cin>>s;

  vi si(n),sj(n),leftb(n),rghtb(n),b(n);

  ll lasti=-2;
  REP(i,n){
    if (s[i]=='o'){
      si[i]=i;
      lasti=i;
    }
    if (s[i]=='x'){
      si[i]=lasti;
    }
  }
  
  lasti=-2;
  REP(i,n){
    if (s[n-i-1]=='o'){
      lasti=n-i-1;
      sj[n-i-1]=n-i-1;
    }
    if (s[n-i-1]=='x'){
      sj[n-i-1]=lasti;
    }
  }


  for(ll i=0;i<n;i++){
    ll idx=-2;
    if (i-c-1>=0)idx=si[i-c-1];

    if (si[i]==i){
      if (idx!=-2)
        leftb[i]=leftb[idx]+1;
      if (idx==-2)
        leftb[i]=1;
    }
  }



  for(ll i=n-1;i>=0;i--){
    ll idx=-2;
    if (i+c+1<n)idx=sj[i+c+1];

    if (si[i]==i){
      if (idx!=-2)
        rghtb[i]=rghtb[idx]+1;
      if (idx==-2)
        rghtb[i]=1;
    }
  }


  vi leftb2(n),rghtb2(n);
  ll mx=0;
  ll idx=-1;
  for(ll i=0;i<n;i++){
    if (mx<leftb[i]){
      mx=leftb[i];
      idx=i;
    }
    leftb2[i]=idx+mx*1000000LL;
  }

  mx=0;
  idx=-1;
  for(ll i=n-1;i>=0;i--){
    if (mx<rghtb[i]){
      mx=rghtb[i];
      idx=i;
    }
    rghtb2[i]=idx+mx*1000000LL;
  }


  REP(i,n){
    if (si[i]==i){
        ll leftx=-1;
        if (i!=0)leftx=leftb2[i-1];
        ll rghtx=-1;
        if (i!=n-1)rghtx=rghtb2[i+1];

        if (rghtx==-1)rghtx=0;
        if (leftx==-1)leftx=0;
        
        ll lval=leftx/1000000;
        ll rval=rghtx/1000000;
        if ((lval+rval)<k){
          b[i]=1;//絶対働かないといけない
        }
        /*
        //多分いらない
        if ((lval+rval)==k){
          if (rghtx%1000000-leftx%1000000<=c)b[i]=1;//絶対働かないといけない
        }
        */
    }
  }
  

  REP(i,n){
    if (b[i]==1){
      cout<<(i+1)<<endl;
    }
  }


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

/*
16 8 1
ooooooooooooooox
*/

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

int main(void){
    int X,Y,x,y,r;
    cin>>X>>Y>>x>>y>>r;

    if(r<=x){
        if(x<=X-r){
            if(y>=r){
                if(y<=Y-r){
                    cout<<"Yes"<<endl;
                    return 0;
                } 
                
            }
        }
        
        }
        cout<<"No"<<endl;
    }
    



Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<int> a(n+1);
	vector<int> b(n);
	for(int i=0;i<n+1;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		if(b[i]>=a[i]){
			b[i]-=a[i];
			ans+=a[i];
			a[i]=0;
		}
		if(a[i]>b[i]&&b[i]>0){
			a[i]-=b[i];
			ans+=b[i];
			b[i]=0;
		}
		if(a[i+1]>b[i]&&b[i]>0){
			a[i+1]-=b[i];
			ans+=b[i];
			b[i]=0;
		}
		if(a[i+1]<=b[i]){
			b[i]-=a[i+1];
			ans+=a[i+1];
			a[i+1]=0;
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
char str[100005];
int cnt[26];
#define P 1000000007
int main() {
	int n;
	scanf("%d%s", &n, str);
	for(int i = 0; i < n; i++) cnt[str[i] - 'a']++;
	long long ans = 1;
	for(int i = 0; i < 26; i++) ans = ans * (cnt[i] + 1) % P;
	printf("%lld\n", ans ? ans - 1 : P - 1);
	return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
m = list()
for _ in range(n):
    m.append(int(input()))

# 最低一つずつは作る
rem = x - sum(m)

# 残った粉で一番少ない使用量の物をたくさん作る
res = n + (rem // min(m))

print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll M1,D1;
int main()
{
	cin>>M1>>D1;
	if(D1<10)cout<<0<<endl;
	else 
	{   int sum=0;
		for(int j=1;j<=M1;j++)
		for(int i=20;i<=D1;i++)
		{ //cout<<1;
		if(i%10>=2){
		
		  if((i%10)*(i/10)==j)
		  {sum++;
		   //cout<<j<<" "<<i<<endl;
          }		
		}}
		 cout<<sum<<endl;
	}
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  map<int, int> m;
  REP(i,n) {
    int tmp;
    cin >> tmp;
    ++m[tmp];
  }
  int ans = m.size();
  int evenCount = 0;
  REPOBJ(itr, m) {
    if(itr->second % 2 == 0) ++evenCount;
  }
  if(evenCount%2 == 1) --ans;
  cout << ans << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 4992
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int a = in();
  cout << 3 * a * a << endl;
  return 0;
}


Measured memory_bytes: 256
fun c94(args: Array<String>) {
    val numList = args[1].split(" ").map { it.toInt() }
    val sortedNumList = numList.sorted()
    val firstMedIndex = (numList.size - 1) / 2
    val secondMedIndex = firstMedIndex + 1

    val ans = numList
            .map {
                if (it <= sortedNumList[firstMedIndex]) {
                    sortedNumList[secondMedIndex]
                } else {
                    sortedNumList[firstMedIndex]
                }
            }
            .joinToString("\n")

    println(ans)
}

fun main(args: Array<String>) {
    c94(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 105976
s = input()
sum = 0
if (s[0] == s[1]):
  sum += 1
if (s[0] == s[2]):
  sum += 1
if (s[0] == s[3]):
  sum += 1
if (s[1] == s[2]):
  sum += 1
if (s[1] == s[3]):
  sum += 1
if (s[2] == s[3]):
  sum += 1
  
if (sum == 2):
  print('Yes')
else:
  print('No')




Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int field[8][8][8];
int x[7*7*8], y[7*7*8];

int check(int n, int m, int t){
  for(int dx=-1; dx<=1; dx++){
    for(int dy=-1; dy<=1; dy++){
      for(int dh=-1; dh<=1; dh++){
        if(dx==0 && dy==0 && dh==0) continue;
        // ????????????????????¢???????????§??¨??¨?????????
        // xx yy hh ????????£?¶???????????????°OK
        rep(xx,n) rep(yy,n) rep(hh,n) if(field[xx][yy][hh]==t){
          bool ok = true;
          repl(i,1,m){
            int nx = xx+dx*i, ny=yy+dy*i, nh =hh+dh*i;
            if(nx<0 || ny<0 || nh<0 || nx>=n || ny>=n || nh>=n || field[nx][ny][nh]!=t) {ok=false; break;}
          }
          if(ok) return true;
        }
      }
    }
  }
  return false;
}

int main(){
  int n,m,q;
  while(cin>>n>>m>>q, n){
    fill(field[0][0], field[7][8], -1);

    rep(i,q) scanf("%d %d", x+i, y+i);
    rep(i,q) x[i]--, y[i]--;

    rep(i,q){
      int h=0;
      while(field[x[i]][y[i]][h]!=-1) h++;
      field[x[i]][y[i]][h] = i%2; //cout<<x[i]<<","<<y[i]<<","<<h<<":"<<i%2<<endl;

      if(i%2==0 && check(n,m,0)){ cout << "Black " << i+1 << endl; break; }
      if(i%2==1 && check(n,m,1)){ cout << "White " << i+1 << endl; break; }
      if(i==q-1) cout << "Draw" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3120
#include<cstdio>
 
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
int main(){
    for(int n,m;scanf("%d%d",&n,&m),n;){
        int a[1000];
        rep(i,n) scanf("%d",a+i);
 
        bool ok;
        int b[1012];
        rep(S,1<<m){
            int sum=0;
            rep(i,m) sum+=b[i]=S>>i&1;
            rep(i,n-1) b[m+i]=a[i+1]-a[i]+b[i];
 
            ok=(sum==a[0]);
            rep(i,n+m-1) if(b[i]!=0 && b[i]!=1) ok=false;
            if(ok) break;
        }
 
        if(ok){ rep(i,n+m-1) printf("%d",b[i]); puts(""); } else puts("Goofy");
    }
 
    return 0;
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int W,H,N;cin>>W>>H>>N;
    vvi M(W,vi(H,1));
    for(int i=0;i<N;i++){
        int x,y,a;cin>>x>>y>>a;
        if(a==1){
            for(int j=0;j<x;j++){
                for(int k=0;k<H;k++){
                    M[j][k]=0;
                }
            }
        }else if(a==2){
            for(int j=x;j<W;j++){
                for(int k=0;k<H;k++){
                    M[j][k]=0;
                }
            }
        }else if(a==3){
            for(int j=0;j<W;j++){
                for(int k=0;k<y;k++){
                    M[j][k]=0;
                }
            }
        }else if(a==4){
            for(int j=0;j<W;j++){
                for(int k=y;k<H;k++){
                    M[j][k]=0;
                }
            }
        }
    }
    int ans=0;
    for(int j=0;j<W;j++){
        for(int k=0;k<H;k++){
            ans+=M[j][k];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int sinpou = sc.nextInt();
        int order = 0;
        int c = 1;
        while(c <= num) {
            c *= sinpou;
            order++;
        }
        sc.close();
        System.out.println(order);

 
    }

}

Measured memory_bytes: 23756
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	priority_queue<ll>pq;
	for(ll i=0;i<n;i++)
	{
		ll tmp;
		cin>>tmp;
		pq.push(tmp);
	}
	while(m--)
	{
		ll val=pq.top();
		pq.pop();
		val/=2;
		pq.push(val);
	}
	ll ans=0;
	while(!pq.empty())
	{
		ans+=pq.top();
		pq.pop();
	}
	cout<<ans;
    return 0;
}


//252908XL

Measured memory_bytes: 1400
#include <stdio.h>

long long cal_lcm(long long a, long long b)
{
    long long t;
    long long gcd;
	long long a_bak;
	
	a_bak = a;
	gcd = b;
	
    if (a < gcd){
        t = a;
        a = gcd;
        gcd = t;
     }
        
     while (a % gcd != 0){
        t = gcd;
        gcd = a % gcd;
        a = t;
    }
	
	return (a_bak * b / gcd);
}


int round(int a, int m)
{
	int x, n;
	
	x = 1;
	n = 0;
	
	do {
		x = (a * x) % m;
		n++;
	} while (x != 1);

	return (n);
}

int main(void)
{
	int a1, a2, a3;
	int m1, m2, m3;
	int n1, n2, n3;
	long long lcm;
	
	while (1){
		scanf("%d%d%d%d%d%d", &a1, &m1, &a2, &m2, &a3, &m3);
		if (a1 == 0 && m1 == 0 &&
		    a2 == 0 && m2 == 0 &&
		    a3 == 0 && m3 == 0){
			
			break;
		}

		n1 = round(a1, m1);
		n2 = round(a2, m2);
		n3 = round(a3, m3);
		
		lcm = cal_lcm(n1, n2);
		lcm = cal_lcm(lcm, n3);

		printf("%lld\n", lcm);
	}
	
	return (0);
}

Measured memory_bytes: 0
import math
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
visit = []
p_num = 1
q_num = 1
for i in range(n):
  visit.append(p[i])
  cnt = 0
  for j in range(p[i]):
    if j not in visit:
      cnt += 1
  p_num += math.factorial(n-i-1)*cnt
visit = []
for i in range(n):
  visit.append(q[i])
  cnt = 0
  for j in range(q[i]):
    if j not in visit:
      cnt += 1
  q_num += math.factorial(n-i-1)*cnt
print(abs(q_num-p_num))

Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  priority_queue<ll> pq;
  rep(i, n) {
    ll ai; cin >> ai;
    pq.push(ai);
  }
  for (int i = 0; i < m && !pq.empty(); i++) {
    ll p = pq.top(); pq.pop();
    // debug(p);
    p /= 2;
    pq.push(p);
  }
  ll ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }
  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

int main(int argc, const char * argv[]) {
    string s, t;
    int count = 0;
    cin >> s;
    cin >> t;
    
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == t[i]) {
            count += 1;
        }
    }
    cout << count << endl;
    return  0;
}

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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	vector<pair<int, int>> AB(N);
	for (int i = 0; i < N; i++) {
		AB[i] = make_pair(A[i], B[i]);
	}
	sort(AB.begin(), AB.end());

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		int buy = min(M, AB[i].second);
		ans += (long long)buy * AB[i].first;
		M -= buy;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<math.h>

using namespace std;


#define INF 1000000007
int dp[101][100001];
int n,w;
vector< pair<int, int> > item;
int m = -1;

int dfs(int k){
  if(k == n){
    for(int i = 0 ; i < 100001; i++){
      if(dp[k][i] != INF && dp[k][i] <= w) m = i;
    }
    return 0;
  }
  for(int i = 0 ; i < 100001; i++){
    dp[k+1][i] = min(dp[k+1][i], dp[k][i]);
    if(dp[k][i] + item[k].first <= w) dp[k+1][i+item[k].second] = min(dp[k+1][i+item[k].second], dp[k][i] + item[k].first);
  }
  return dfs(k+1);
}

int main(){
  cin >> n >> w;
  for(int i = 0; i < n ; i++){
    int a,b;
    cin >> a >> b;
    item.push_back(make_pair(a,b));
  }
  for(int i = 0; i <= n ; i++){
    for(int j = 0; j <= 100001; j++){
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  dfs(0);
  cout << m << endl;
}


Measured memory_bytes: 39680
#include <iostream>
#include <algorithm>

using namespace std;
using pii = pair<int, int>;

#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define in(v) if (scanf("%d", &v)<1);
#define out(v) printf("%d\n", v)

int main() {
  int N; in(N);

  pii red[N], blue[N];

  rep(i, N) {
    int a, b;
    in(a); in(b);
    red[i] = make_pair(a, b);
  }
  rep(i, N) {
    int c, d;
    in(c); in(d);
    blue[i] = make_pair(c, d);
  }

  sort(blue, blue+N);
  bool pairing[N];
  rep(i, N)
    pairing[i] = false;

  int ans = 0;
  rep(i, N) {
    int max_j = -1;
    rep(j, N) {
      if (pairing[j])
        continue;
      if (blue[i].first > red[j].first && blue[i].second > red[j].second && (max_j == -1 || red[j].second > red[max_j].second))
        max_j = j;
    }
    if (max_j != -1) {
      pairing[max_j] = true;
      ++ans;
    }
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n);
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
    }
    sort(a.begin(), a.end());

    printf("%ld\n", a[n-1]-a[0]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	long long int l, r; std::cin >> l >> r;
	if (r - l >= 2019) {
		std::cout << 0 << std::endl;
	}
	else {
		long long int min = LLONG_MAX;
		for (auto i = l; i <= r; ++i) {
			for (auto j = i + 1; j <= r; ++j) {
				auto temp = (i * j) % 2019;
				if (min > temp) min = temp;
			}
		}
		std::cout << min << std::endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main(){
	int a, b, d = 0;
	while(scanf("%d%d", &a, &b), a && b){
		if(d)puts("");
		else d = 1;
		int c = 0;
		for(;a<=b;a++){
			if(a % 4 == 0){
				if(a % 100 == 0){
					if(a % 400 == 0){c++, printf("%d\n", a);}
				}
				else c++, printf("%d\n", a);
			}
		}
		if(!c)puts("NA");
	}
}

Measured memory_bytes: 0
package main

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

func main() {
	defer stdout.Flush()
	a := readInt()
	b := readInt()
	d := b - a
	blen := (1 + d) * d / 2
	println(blen - b)
}

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	i, err := strconv.Atoi(readString())
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}


Measured memory_bytes: 640
n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

DP = [False] * (k + 1)

for i in range(1, k+1):
    DP[i] = not all(DP[i-a] for a in A if i - a >= 0)

print('First' if DP[k] else 'Second')


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

set<int> edge[51];
int N,M;

bool dfs(int n){
  vector<bool> visited(N+1,false);

  visited[n] = true;
  stack<int> st;
  st.push(n);
  while(!st.empty()){
    int m = st.top(); st.pop();
    for(const auto& v : edge[m]){
      if(visited[v])continue;
      visited[v] = true;
      st.push(v);
    }
  }

  bool flag = true;
  FOR(i,1,N+1){
    if(!visited[i])flag=false;
  }
  return flag;
}

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

  vector<int> a(M), b(M);

  REP(i,M){
    cin >> a[i] >> b[i];
    edge[a[i]].insert(b[i]);
    edge[b[i]].insert(a[i]);
  }

  int ans=0;

  REP(i,M){
    edge[a[i]].erase(b[i]);
    edge[b[i]].erase(a[i]);

    if(!dfs(1)){
      ans++;
    }
    edge[a[i]].insert(b[i]);
    edge[b[i]].insert(a[i]);
  }

  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int gcd(int a, int b) {
    if (!a)return b;
    return gcd(b % a, a);
}

int main() {
    init();

    int n, k;
    cin >> n >> k;

    VI a(n);
    cin >> a;
    SORT(a);
    int g = a[0];
    FOR(i, 1, n)g = gcd(g, a[i]);

    cout << (k % g == 0 && k <= a[n - 1] ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int MAX = 21;

int main()
{
    string s;
    int l, n, one = 0;

    while(getline(cin, s))
    {
        one = 0; n = 0;
        vector<int> ans;
        ans.push_back(0);

        if(s == "0") break;
        s += " ";
        int l = s.size();
        
        REP(l)if(s[i] != ' '){ n = n*10 + s[i] - '0';}
        else 
        {
            if(n == 1) one++;
            if(n >= 10) n =10;
            ans[0] += n;
            n = 0;
        }
        REP(one){ans.push_back( ans[i] + 10); }
        int maxp = 0;
        REP(ans.size())if(ans[i] > maxp && ans[i] <= MAX) maxp = ans[i];

        cout << maxp << endl;

    }
    return 0;
}

Measured memory_bytes: 0
n, t = gets.split.map(&:to_i)
ary = []
costs = []
ans = "TLE"
n.times do
  ary << gets.split.map(&:to_i)
end
ary.each do |i|
  if i[1] <= t
    costs << i[0]
  end
end
if costs.empty?
  puts ans
else
  puts ans = costs.min
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  ll A, B;
  cin >> A >> B;
  if((A + B) % 2 == 0) {
    cout << (A + B) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<long long> b(n);
    b[0]=100001;
    for(int i=1;i<n;i++){
        cin>>b[i];
    }
    long long ans=0;
    for(int i=1;i<n;i++){
        ans+=min(b[i-1],b[i]);
    }
    ans+=b[n-1];
    cout<<ans<<endl;
}

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

s = input()
A = {}
for i in range(len(s)):
    if s[i] not in A:
        A[s[i]] = True

for i in range(26):
    character = chr(ord('a')+i)
    if character not in A.keys():
        print(character)
        exit()

print('None')


Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[1001][1001]={0};
int main(){
int i,j,q,e,l,z,m,u,n;
char s[2001],c[2001];
cin>>q;
for(e=0;e<q;e++){
scanf("%s %s",s,c);
l=strlen(s);
z=strlen(c);

for(i=0;i<=l;i++){
	for(j=0;j<=z;j++){
		p[i][j]=0;
	}
}
for(i=1;i<=z;i++){
	for(j=1;j<=l;j++){
		if(c[i-1]==s[j-1])p[j][i]=p[j-1][i-1]+1;
		else p[j][i]=max(p[j-1][i],p[j][i-1]);
	}
}
cout<<p[l][z]<<endl;
}
return 0;
}

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

int main()
{
	int a, b, h;
	cin >> a >> b >> h;

	cout << (a + b) * h / 2 << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

import static java.lang.Integer.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st;
        int t = parseInt(in.readLine());
        int cnt = 0;
        for (int i = 0; i < t; i++) {
            st = new StringTokenizer(in.readLine());
            int D1 = parseInt(st.nextToken()), D2 = parseInt(st.nextToken());
            if (D1 == D2) cnt++;
            else if (cnt < 3) cnt = 0;

        }
        if (cnt >= 3) pw.println("Yes");
        else pw.println("No");
        pw.close();
    }

    static void solve() {

    }
}


Measured memory_bytes: 32844