akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

ll fac[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> X(N);
    for(int i=0;i<N;i++) cin>>X[i];
    
    fac[0]=1;
    fac[1]=1;
    for(ll i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i;
        fac[i]%=mod;
    }
    
    ll p=1;
    ll sum=0;
    for(int i=1;i<N;i++){
        sum+=(X[i]-X[i-1])*p;
        sum%=mod;
        p+=rui(i+1,mod-2);
        p%=mod;
    }
    
    sum*=fac[N-1];
    sum%=mod;
    
    cout<<sum<<endl;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;

int main(){
    ll N;
    cin>>N;
    ll A[10002]={};
    for(int i=1; i<101; i++){
        for(int j=i; j<101; j++) {
            for(int k=j; k<101; k++) {
                ll sum = i*i + j*j + k*k + k*i + i*j + j*k;
                if (sum<=10000){
                    if(i==j && j==k){
                        A[sum] += 1;
                    }
                    else if (i==j || j==k || k==i){
                        A[sum] += 3;
                    }
                    else {
                        A[sum] += 6;
                    }
                }
            }
        }
    }
    for(ll i=1; i<=N; i++){
        out(A[i]);
    }
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll len(ll n) {
	int count = 0;
	while (n > 0) {
		n /= 10;
		count++;
	}
	return count;
}
int main() {
	ll n;
	cin >> n;
	//deque<ll>a, b;
	int tmp = 11;
	for(int i=1; i<= pow(n,0.5); i++) {
		if (n%i == 0) {
			int a = max(len(n/i) , len(i));
			if (tmp > a) {
				tmp = a;
			}
		}
	}
	cout << tmp << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	long min,max,sum = 0L;
	int i,n = 0;
	int in;

	scanf("%d",&n);

	for(i = 0;i < n; i++)
	{
		scanf("%d",&in);
		if(i == 0)
		{
			min = max = in;
		}else{
			if(min > in)
			{
				min = in;
			}
			if(max < in){
				max = in;
			}
		}

		sum = sum + in;
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############

x1,y1,x2,y2 = inputIL()

dx,dy = x2-x1,y2-y1

x3,y3 = x2-dy,y2+dx
x4,y4 = x3-dx,y3-dy
print(x3,y3,x4,y4)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define rep(i,a,b) for(int i=a; i<b; i++)
#define dep(i,a,b) for(int i=a; i>=b; i--)
#define ALL(x)	(x).begin(), (x).end()
using namespace std;
const long long INF = 1e18 , MAXN =1e5, MOD = 1e9 + 7,N=1000010;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll a,b,c,k;cin>>a>>b>>c>>k;
	if (a>=k)cout<<k;
	else if (a+b>=k)cout<<a;
	else cout<<a-(k-a-b);
return 0;
}
//ghmru


Measured memory_bytes: 3632
#include<iostream>

using namespace std ;

char c[ 1000000 + 1 ] ;

int cnt( int a ,char str )
{
	int i = 0 ;
	while( c[ a ] == str )
	{
		i++ ;
		a++ ;
	}
	return i ;
}

int main()
{
	int ans = 0 ;
	cin >> c ;
	for( int i = 0 ; c[ i ] != '\0' ; i++ )
	{
		if( c[ i ] == 'J' )
		{
			int p = i ;
			int J = cnt( p ,'J' ) ;
			p += J ;
			if( c[ p ] == 'O' )
			{
				int O = cnt( p ,'O' ) ;
				p += O ;
				if( c[ p ] == 'I' && J >= O )
				{
					int I = cnt( p ,'I' ) ;
					p += I ;
					if( I >= O && O > ans )
					{
						ans = O ;
					}
					else
					{
						i = p - 1 ;
					}
				}
				else
				{
					i = p - 1 ;
				}
			}
			else
			{
				i = p - 1 ;
			}
		}
	}
	cout << ans << endl ;
	return 0 ;
}

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

int main(){
	int n;
	string ac;

	while (cin >> n, n != 0){
		int count = 0;
		bool l = false, r = false;
		bool next = true;
		for (int i = 0; i < n; i++){
			cin >> ac;
			if (ac == "lu") l = true;
			if (ac == "ru") r = true;
			if (ac == "ld") l = false;
			if (ac == "rd") r = false;
			if (l == r&&l == next){
				count++;
				next = !next;
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

int main() {
  int A, B, i;
  cin >> A >> B;
  for (i = 0; A <= B; A++) if (A / 1000 == A % 100 / 10 + A % 10 * 10) i++;
  cout << i << endl;
}

Measured memory_bytes: 256
while true
    n = gets.to_i
    break if n == 0
    h = {}
    1.upto(n-1){|x| h[(x * x) % n] = true}
    arr = h.keys.sort
    arr2 = Array.new((n - 1) / 2, 0)
    arr.combination(2){|a, b|
        d = b - a
        d = n - d if d > (n - 1) / 2
        arr2[d - 1] += 2
    }
    puts arr2
end


Measured memory_bytes: 7512
from sys import stdin
input = stdin.readline

H, W, K = map(int, input().split())
c = [list(input().rstrip()) for _ in range(H)]

cnt_black = 0

for i in range(H):
    for j in range(W):
        if c[i][j] == "#":
            cnt_black += 1

ans = 0


def bit_full_search(H, W):
    global ans
    # 縦
    for i in range(2 ** H):
        # 横
        for j in range(2 ** W):
            changed = [[False for _ in range(W)] for _ in range(H)]
            cnt = 0
            for h in range(H):
                if (i >> h) & 1:
                    for w in range(W):
                        if not changed[h][w] and c[h][w] == "#":
                            changed[h][w] = True
                            cnt += 1
            for w in range(W):
                if (j >> w) & 1:
                    for h in range(H):
                        if not changed[h][w] and c[h][w] == "#":
                            changed[h][w] = True
                            cnt += 1

            if cnt_black - cnt == K:
                ans += 1


bit_full_search(H, W)

print(ans)


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int a[m];
    for(int i=0;i<m;i++) cin >> a[i];
    sort(a,a+m);
    vector<int> v;
    for(int i=1;i<m;i++) v.push_back(a[i]-a[i-1]);
    sort(v.begin(),v.end());
    if(n>=m) cout << 0 << endl;
    else
    {
        int sum=0;
        for(int i=0;i<m-n;i++) sum+=v[i];
        cout << sum << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 100, 5min

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll X, Y;

signed main()
{
    cin >> X >> Y;
    if(X % Y == 0) { printf("-1\n"); }
    else { printf("%lld\n", X); }
    return 0;
}


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

using namespace std;

int main() {
  int n = 0;
  cin >> n;
  string a;
  cin >> a;
  int r = 0, b = 0;
  for(int i = 0; i < n; ++i) {
    if(a[i] == 'R') {
      r += 1;
    } else {
      b += 1;
    }
  }
  if(r > b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

#define REP(i, a, b) for (i = a; i < b; i++)
#define REP_ITER(it, v) for (it = v.begin(); it != v.end(); it++)

#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(0)

#define TEST(test) \
    int test;      \
    cin >> test;   \
    while (test--)

#define cll(a, b) cin >> a >> b
#define YES cout << "YES\n"
#define NO cout << "NO\n"

#define vi vector<int>
#define vi_iterator vector<int>::iterator

#define si set<int>
#define si_iterator set<int>::iterator

double pi = 2 * acos(0.0);
int i, j;
int main()
{
    FASTIO;
    ll n;
    cin >> n;
    ll a[n], b[n];
    REP(i, 0, n)
    {
        cin >> a[i];
    }
    REP(i, 0, n)
    {
        cin >> b[i];
    }
    ll maxiii = INT_MIN, ans = 0;
    REP(i, 0, n)
    {
        if (a[i] > b[i])
        {
            ans += (a[i] - b[i]);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

struct Book {
    int r, w;
};

int main()
{
    int N;

    while (cin >> N, N) {
        vector<Book> book(N);

        int max_idx = 0, max_r = -1, sum_r = 0, sum_w = 0;
        for (int i = 0; i < N; ++i) {
            cin >> book[i].r >> book[i].w;

            if (book[i].r > max_r) {
                max_idx = i;
                max_r = book[i].r;
            }
            sum_r += book[i].r;
            sum_w += book[i].w;
        }

        sum_r -= max_r;

        if (sum_r >= max_r) {
            cout << sum_r + max_r + sum_w << '\n';
        }
        else {
            int wait_time = max_r - sum_r;
            vector<vector<bool>> dp(N + 1, vector<bool>(wait_time + 1, false));

            dp[0][0] = true;

            if (max_idx != N - 1)
                swap(book[max_idx], book[N - 1]);
            --N;

            for (int i = 0; i < N; ++i) {
                for (int j = 0; j <= wait_time; ++j) {
                    if (!dp[i][j])
                        continue;
                    dp[i + 1][j] = true;
                    if (j + book[i].w <= wait_time)
                        dp[i + 1][j + book[i].w] = true;
                }
            }

            int max_write = 0;
            for (int i = 0; i <= wait_time; ++i)
                if (dp[N][i])
                    max_write = i;

            cout << 2 * max_r + (sum_w - max_write) << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int ans[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int x  = 1;
    map<int, int> mp;
    mp[0] = 1;
    ll res = 0;
    for(int i = n - 1; i >= 0; i--){
        ans[i] = (x * (s[i] - '0') + ans[i + 1]) % 2019;
        // cout << ans[i] << ' ';
        x = (x * 10) % 2019;
        res += mp[ans[i]];
        mp[ans[i]]++;
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    int N;
    cin >> N;
    cout << (N * (N + 1)) / 2;
    return 0;
}

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

int main(){
  long long q,h,s,d,n;
  cin>>q>>h>>s>>d>>n;
  long long min1=min({s,2*h,4*q});
  long long min2=min({d,2*s,4*h,8*q});
  if(n%2==0){
      if(2*min1<min2) cout<<n*min1<<endl;
      else cout<<n*min2/2<<endl;
  }
  else{
      if(2*min1<min2) cout<<n*min1<<endl;
      else cout<<(n-1)*min2/2+min1<<endl;
  }
}

Measured memory_bytes: 256
let
  S = readline()
  pre, rea = map(x -> parse(Int, x), [S[1:2], S[3:4]])
  ret = ""

  if 0 < pre < 13
    if 0 < rea < 13
      ret = "AMBIGUOUS"
    else
      ret = "MMYY"
    end
  elseif 0 < rea < 13
    if 0 < pre < 13
      ret = "AMBIGUOUS"
    else
      ret = "YYMM"
    end
  else
    ret = "NA"
  end

  print(ret)
end 


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

#define fr first
#define sc second
#define pii pair < int, int >

const int N = 1e2;
const int W = 1e5;

long long dp[N + 1][W + 1];
int w[N + 1], v[N + 1];

#define name "lifeguards"

main()
{
	//freopen(name".in", "r", stdin);
	//freopen(name".out", "w", stdout);
	int n, ww; cin >> n >> ww;
	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];
	
	for(int weight = 1; weight <= ww; weight++)
	{
		for(int item = 1; item <= n; item++)
		{
			dp[item][weight] = dp[item - 1][weight];
			if(w[item] > weight);
			else
			{
				dp[item][weight] = max(dp[item][weight],
															 dp[item - 1][weight - w[item]] + v[item]);
			}
		}
	}
	
	cout << dp[n][ww] << endl;
}
/***
***/


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 6");
            WillReturn.Add("3 4 5");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 9");
            WillReturn.Add("3 3 3 3");
            //4
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(pX => int.Parse(pX)).ToArray();
        int X = wkArr[1];

        int[] LArr = InputList[1].Split(' ').Select(pX => int.Parse(pX)).ToArray();

        int Answer = 1;
        int CurrPos = 0;
        foreach (int EachInt in LArr) {
            CurrPos += EachInt;
            if (CurrPos <= X) Answer++;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if ((A<C&&B>C)||(A>C&&B<C)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
number = int(input())
list1 = [0, 0, 0, 0]
list2 = ['AC', 'WA', 'TLE', 'RE']

for _ in range(number):
  word = input()
  if word == 'AC':
    list1[0] = list1[0] + 1
  elif word == 'WA':
    list1[1] = list1[1] + 1
  elif word == 'TLE':
    list1[2] = list1[2] + 1
  elif word == 'RE':
    list1[3] = list1[3] + 1
    
for i in range(len(list1)):
  print(list2[i], 'x',  list1[i])

Measured memory_bytes: 9232
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int memo[110000][30] = {};

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    int nex[30];
    for(int i = 0; i < 30; i++){
        nex[i] = -1;
    }
    for(int i = s.size() - 1; i >= 0; i--){
        nex[s[i] - 'a'] = i;
    }
    for(int i = s.size() - 1; i >= 0; i--){
        for(int j = 0; j < 30; j++){
            memo[i][j] = nex[j];
        }
        nex[s[i] - 'a'] = i;
    }
    if(nex[t[0] - 'a'] == -1){
        cout << -1 << endl;
        return 0;
    }
    int pos = nex[t[0] - 'a'];
    long long int ans = pos;
    for(int i = 1; i < t.size(); i++){
        int to = memo[pos][t[i] - 'a'];
        if(to == -1){
            cout << -1 << endl;
            return 0;
        }
        if(to <= pos){
            ans += s.size();
        }
        ans += to - pos;
        pos = to;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(string s;getline(cin,s);){
		string res;
		for(int i=0;i<s.size();){
			if(s.substr(i,5)=="apple"){
				res+="peach";
				i+=5;
			}
			else if(s.substr(i,5)=="peach"){
				res+="apple";
				i+=5;
			}
			else
				res+=s[i++];
		}
		cout<<res<<endl;
	}
	
	return 0;
}

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

int n;
string s = "";

bool exists(string t){
    for(int i = 0; i <= s.length()-t.length(); i++){
        if(t == s.substr(i, t.length()))    return true;
    }
    return false;
}

int main(){
    cin >> n;
    
    char c;
    for(int i = 0; i < n; i++){
        cin >> c;
        s += c;
    }

    int ans = 0;
    while(exists(to_string(ans)))    ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3284
#include<iostream>
#include<stack>
#include<queue>
using namespace std;

int main(){
    stack<int> b, c;
    int a[10];
    bool which[11];
    int data[11];
    int index;
    int n, m, A;
    int i, j;
    cin >> n;
    for(i=0;i<n;i++){
        index = 0;
        for(j=0;j<10;j++){
            cin >> m;
            a[j] = m;
            data[j+1] = 0;
        }
        b.push(0);
        c.push(0);
        while(index>=0){
            A = a[index];
            if(b.top() < A && (data[A] != 1 && data[A] != 3)){
                b.push(A);
                data[A] += 1;
                which[A] = true;
            }else if(c.top() < A && (data[A] != 2 && data[A] != 3)){
                c.push(A);
                data[A] += 2;
                which[A] = false;
            }else{
                index--;
                if(index < 0){
                    break;
                }else if(which[a[index]]){
                    b.pop();
                }else{
                    c.pop();
                }
                continue;
            }
            index++;
            if(index > 9){
                cout << "YES" << endl;
                break;
            }
        }
        if(index < 0){
            cout << "NO" << endl;
        }
    }
}

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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

int main(){
  int n;
  cin >> n;
  pair<int, int> p1[n], p2[n];
  int a,b;
  for ( int i = 0; i < n; i++){
    cin >> a >> b;
    p1[i] = make_pair(a, b);
  }
  for ( int i = 0; i < n; i++){
    cin >> a >> b;
    p2[i] = make_pair(a, b);
  }

  sort(p1, p1+n, compare_by_b);
  sort(p2, p2+n, compare_by_b);

  bool color[n];
  for ( int i = 0; i < n; i++)color[i] = false;

  int ans = 0;
  for ( int i = 0; i < n; i++){
    int max = -1, maxI = n;
    for ( int j = 0; j < n; j++){
      if ( p2[i].first > p1[j].first && p2[i].second > p1[j].second && !color[j] && max < p1[j].second){
        max = p1[j].second;
        maxI = j;
      }
    }
    if ( maxI < n){
      color[maxI] = true;
      ans ++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	map<int, int>mp;
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}
	rep(i, n) {
		cout << mp[i + 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int n, m;
    cin >> n >> m;
    int avs[2*m];
    for (int i = 0; i < 2*m; i+=2) {
        cin >> avs[i] >> avs[i+1];
        avs[i]--; avs[i+1]--;
    }
    int ans[n];
    fill(ans, ans + n, 0);
    rep(2*m, i) ans[avs[i]]++;
    rep(n, i) cout << ans[i] << '\n';
}

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


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

using namespace std;


int main()
{
    int n,k;
    long long rm=1e9+7;
    cin>>n>>k;
    vector<long long>v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    vector<vector<long long> > dp(n+1,vector<long long>(k+1));
    for(int i=0;i<=v[0];i++){
        dp[1][i]=1ll;
    }
    long long ttl=v[0];
    for(int in=2;in<=n;in++){
        ttl+=v[in-1];
        for(int ik=0;ik<=k;ik++){
            if(ik==0){
                dp[in][ik]=1ll;
                continue;
            }
            if(ik>v[in-1])
                dp[in][ik]=dp[in-1][ik]+dp[in][ik-1]-dp[in-1][ik-v[in-1]-1];
            else{
                dp[in][ik]=dp[in][ik-1]+dp[in-1][ik];
            }
            dp[in][ik]%=rm;
            dp[in][ik]+=rm;
            dp[in][ik]%=rm;
            if(ik>ttl)
                break;
        }
    }
    cout<<dp[n][k]<<'\n';

/**
5
0.42 0.01 0.42 0.99 0.42
*/
    return 0;
}


Measured memory_bytes: 83192
import java.util.Scanner;
import java.util.ArrayList;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        String s = stdIn.next();
        int[] n = new int[26];

        String[] ss = s.split("");

        int k = 1;

        String sss = ss[0];

        for(int i = 1;i < ss.length;i++){
            if(sss.length() >= 2 || !sss.equals(ss[i])){
                sss = ss[i];
                if(i == ss.length - 3){
                    if(ss[i+1].equals(ss[i+2])){
                        k += 2;
                        break;
                    }
                }
            }else {
                sss = ss[i] + ss[i+1];
                i++;
                if(i == ss.length - 3) {
                    if(ss[i+1].equals(ss[i+2])){
                        k += 2;
                        break;
                    }
                }
            }
            k++;
        }

        System.out.println(k);
    }

}

Measured memory_bytes: 53176
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<vector<long long> > dp(n + 1, vector<long long>(1 << 9, 0));
  dp[0][0] = 1;
  REP(i, n) REP(j, 1 << 9) if (dp[i][j] > 0) {
    vector<int> now(3);
    REP(k, 3) {
      int bit = 0;
      REP(l, 3) {
        if (j >> (3*k+l) & 1) bit += (1 << l);
      }
      now[2 - k] = bit;
    }
    int nx = (j << 3) & ((1 << 9) - 1);
    FOR(k, 1, 5) {
      if (k == 3) {
        if (now[1] == 1 && now[2] == 2) continue;
      } else if (k == 2) {
        if (now[0] == 1) {
          if (now[1] == 3) {
            if (now[2] == 3 || now[2] == 4) continue;
          } else if (now[1] == 4) {
            if (now[2] == 3) continue;
          }
        }
        if (now[1] == 1 && now[2] == 3) continue;
        if (now[1] == 3 && now[2] == 1) continue;
      }
      (dp[i + 1][nx + k] += dp[i][j]) %= MOD;
    }
  }
  long long ans = 0;
  REP(j, 1 << 9) (ans += dp[n][j]) %= MOD;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

int common_time=1,n;

int table[101][101],time_table[101][2];

void func(int node){
	if(time_table[node][0] == 0){
		time_table[node][0] = common_time++;
	}else{
		return;
	}
	for(int i=1;i<=n;i++){
		if(table[node][i] == 1){
			func(i);
		}
	}
	time_table[node][1] = common_time++;
}

int main(){
	int row,num,col;
	scanf("%d",&n);

	for(int i=1;i<=n;i++){
		for(int k=1;k<=n;k++){
			table[i][k]=0;
		}
		time_table[i][0]=0;
		time_table[i][1]=0;
	}

	for(int i=1;i<=n;i++){
		scanf("%d %d",&row,&num);
		for(int k=1;k<=num;k++){
			scanf("%d",&col);
			table[row][col]=1;
		}
	}

	for(int i=1;i<=n;i++){
		func(i);
	}

	for(int i=1;i<=n;i++){
		printf("%d %d %d\n",i,time_table[i][0],time_table[i][1]);
	}

    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
ll a[100001] = {};
ll b[100001] = {};

int main() {
	ll N, H; cin >> N >> H;
	ll maxV = 0;

	ll cnt = 0;
	rep(i, 0, N) {
		cin >> a[i] >> b[i];
		maxV = max(maxV, a[i]);
	}

	sort(b, b + N);
	reverse(b, b + N);

	rep(i, 0, N) {
		if (maxV <= b[i]) {
			H -= b[i];
			cnt++;
			if (H <= 0) {
				cout << cnt << endl;
				return 0;
			}
		}
	}

	if (H % maxV != 0) {
		cnt++;
	}
	cout << cnt + (H / maxV) << endl;

	return 0;
}

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

int N, M;

struct pi {
	int P, Y;
}C[100006], D[100006];

bool f (pi x, pi y) {
	return x.P < y.P;
}

bool g (pi x, pi y) {
	return x.Y < y.Y;
}

int main(){
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &C[i].P, &C[i].Y);
		D[i].P = C[i].P;
		D[i].Y = C[i].Y;
	}
	sort(C, C + M, f);
	vector<int> v, a;
	v.push_back(0);
	a.push_back(C[0].P);
	for (int i = 1; i < M; i++) {
		if (C[i].P != C[v.back()].P) {
			v.push_back(i);
			a.push_back(C[i].P);
		}
	}
	v.push_back(M);
	/*for (int i = 0 ; i < v.size(); i++) {
		cout << v[i];
	}
	cout << endl;*/
	for (int i = 0; i + 1 < v.size(); i++) {
		sort(C + v[i], C + v[i + 1], g);
	}
	for (int i = 0; i < M; i++) {
		string temp;
		temp = to_string(D[i].P);
		while (temp.size() < 6) {
			temp.insert(0, "0");
		}
		string temp2;
		int temp3 = lower_bound(a.begin(), a.end(), D[i].P) - a.begin();
		int l = v[temp3];
		int r = v[temp3 + 1] - 1;
		while (l < r) {
			int mid = (l + r)/2;
			if (C[mid].Y < D[i].Y) {
				l = mid + 1;
			} else {
				r = mid;
			}
		}
		//printf("%d %d\n", l, r);
		temp2 = to_string(r - v[temp3] + 1);
		while (temp2.size() < 6) {
			temp2.insert(0, "0");
		}
		string ans = temp + temp2;
		printf("%s\n", ans.c_str());
	}
	return 0;
}

Measured memory_bytes: 4084
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string S, T; int pos;
int solve() {
	switch (T[pos++]) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '-': return 2 - solve();
		case '(':
			int a = solve();
			switch (T[pos++]) {
				case '+': a = max(a, solve()); break;
				case '*': a = min(a, solve()); break;
			}
			pos++;
			return a;
	}
	return -1;
}
int main() {
	while (true) {
		cin >> S;
		if (S == ".") break;
		int ret = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					T = S;
					for (int l = 0; l < S.size(); l++) {
						if (S[l] == 'P') T[l] = i + 48;
						if (S[l] == 'Q') T[l] = j + 48;
						if (S[l] == 'R') T[l] = k + 48;
					}
					pos = 0;
					if (solve() == 2) {
						ret++;
					}
				}
			}
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3184
#include<stdio.h>
#include<math.h>
int main(){
    double x1, x2;
    double y1, y2;
    double L, l;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    L = pow(x2-x1, 2.0) + pow(y2-y1, 2.0);
    l = sqrt(L);
    printf("%f", l);
    return 0;
}

Measured memory_bytes: 2716
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

const int N = 100010;
int n;
char s[N];

int main()
{
	scanf("%s", s); n = strlen(s);
	for(int i = n/2+n%2; i < n; i ++)
		if(s[i] != s[n-i-1] || s[i] != s[i-1]) {
			printf("%d\n", i); return 0;
		}
	printf("%d\n", n);
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

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

		n = n % k;

		System.out.println(Math.min(k - n, n));
	}

}


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d);
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int up=32;
const int P0=200000-1;
int P2[up+5];
int tot=3;
struct info
{
	char ch;
	int x,y,z;
	info(char a=0,int b=0,int c=0,int d=0):ch(a),x(b),y(c),z(d){}
};
vector<info>A;
inline int smaller(int x,int y)
{
	A.push_back(info('<',x,y,++tot));
	return tot;
}
inline int add(int x,int y)
{
	A.push_back(info('+',x,y,++tot));
	return tot;
}
void init()
{
	int x=add(0,1);
	P2[0]=smaller(P0,x);
	for(int i=1;i<up;++i)
		P2[i]=add(P2[i-1],P2[i-1]);
}
inline int shift(int x,int y)
{
	for(int i=0;i<y;++i)
		x=add(x,x);
	return x;
}
inline int sub(int x,int y)
{
	int sum=add(P0,P0);
	x=add(x,P2[0]);
	for(int i=up-1;i>=0;--i)
	{
		int z=add(add(sum,y),P2[i]);
		int carry=smaller(z,x);
		sum=add(sum,shift(carry,i));
	}
	return sum;
}
inline int isZero(int x)
{
	return smaller(x,P2[0]);
}
inline int check(int x,int y)
{
	return sub(y,shift(isZero(x),up));
}
int multi(int x,int y)
{
	x=add(x,P2[0]);
	int z=add(P0,P0),sum=add(P0,P0);
	for(int i=29;i>=0;--i)
	{
		int carry=smaller(add(sum,P2[i]),x);
		z=add(z,shift(check(carry,y),i));
		x=sub(x,check(carry,P2[i]));
	}
	return z;
}
int main()
{
//	freopen("a.out","w",stdout);
	ios::sync_with_stdio(false);
	init();
	int x=multi(0,1);
	A.push_back(info('+',x,P0,2));
	cout<<A.size()<<endl;
	for(int i=0;i<A.size();++i)
		cout<<A[i].ch<<" "<<A[i].x<<" "<<A[i].y<<" "<<A[i].z<<endl;
	return 0;
}


Measured memory_bytes: 4196
#include <bits/stdc++.h>
#define MAX_V 110
#define N 110
using namespace std;

/* ?????£?????????????§£ O(|V|+|E|) */
int V; //????????°
vector<int> G[MAX_V]; //??°???????????£??\??????????????¨???
vector<int> rG[MAX_V];//?????????????????????????????°??????
vector<int> vs;       //??°?????????????????????
bool used[MAX_V];     //?????§???????????????
int cmp[MAX_V];       //?±????????????£?????????????????????????????????

void add_edge(int from,int to){
  G[from].push_back(to);
  rG[to].push_back(from);
}

void dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
  vs.push_back(v);
}

void rdfs(int v,int k){
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rG[v].size();i++) if(!used[rG[v][i]])rdfs(rG[v][i],k);
}

int scc(){
  memset(used,0,sizeof(used));
  vs.clear();
  for(int v=0;v<V;v++) if(!used[v]) dfs(v);
  memset(used,0,sizeof(used));
  int k=0;
  for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]) rdfs(vs[i],k++);
  return k;
}

int n,v[N],w[N],K[N],T;
int Max(int &a,int b){return a=max(a,b);}

set<int>g[N];
vector<int> DP[N];
void update(vector<int> I,vector<int> &dp){
  int col = cmp[I[0]];
  for(int i:I){
  int num = g[cmp[i]].count(cmp[i])? K[i]:1;
  for(int j=1;num;j=min(num,j*2)){ //???????????°
    num -= j;
    for(int k=T;k>=j*w[i];k--)  //?????¨?????????
      Max(dp[k],dp[k-j*w[i]]+j*v[i]);
  }
  }
  

  for(int nx:g[col])
    for(int j=0;j<=T;j++) Max(DP[nx][j],dp[j]);
  
}

void init(){
  for(int i=0;i<N;i++){
    cmp[i] = 0;
    G[i].clear();
    rG[i].clear();
    g[i].clear();
    DP[i].clear();
    DP[i].resize(T+1,0);
  }
}

int main(){
  while(1){
  int m;
  cin>>n>>m>>T;
  if(!n&&!m&&!T)break;
  init();
  
  for(int i=0;i<n;i++)cin>>v[i]>>w[i]>>K[i];
  for(int i=0,a,b;i<m;i++)cin>>a>>b,add_edge(a-1,b-1);
  V = n;
  V=scc();
  //for(int i=0;i<n;i++)cout<<cmp[i]<<" ";cout<<endl;

  for(int i=0;i<n;i++)
    for(int j:G[i])g[cmp[i]].insert(cmp[j]);
  
  
  int ans = 0;
  for(int i=0;i<V;i++){
    vector<int> I;
    for(int j=0;j<n;j++)if(cmp[j]==i) I.push_back(j);
    update(I,DP[i]);
  }
  for(int i=0;i<V;i++)
    for(int j=0;j<=T;j++) Max(ans,DP[i][j]);
  
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 7380
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

int main()
{
	ll n, k;
	cin >> n >> k;
	n %= k;
	cout << min(abs(n - k), n) << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	bool flag = true;
	int ans = (s[0] - '0') + 9 * (s.length() - 1) - 1;
	for (int i = 1; i < s.length(); i++) {
		if (s[i] != '9') {
			flag = false;
		}
	}
	if (flag) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
a = LIST()

dp = [0]*(K+1)

for i in range(K+1):
	if dp[i] == 0:
		for x in a:
			if i+x <= K:
				dp[i+x] = 1

if dp[K] == 0:
	print("Second")
else:
	print("First")


Measured memory_bytes: 11096
/*input
3
-6 -2 -5
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}
int a[100010];
signed main() {
  IOS;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    if(a[i]<0){
      bool f = 0 ; 
      for(int j=i+1;j<n;j++){
        if(a[j]<0){
          f = 1 ; 
          a[j]*=-1;
          a[i]*=-1;
          i = j;
          break;
        }
      }

      if(f == 1)
        continue;
      else{
        int ind = i ;
        int ap = -a[i];
        for(int j = i - 1 ; j>=0;j--){
          if(a[j]<ap){
            ap = min(ap,a[j]);
            ind = j ; 
          }
        }
        for(int j = i + 1 ; j<n;j++){
          if(a[j]<ap){
            ap = min(ap,a[j]);
            ind = j ; 
          }
        }
        if(ind != i){
          a[ind]*=-1 ;
          a[i]*=-1;
          i = n ; 
          break;
        }
        else{
          i = n ;
          break;
        }
      }
    }
  }
  int sum = 0 ;
  for(int i=0;i<n;i++)sum+=a[i];
  cout << sum << endl ; 
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lli long long int 
#define pb push_back
using namespace std;

const int INF= 1e9 +5;
typedef std::vector<lli> vi;
typedef pair<int,int> ii;


int main() {

	//freopen("input.txt", "r", stdin); 
  	//freopen("output.txt", "w", stdout); 

int n;
	cin>>n;
	vi v(n);

	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}

	vi dp(n,0);
	lli ans=0;
	for(int i=1;i<n;i++)
	{
		if(v[i-1]>=v[i])
		{
			dp[i]=dp[i-1]+1;
			
		}
		ans=max(ans,dp[i]);
	}

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

	
	return 0;
}

Measured memory_bytes: 1792
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        int N = Integer.parseInt (reader.readLine());
        int ans = 0;
        for (int i = 1; i < N + 1; i++)
            if ((Math.floor (Math.log10 (i)) + 1) % 2 == 1)
                ans++;
        System.out.println (ans);
        return;
    }
}

Measured memory_bytes: 32960
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vvchar vector<vector<char>>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

int h,w;
vstring s(9);
vint dx = {1,0};
vint dy = {0,1};

bool check(int x,int y){
  int count = 0;
  if(x == h-1 && y == w-1) return true;
  rep(i,2){
    //cout << x + dx[i] << " " << y + dy[i] << " " << s[x + dx[i]][y + dy[i]] <<  endl;
    if(x + dx[i] < h && y + dy[i] < w){
      //cout << x + dx[i] << " " << y + dy[i] << " " << s[x + dx[i]][y + dy[i]] <<  endl;
      if(s[x + dx[i]][y + dy[i]] == '#') count++;
    }
  }
  //cout << x << " " << y << " " << count << endl;
  if(count == 1){
    if(s[x + dx[0]][y + dy[0]] == '#'){
      if(y + dy[0] > 0){
        if(s[x + dx[0]][y + dy[0]-1] == '#') return false;
        else return check(x+dx[0],y+dy[0]);
      }
      else return check(x+dx[0],y+dy[0]);
    }
    if(s[x + dx[1]][y + dy[1]] == '#'){
      if(x + dx[1] > 0){
        if(s[x + dx[1]-1][y + dy[1]] == '#') return false;
        else return check(x+dx[1],y+dy[1]);
      }
      else return check(x+dx[1],y+dy[1]);
    }
  }
  //cout << "a" << endl;
  return false;
}

signed main(){
  cin >> h >> w;
  rep(i,h){
    cin >> s[i];
  }
  if(check(0,0)) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
N=int(input())
lr=[[] for _ in range(N)]

for i in range(N):
    x,l=map(int,input().split())
    lr[i]=[x-l,x+l]

lr.sort()
r_max=lr[0][1]

ans=N
for i in range(1,N):
    if lr[i][0]<r_max:#被り
        ans-=1
        r_max=min(r_max,lr[i][1])
    else:
        r_max=max(r_max,lr[i][1])
    
print(ans)

Measured memory_bytes: 56992
a = [int(input()) for i in range(2)]
if a[0] == 1:
  if a[1] == 2:
    my_result = 3
  else:
    my_result = 2
elif a[0] == 2:
  if a[1] == 1:
    my_result = 3
  else:
    my_result = 1
else:
  if a[1] == 1:
    my_result = 2
  else:
    my_result = 1
print(my_result)

Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
int c[105];
int t[105];
int main()
{
    int n,q;
    cin>>n>>q;
    int min=1005;
    for(int i=0;i<n;i++)
    {
        cin>>c[i]>>t[i];
        if(t[i]<=q)
        {
            if(min>c[i])
            {
                min=c[i];
            }
        }
    }
    if(min==1005)
    {
        cout<<"TLE"<<endl;
    }
    else
    cout<<min<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		char s[] = new char[4];
		int think = 0;
		for(int i = 0; i < 4; i++) {
			s[i] = S.charAt(i);
			if(s[i] == '+')think++;
			else if(s[i] == '-')think--;

		}
		System.out.println(think);

	}

}


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

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

    int x, t;
    cin >> x >> t;
    
    cout << max(x - t, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
/**
 * 重み付き有向グラフの問題
 */

struct List {
  int v;    // 隣接リスト
  int dis;  // distance
  List(int node, int distance) {
    v = node;
    dis = distance;
  }
};

bool flag[100000];
int dist[100000] = {};
bool ans = true;
vector<unique_ptr<List>> str[1000000];

void dfs(int v) {
  if (flag[v]) {
    return;
  }
  flag[v] = true;
  for (auto&& i : str[v]) {
    if (!flag[i->v]) {
      dist[i->v] = dist[v] + i->dis;
      dfs(i->v);
    } else if (dist[i->v] != dist[v] + i->dis) {
      ans = false;
    }
  }
}

auto find(vector<unique_ptr<List>>& list, int v, int d) {
  if (list[v]->v == v) {
    return make_unique<List>(v, d);
  } else {
    list[v] = find(list, list[v]->v, list[v]->dis);
    return make_unique<List>(list[v]->v, list[v]->dis + d);
  }
}

bool unite(vector<unique_ptr<List>>& list, int xx, int yy, int d) {
  auto x = find(list, xx, 0);
  auto y = find(list, yy, 0);
  if (x->v == y->v) {
    if (x->dis + d == y->dis) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

int main() {
  int n, m;
  cin >> n >> m;
  int l, r, d;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> d;
    str[l - 1].push_back(make_unique<List>(r - 1, d));
    str[r - 1].push_back(make_unique<List>(l - 1, -d));
  }

  // memset(flag, false, sizeof flag);
  fill_n(flag, 100000, false);

  for (int i = 0; i < n; ++i) {
    if (!flag[i]) {
      dfs(i);
    }
  }

  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 44160