akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		List<Integer> list = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			if (!map.containsKey(num)) {
				map.put(num, 1);
				list.add(num);
			} else {
				map.put(num, map.get(num) + 1);
			}
		}
		int ans = 0;
		for(int i = 0; i < list.size(); i++) {
			int key = list.get(i);
			int value = map.get(key);
			int num = value - key;
			if (num >= 0)
				ans += num;
			else
				ans += value;
		}

		out.println(ans);
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 33644
#include <stdio.h>
     
    int main(void)
    {
      int a, b, c;
     
      scanf("%d/%d/%d",&a,&b,&c);
     
      if(a<2019){ printf("Heisei\n");
                    return 0; }
      else if(a>2019) {printf("TBD\n");
            return 0; }
      if(b<04)  {printf("Heisei\n");
                    return 0; }
      else if(b>04) {printf("TBD\n");
            return 0; }
      if(c<=30) {printf("Heisei\n");
                    return 0;;}
      else if(c>30) {printf("TBD\n");
            return 0; }
      return 0;
    }

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc162/tasks/abc162_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
  ll K; cin>>K;
  ll ans=0;
  FOR(a,1,K+1){
    FOR(b,1,K+1){
      ll t=std::gcd(a,b);
      FOR(c,1,K+1){
        ans += std::gcd(t,c);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

int ord(ll a,ll p){
  int i=0;
  while(a%p==0){
    a/=p;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

vector<bool> b;
void dfs(const graph &g,int v){
  b[v]=true;
  for(auto i:g[v]){
    if(b[i])continue;
    dfs(g,i);
  }
}

int main(){
  int i,j,k;ll cnt=0;
  int n,m;
  cin>>n>>m;
  int x[m],y[m],z[m];
  graph g(n);
  for(i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    g[a-1].push_back(b-1);
    g[b-1].push_back(a-1);
  }
  b.assign(n,false);
  for(i=0;i<n;i++){
    if(b[i])continue;
    dfs(g,i);
    cnt++;
  }
  cout<<cnt<<endl;
}


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

int main(void){
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.6f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    return 0;
}


Measured memory_bytes: 3208
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<(n/i);i++){
        if((n%i)==0&&(n%((n/i)-1)!=0)){
            ans+=((n/i)-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int a , b ;
      cin >> a >> b ;
      
      if ( a * b % 2 == 1 ) {
        cout << "Odd" << endl;
      }
     else { cout << "Even"<< endl;
          }
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ld d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t){
    	cout<<"Yes";
    }else{
    	cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x, y;
int main() {
    cin >> x >> y;
    int ans = 0;
    ans += max(0, (4-x) * 100000);
    ans += max(0, (4-y) * 100000);
    if (x == 1 && y == 1) ans += 400000;
cout << ans << endl;  
    return 0;
}


Measured memory_bytes: 256
def solve(N, K, As):
    current = 1
    count = 0
    teleport = {i + 1 : v for i, v in enumerate(As)}
    dist = {}

    while current not in dist:
        dist[current] = count
        count += 1
        current = teleport[current]
        if K == count:
            return current

    loop_size = count - dist[current]
    K -= dist[current]
    K %= loop_size
    K += dist[current]

    current = 1
    while K > 0:
        current = teleport[current]
        K -= 1
    return current

# assert(solve(4, 6, [3, 2, 4, 1]) == 1)
# assert(solve(4, 5, [3, 2, 4, 1]) == 4)
# assert(solve(4, 4, [3, 2, 4, 1]) == 3)
# assert(solve(4, 3, [3, 2, 4, 1]) == 1)
# assert(solve(4, 2, [3, 2, 4, 1]) == 4)
# assert(solve(4, 1, [3, 2, 4, 1]) == 3)
# assert(solve(2, 1, [2, 1]) == 2)
# assert(solve(2, 2, [2, 1]) == 1)
# assert(solve(2, 10**18, [2, 1]) == 1)
# 
# assert(solve(2, 100, [1, 1]) == 1)
# assert(solve(2, 10**18, [1, 1]) == 1)
# 
# assert(solve(3, 10**18, [2, 3, 3]) == 3)
# assert(solve(3, 1, [2, 3, 3]) == 2)
# assert(solve(3, 10**18, [3, 3, 3]) == 3)
# 
# print("OK")

if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    print(solve(N, K, As))


Measured memory_bytes: 48872
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

# exit if $0 != __FILE__

n = gets.chop
a = cin

b = a.pop

def euc(a, b)
  a, b = b, a if a > b
  return b if a == 0
  euc(a, b%a)
end

a.each {|x| b = euc(b, x)}

puts b


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

int main()
{
    string s;
    cin >> s;
    if (s.at(s.size() - 1) == 's')
    {
        cout << s << "es" << endl;
    }
    else
    {
        cout << s << "s" << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
n = int(input())
a = [int(i) for i in input().split()]
tmp1 = 0
tmp2 = 0
S = [0]*n

if a[0] > 0:
  S[0] = a[0]
else:
  S[0] = 1
  tmp1 += abs(1-a[0])
  
for i in range(1,n):
  tmpS = a[i] + S[i-1]
  if tmpS*S[i-1] < 0:
    S[i] = tmpS
    continue
  else:
    if i%2 == 0:
      S[i] = 1
      tmp1 += abs(1 - tmpS)
    else:
      S[i] = -1
      tmp1 += abs(-1-tmpS)
if a[0] < 0:
  S[0] = a[0]
else:
  S[0] = -1
  tmp2 += abs(-1-a[0])
for i in range(1,n):
  tmpS = a[i] + S[i-1]
  if tmpS*S[i-1] < 0:
    S[i] = tmpS
    continue
  else:
    if i%2 == 0:
      S[i] = -1
      tmp2 += abs(-1 - tmpS)
    else:
      S[i] = 1
      tmp2 += abs(1-tmpS)
print(min(tmp1,tmp2))

Measured memory_bytes: 14468
N = int(input())
S = [input() for i in range(N)]

dic = {}
dic["TLE"]=0
dic["AC"]=1
dic["WA"]=2
dic["RE"]=3

arr = [0 for i in range(4)]

for i in range(len(S)):
  arr[dic[S[i]]] += 1

print("AC x " + str(arr[dic["AC"]]))
print("WA x " + str(arr[dic["WA"]]))
print("TLE x " + str(arr[dic["TLE"]]))
print("RE x " + str(arr[dic["RE"]]))


Measured memory_bytes: 16184
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

final class Main {

    public static final int HEIGHT = 8;
    public static final int WIDTH = 8;
    private static final String[] BLOCK_NAME_LIST = {"A", "B", "C", "D", "E",
                                                     "F", "G"};
    private static final char[][] A = {{1, 1}, {1, 1}};
    private static final char[][] B = {{1}, {1}, {1}, {1}};
    private static final char[][] C = {{1, 1, 1, 1}};
    private static final char[][] D = {{0, 1}, {1, 1}, {1, 0}};
    private static final char[][] E = {{1, 1, 0}, {0, 1, 1}};
    private static final char[][] F = {{1, 0}, {1, 1}, {0, 1}};
    private static final char[][] G = {{0, 1, 1}, {1, 1, 0}};
    private static final ArrayList<char[][]> BLOCKS = new ArrayList<char[][]>();

    private static String solv(final char[][] field) {
        int blockIndex = 0;
        for (char[][] block : BLOCKS) {
            for (int i = 0; i < field.length; i++) {
                for (int j = 0; j < field[i].length; j++) {
                    boolean exist = true;
                    for (int k = 0; exist && k < block.length; k++) {
                        for (int l = 0; exist && l < block[k].length; l++) {
                            if (field.length <= i + k
                                    || field[i + k].length <= j + l) {
                                exist = false;
                                continue;
                            }
                            if (field[i + k][j + l] != block[k][l]) {
                                exist = false;
                                break;
                            }
                        }
                    }
                    if (exist) {
                        return BLOCK_NAME_LIST[blockIndex];
                    }
                }
            }
            blockIndex++;
        }
        return BLOCK_NAME_LIST[blockIndex - 1];
    }

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        BLOCKS.add(A);
        BLOCKS.add(B);
        BLOCKS.add(C);
        BLOCKS.add(D);
        BLOCKS.add(E);
        BLOCKS.add(F);
        BLOCKS.add(G);
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String input = inputReader.readLine();
            if (input == null) {
                break;
            }
            char[][] field = new char[WIDTH][HEIGHT];
            int lineCount = 0;
            do {
                field[lineCount] = input.toCharArray();
                for (int i = 0; i < field[lineCount].length; i++) {
                    field[lineCount][i] = (char) (field[lineCount][i] - '0');
                }
                lineCount++;
                input = inputReader.readLine();
            } while (input != null && !input.equals(""));
            String ret = solv(field);
            System.out.println(ret);
        }
    }
}

Measured memory_bytes: 10000
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;


ll SQRT(ll n){ll s=1; while(s*s>n||n>=(s+1)*(s+1)){ s=(n/s+s)/2; } return s;}
int main(){
    constexpr ll mod=1e9+7;
    int N,K;cin>>N>>K;
    int s=SQRT(N);
    vector<vector<ll>> dp(K+1,vector<ll>(2*s,0));
    dp[0][0]=1;
    vector<ll> S(2*s+1),cnt(2*s+1);
    REP(j,2*s){
        //cnt[j]:j-1番目の数より大きくj番目の数以下の数がいくつあるか
        if(j<s) cnt[j]=1;
        else{
            int rev = 2*s-j;
            cnt[j]=N/rev-N/(rev+1);
            if(N/rev==s) cnt[j]=0;
        }
    }
    REP(i,K){
        S[0]=0;
        REP(j,2*s){
            S[j+1]=S[j]+dp[i][j];
        }
        REP(j,2*s){
            dp[i+1][j]+=cnt[j]*S[2*s-j];
            dp[i+1][j]%=mod;
        }
    }
    ll ans=0;
    REP(i,2*s){
        ans+=dp[K][i];
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 51344
import os, sys, re, math

N = int(input())

a = []
for _ in range(N):
    a.append(int(input()))
sorted_a = sorted(a,reverse=True)[:2]

for ai in a:
    if ai == sorted_a[0]:
        print(sorted_a[1])
    else:
        print(sorted_a[0])


Measured memory_bytes: 68796
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 1000000007 
#define ff first
#define ss second
#define pb push_back  
#define INF 1000000000000
									//nestedcode



long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%M;
        a = a * a%M;
        b >>= 1;
    }
    return res;
}

ll r[4005],g[4005],b[4005],rr[4005],gg[4005],bb[4005];

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;
    ll n,i,j,ans;
    cin>>n;
    cin>>s;
    for(i=0;i<n;i++){
    	if(s[i] == 'R'){
    		r[i] = 1;
		}if(s[i] == 'G'){
			g[i] = 1;
		}if(s[i] == 'B'){
			b[i] = 1;
		}
	}
	
	rr[0] = r[0];
	bb[0] = b[0];
	gg[0] = g[0];
	for(i=1;i<n;i++){
		
		rr[i] = rr[i-1] + r[i];
		gg[i] = gg[i-1] + g[i];
		bb[i] = bb[i-1] + b[i];
	}
	ans = 0;
	
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(s[i] != s[j]){
				if((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')){
					ll d = j-i;
					if(j + d < n && b[j+d] == 1){
						ans -= 1;
					}
				//	cout<<i<<" "<<j<<endl;
					ans += bb[n-1] - bb[j-1];
				}
				else if((s[i] == 'B' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'B')){
					ll d = j-i;
					if(j + d < n && r[j+d] == 1){
						ans -= 1;
					}
					ans += rr[n-1] - rr[j-1];
				}
				else if((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')){
					ll d = j-i;
					if(j + d < n && g[j+d] == 1){
						ans -= 1;
					}
					ans += gg[n-1] - gg[j-1];
				}
			}
//			cout<<i<<" "<<j<<" "<<ans<<endl;
		}
	}
	
	cout<<ans;
    
}


Measured memory_bytes: 3792
#include <stdio.h>

int main(void)
{
  int a[3], s = 0, i, j;

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

  for (i = 0; i < 2; i++) {
    for (j = i + 1; j < 3; j++){
      if (a[i] != a[j]) {
        s++;
      }
    }
  }

  if (s == 0) {
    printf("%d\n", s + 1);
  } else {
    printf("%d\n", s);
  }

  return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val (n,m,c) = readLine()!!.split(" ").map { it.toInt() }
    val b = readLine()!!.split(" ").map { it.toInt() }
    var count = 0
    for (i in 0 until n) {
        val a = readLine()!!.split(" ").map { it.toInt() }
        var answer = c
        for (j in 0 until m) {
            answer += a[j] * b[j]
        }
        if (answer > 0) count++
    }
    println(count)
}


Measured memory_bytes: 37908
def main():
    n = input()
    l = len(n)
    ans = 0
    p = 0

    for i in range(l-1, -1, -1):
        v = int(n[i])
        if p == 1:
            v += 1
        if v > 5 or (i != 0 and v == 5 and int(n[i-1]) >= 5):
            ans += (10-v)
            p = 1
        else:
            ans += v
            p = 0
    if p == 1:
        ans += 1

    print(ans)
main()

Measured memory_bytes: 53612
#include <bits/stdc++.h>
/*
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>
 */
using namespace std;
#define LSON            id << 1 , l , mid
#define RSON            id << 1 | 1 , mid + 1 , r
#define LS              id << 1
#define RS              id << 1 | 1
#define ROOT            1 , 1 , n
#define CLR(x , y)      memset(x , y , sizeof(x))
#define LOWBIT(x)       x & (-x)
#define FORN(i , a , n)  for(int i = (a) ; i <= (n) ; ++i)
#define FORP(i , n , a)  for(int i = (n) ; i >= (a) ; --i)
#define CASE(x)		printf("Case %d: ", x)
#define CASE#(x) printf("Case #%d: " , x)
#define SFD(x)      scanf("%lf" , &x)
#define SFC(x)      scanf(" %c" , &x)
#define SFS(x)      scanf(" %s" , x)
#define SFI(x)      scanf("%d" , &x)
//#define SFL(x)      scanf("%lld" , &x)
#define SFI64(x)    scanf("%I64d" , &x)
#define PFF(x)         printf("%f" , x)
#define PFD(x)         printf("%lf" , x)
#define PFI(x)         printf("%d" , x)
#define PFC(x)         printf("%c" , x)
#define PFS(x)         printf("%s" , x)
#define PFI64(x)       printf("%I64d" , x)
//#define PFL(x)         printf("%lld" , x)
#define SPACE          printf(" ")
#define PUT            puts("")
#define TEST           printf("pass\n");
#define LPUP(i , j , k) for(int i = j ; i <= k ; ++i)
#define LPDW(i , j , k) for(int i = j ; i >= k ; --i)
#define PB(x)          push_back(x)
#define ALL(A)         A.begin(), A.end()
#define SZ(A)          int((A).size())
#define LBD(A, x)      (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x)      (upper_bound(ALL(A), x) - A.begin())
//#define LOCAL
static const double PI = acos(-1.0);
static const double EPS = 1e-8;
static const int SEED = 131;
static const int OO = 0X3fffffff;
typedef unsigned long long ULL;
typedef long long LL;
typedef double DB;
inline int read1()
{
    int x = 0;
    int f = 1 ; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch - '0'); ch = getchar();}
    x *= f;
    return x;
}

struct buf
{
	operator int()
	{
		int x = 0 , y = 0 , c = getchar();
		while(c < 48)
			y = c == 45 , c = getchar();
		while(c > 47)
			x = (x << 1) + (x << 3) + (c - 48) , c = getchar();
		return y ? -x : x;
	}
}read;



inline void write(int x)
{
    int y = 10 , len = 1;
	if(x < 0)
	{
		putchar('-');
		x = -x;
	}
    while(y <= x)
    {
        y *= 10;
        ++len;
    }
    while(len--)
    {
        y /= 10;
        putchar(x / y + 48);
        x %= y;
    }
}

/************************Little Pea****************************/

int a , b;
int main()
{
#ifdef LOCAL
    freopen("G:\\desktop\\littlepea\\in.data" , "r" , stdin);
#endif
    SFI(a);SFI(b);
    printf("%d\n" , (a - 1) * (b - 1));

#ifdef LOCAL
    fclose(stdin);fclose(stdout);
#endif
}


Measured memory_bytes: 256
n,q=gets.split.map &:to_i
a=$<.read.split.map.with_index{|p,i|i.odd? ? p.to_i : p}
c=0
while a.size>0
m,t=a.slice!(0,2)
t>q ?(a.push(m,t-q);c+=q) : (puts"#{m} #{c+=t}")
end


Measured memory_bytes: 13440
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
const int maxn=5+1e2;
int a[maxn];
int main(){
    int n,m;
    cin>>n>>m;
    int ans=0;
    for (int i=1;i<=n;i++){
        cin>>a[i];
        ans+=a[i];
    }
    sort(a+1,a+n+1);
    int ok=0;
    double res=1.0*ans/(4*m);
    for (int i=n;i;i--){
        if (double(a[i])>=res)
            m--;
        else
          	ok=1;
        if (!m)
          	break;
    }

    if (ok) 
  		puts("No");
    else
      	puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> d(N);
  rep(i,N) cin >> d[i];
  ll ans = 0;
  for(int i=0; i<N; ++i) {
    for(int j=i+1; j<N; ++j) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N],b[N];
struct edge{
	int x,y;
}e[N];
bool cmp(edge a,edge b){
	if(a.x!=b.x)return a.x<b.x;
	return a.y<b.y;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(x>y)swap(x,y);
		e[i].x=x;e[i].y=y;
	}
	
	if(a[e[0].x]<a[e[0].y])b[e[0].x]=true;
	else if(a[e[0].x]>a[e[0].y])b[e[0].y]=true;
	else {
		b[e[0].x]=true;b[e[0].y]=true;
	}
	for(int i=1;i<m;i++){
		if(e[i].x==e[i-1].x && e[i].y==e[i-1].y){
			b[e[i].x]=true;b[e[i].y]=true;
		}
		else {
			if(a[e[i].x]<a[e[i].y])b[e[i].x]=true;
			else if(a[e[i].x]>a[e[i].y])b[e[i].y]=true;
			else {
				b[e[i].x]=true;b[e[i].y]=true;
			}
		}
	}
	
	int ans=0;
	for(int i=1;i<=n;i++){
		if(b[i]==false)ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 5176
#include <iostream>
using namespace std;
int main(){
        int n, i;
        float s;
        s = 0;
        cin >> n;
        int a[n];
        for (i=0;i<n;i++){
                cin >> a[i];
                s = s + 1/((float)a[i]);
        }
        cout << 1/s;
}


Measured memory_bytes: 256
from sys import stdin


def main():
    A, B, K = [int(x) for x in stdin.readline().rstrip().split()]
    a = [x for x, y in zip(range(A, B + 1), range(K))]
    b = [x for x, y in zip(range(B, A - 1, -1), range(K))]
    c = sorted(list(set(a + b)))
    for x in c:
        print(x)


if __name__ == '__main__':
    main()


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

int main()
{
    int flg=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length()/2;i++)
    {
        if(s[i]!=s[s.length()-1-i]) flg++;
    }
    cout<<flg;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
enum{NONE,BLA,WHI};

int kui[50][50]={};
bool rin[50][50][WHI+1]={};
int W,H;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
void clear(){
     for(int i=0;i<50;i++){
	  for(int j=0;j<50;j++){
	       kui[i][j]=0;
	       rin[i][j][BLA]=false;rin[i][j][WHI]=false;
	  }
     }
}
void rec(int x,int y,int color){
     if(x>=W||x<0||y>=H||y<0) return;
     if(kui[x][y]>0||rin[x][y][color])return;
     rin[x][y][color]=true;
     for(int i=0;i<4;i++){
	  rec(x+dx[i],y+dy[i],color);
     }
}

int main(){
     while(cin>>W>>H,W||H){
	  clear();
	  for(int i=0;i<H;i++){
	       for(int j=0;j<W;j++){
		    char t;
		    cin>>t;
		    switch(t){
		    case '.':
			 break;
		    case 'B':
			 kui[j][i]=BLA;
			 break;
		    case 'W':
			 kui[j][i]=WHI;
			 break;
		    }
	       }
	  }
	  for(int i=0;i<W;i++){
	       for(int j=0;j<H;j++){
		    switch(kui[i][j]){
		    case BLA:
			 for(int k=0;k<4;k++) rec(i+dx[k],j+dy[k],BLA);
			 break;
		    case WHI:
			 for(int k=0;k<4;k++) rec(i+dx[k],j+dy[k],WHI);
			 break;
		    }
	       }
	  }
	  /*for(int i=0;i<W;i++){
	       for(int j=0;j<H;j++){
		    cout<<kui[i][j];
	       }
	       cout<<endl;
	       }*/
	  int sumw=0,sumb=0;
	  for(int i=0;i<W;i++){
	       for(int j=0;j<H;j++){
		    if(rin[i][j][BLA]&&(!rin[i][j][WHI]))sumb++;
		    if(rin[i][j][WHI]&&(!rin[i][j][BLA]))sumw++;
	       }
	  }
	  cout<<sumb<<" "<<sumw<<endl;
     }
     return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define int long long
signed main(){
    char AA, BB;
    string A, B;
    cin >> AA >> BB;
    int a = AA - '0';
    int b = BB - '0';
    if(a >= b){for(int i = 0;i < a;i++){
        B += BB;
    }
    cout << B;
    }

    else if(a <= b){for(int i = 0;i < b;i++){
        A += AA;
    }
    cout << A;
    }

}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {

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

  unordered_map<int, int> mp, mprev;
  int darkcnt = 0;

  rep(i, M) {
    int d; cin >> d; d--;
    mp[d] = darkcnt;
    mprev[darkcnt++] = d;
  }

  vector<vector<int>> G(N);

  rep(i, N) {
    rep(k, K) {
      int to; cin >> to; to--;
      G[i].push_back(to);
    }
  }

  int dp[1 << M];
  rep(i, 1 << M) dp[i] = inf;

  dp[(1 << M) - 1] = 0;
  queue<int> q;
  q.push((1 << M) - 1);

  while(!q.empty()) {
    auto const S = q.front(); q.pop();
    rep(to_dir, K) {
      auto T = S;
      auto TAdd = 0;
      rep(from, M) {
        if(T >> from & 1) {
          T &= ~(1 << from);
          auto to = G[mprev[from]][to_dir];
          if(mp.find(to) != mp.end()) {
            TAdd |= 1 << mp[to];
          }
        }
      }
      T |= TAdd;
      if(dp[T] > dp[S] + 1) {
        dp[T] = dp[S] + 1;
        q.push(T);
      }
    }
  }

  cout << dp[0] << endl;
  
  return 0;
}

Measured memory_bytes: 3572
N, K = map(int, input().split())
X = list(map(int, input().split()))
XN, XP = [], []
for x in X:
    if x < 0: XN.append(-x)
    else: XP.append(x)
XN.reverse()
T = [0]
S = 0
for i, x in enumerate(XN):
    if i==K-1:
        T.append(x)
        break
    T.append(2*x)
res = float("inf")
for i in range(K):
    if K-1-i >= len(XP) or i>=len(T):
        continue
    res = min(T[i] + XP[K-1-i], res)

T = [0]
S = 0
for i, x in enumerate(XP):
    if i==K-1:
        T.append(x)
        break
    T.append(2*x)
for i in range(K):
    if K-1-i >= len(XN) or i>=len(T):
        continue
    res = min(T[i] + XN[K-1-i], res)

print(res)

Measured memory_bytes: 96960
#include<iostream>

using namespace std;

int main() {
	int a, b, c;

	cin >> a >> b >> c;
	if (a > b) {
		if (a > c) {
			cout << b + c;
		}
		else {
			cout << b + a;
		}
	}
	else {
		if (b > c) {
			cout << a + c;
		}
		else {
			cout << a + b;
		}
	}
	return 0;

}

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

int main() {
	char S;
	int ans = 0;
	for (int i = 0; i < 4; i++) {
		cin >> S;

		if (S == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
ac = [0 for i in range(n)]
wa = [0 for i in range(n)]

for i in range(m):
    check = input().split()
    if ac[int(check[0])-1]==0:
        if check[1]=='AC':
            ac[int(check[0])-1]=1
        else:
            wa[int(check[0])-1]+=1
for i in range(n):
    if ac[i]==0:
        wa[i]=0
ans = [sum(ac),sum(wa)]
print(*ans,sep=' ')

Measured memory_bytes: 4760
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = input[0];
            var L = input[1];

            var sum = 0;
            var absMin = int.MaxValue;
            var a = 0;
            for (int i = 0; i < N; i++)
            {
                sum += L + i;
                var abs = Math.Abs(L + i);
                if (abs < absMin)
                {
                    absMin = abs;
                    a = L + i;
                }
            }

            Console.WriteLine(sum - a);
        }
    }
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 1000000007

int n,c;
int d[33][33];
int col[505][505];
int cnt[3][33];

int main(){
  cin>>n>>c;
  rep(i,c)rep(j,c)cin>>d[i][j];
  rep(i,n)rep(j,n){
    cin>>col[i][j];
    col[i][j]--;
  }
  rep(i,n)rep(j,n){
    cnt[(i+j)%3][col[i][j]]++;
  }
  int res=INF;
  rep(x,c)rep(y,c)rep(z,c){
    if(x==y||y==z||z==x)continue;
    int sa=0,sb=0,sc=0;
    rep(i,c){
      if(i!=x)sa+=d[i][x]*cnt[0][i];
    }
    rep(i,c){
      if(i!=y)sb+=d[i][y]*cnt[1][i];
    }
    rep(i,c){
      if(i!=z)sc+=d[i][z]*cnt[2][i];
    }
    minch(res,sa+sb+sc);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		int[] arr = new int[N];
		StringTokenizer st = new StringTokenizer(br.readLine());
		int xor = 0;
		for (int i = 0; i < N; i++) {
			arr[i] = Integer.parseInt(st.nextToken());
			xor ^= arr[i];
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < arr.length; i++)
			sb.append((xor ^ arr[i]) + " ");
		System.out.println(sb);
	}

}

Measured memory_bytes: 59488
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define t int t;scanf("%d",&t);for(int v=1;v<=t;v++)
#define loop_arr(i,a,b) for(int i=a;i<b;i++)
#define loop_norm(i,a,b) for(int i=a;i<=b;i++)
#define minheap priority_queue<int,vector<int>,greater<int> >
#define maaheap priority_queue<int>
#define pb push_back
#define newl "\n"
ll BIGMOD ( ll a, ll p, ll m )
{
    ll result = 1;
    ll x = a;

    while ( p )
    {
        if ( p & 1 ) //p is odd
        {
            result = ( result * x ) % m;
        }
        x = ( x * x ) % m;
        p = p >> 1;
    }

    return result;
}

bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int row,col;
int grid[1005][1005];
ll memo[1005][1005];
void dp()
{
    memo[0][0]=1;
   for(int i=1;i<row;i++)
   {
      if(grid[i][0]==1)
      {
       if(memo[i-1][0]==1)   memo[i][0]=1;
       else memo[i][0]=0;
      }
      else memo[i][0]=0;
   }
   for(int i=1;i<col;i++)
   {
      if(grid[0][i]==1)
      {
       if(memo[0][i-1]==1)   memo[0][i]=1;
       else memo[0][i]=0;
      }
      else memo[0][i]=0;
   }
   for(int i=1;i<row;i++)
   {
       for(int j=1;j<col;j++)
       {
           if(grid[i][j]==0) memo[i][j]=0;
           else memo[i][j]=(memo[i-1][j]+memo[i][j-1])%mod;
       }
   }
}
int main()
{
  // fastread;
   cin>>row>>col;
   char ch;
   loop_arr(i,0,row)
   {
       loop_arr(j,0,col)
       {
           cin>>ch;
           if(ch=='.') grid[i][j]=1;
           else grid[i][j]=0;
       }
   }
   dp();
   cout<<memo[row-1][col-1]<<newl;

  return 0;
}


Measured memory_bytes: 12032
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> V(N, 0);
  for (int i = 0; i<N;i++) {
    cin >> V[i];
  }
  int ans = 0;
  for (int i = 0; i<N;i++) {
    int c;
    cin >> c;
    if (c < V[i]) {
      ans += (V[i]-c);
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

// void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
// void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

template<class T> void vprn(T &v, string s, string m, string e)
{cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

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

	double a;
	rp(i,n){
		double x;cin>>x;
		a += (double)1./x;
	}
	printf("%lf\n",(1./a));
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#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 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%ld", &n);
    vector<int> a(n);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    printf("%d\n", a[n-1]-a[0]);
}

Measured memory_bytes: 256
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop,heapify
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

from itertools import accumulate
from functools import lru_cache

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
 
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]



n, k = li()
l = li()

dp = [False] * (k + 1)


for j in range(k + 1):
    for i in l:
        if j >= i and not dp[j - i]:dp[j] = True

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

Measured memory_bytes: 69140
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,k; cin >> n >> k;
  int zero = 0, half = 0;
  for(int a = 1; a <= n; a++){
    if(a % k == 0) zero++;
    if(a % k == k/2) half++;
  }
  ll ans = pow(zero,3);
  if(k % 2 == 0) ans += pow(half,3);
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    long num;
    cin >> num;
    long ans = 0;
    ans += (num / 500) * 1000;
    num %= 500;
    ans += (num/5) * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans;
bool t[101];
int main() {
	for(int i=0; i<3; ++i) {
		int x;
		scanf("%d",&x);
		if(!t[x])++ans,t[x]=true;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct Data{
    bool s[100][100];
};
    int w,h;
const int dx[] = {0,1,0,-1},dy[] = {1,0,-1,0};
int ans = 0;
void dfs(int x,int y,int t,Data D){
    D.s[y][x] = false;
    bool flg = true;
    for(int i = 0;i < 4;i++){
        int nx = x+dx[i];
        int ny = y+dy[i];
        if(0<=nx&&nx<w&&0<=ny&&ny<h){
            if(D.s[ny][nx]){
                dfs(nx,ny,t+1,D);
                flg = false;
            }
        }
    }
    if(flg)ans = max(ans,t);
    return;
}
int main(){
    while(cin>>w>>h,w&&h){
            ans = 0;
        Data D;
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                cin>>D.s[i][j];
            }
        }
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(D.s[i][j]){
                    dfs(j,i,0,D);
                }
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1480
x1, y1, x2, y2 = map(int, input().split())

a = x2 - x1
b = y2 - y1

x3 = x2 - b
y3 = y2 + a
x4 = x2 - b - a
y4 = y2 + a - b

print(x3,y3,x4,y4)

Measured memory_bytes: 9172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n;
double a[105];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n) cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=2;i<=n;++i) a[i]=(a[i]+a[i-1])/2.0;
	printf("%0.8lf",a[n]);
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
using namespace std;
map<int,int>m;
vector<int>v;
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
if(m[x]==0)
v.push_back(x);
m[x]++;
}
int ans=0;
for(int i=0;i<v.size();i++)
if(v[i]>m[v[i]])
ans+=m[v[i]];
else if(v[i]<m[v[i]])
ans+=m[v[i]]-v[i];
cout<<ans;
return 0;
}

Measured memory_bytes: 5112
h, w = map(int, input().split())
a = [''] * h
# 行の数だけ入力
for i in range(h):
  a[i] = input()

row = [False] * h
col = [False] * w

# 各セルについてTrue/Falseを設定
for i in range(h):
  for j in range(w):
    if a[i][j] == "#":
      row[i] = True
      col[j] = True

# 出力
for i in range(h):
  if row[i]:
    for j in range(w):
      if col[j]:
        print(a[i][j], end="")
    print()

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

int main() {
    std::string s;
    std::cin >> s;
    int x, xmin = INT32_MAX;
    for (int i = 0; i + 2 < s.length(); ++i) {
        x = std::stoi(s.substr(i, 3));
        xmin = std::min(xmin, abs(753 - x));
    }
    printf("%d", xmin);
    return 0;
}

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

using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> q(n);
    for(int i = 0; i < n; i++){
        int p;
        cin >> p;
        p--;
        q[p] = i;
    }
    int ma = 1;
    int last = q[0];
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(last < q[i]){
            last = q[i];
            ans++;
        }else{
            ma = max(ma, ans);
            last = q[i];
            ans = 1;
        }
    }
    ma = max(ma, ans);
    cout << n - ma << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

// vector<ll> score(ll t[]) {
//     ll i, j, sc = 0;
//     vector<ll> v;
//     v.pb(0);
//     for (i = 1; i <= D; i++){
//         sc += s[i][t[i]];
//         last[t[i]] = i;
//         for (j = 1; j <= 26;j++)
//             sc -= c[j] * (i - last[j]);
//         v.pb(sc);
//     }
//     return v;
// }

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e15, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand365(1, 365);
    ll INF = 1e18;
    double start_temp = 30000, end_temp = 0;
    for (i = 0; i < 500000; i++){
        ll ma = -1e15, p;
        ll d = rand365(mt);
        for (j = 1; j <= 26; j++){
            if(j!=t[d]){
                ll sc = eval(d, j);
                if(sc > ma){
                    ma = sc;
                    p = j;
                }
            }
        }
        double temp = start_temp + (end_temp - start_temp) * i / 100000;
        double prob = exp(ma / temp);
        if (prob > (rand() % INF) / (double)INF){
            s1[t[d]].erase(d);
            s2[t[d]].erase(-d);
            s1[p].insert(d);
            s2[p].insert(-d);
            t[d] = p;
        }
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

Measured memory_bytes: 4492