akhauriyash/Code-Regression huggingface dataset:
n, m, l = map(int, input().split())
a = []
b = []
ans = []
for x in range(n):
    a.append(list(map(int, input().split())))
for y in range(m):
    b.append(list(map(int, input().split())))

# print(a, b)
sub_total = []
for e in range(0, n):
    tm2 = []
    for f in range(0, l):
        tmp = []
        for g in range(0, m):
            tmp.append(a[e][g] * b[g][f])
            if len(tmp) == m:
                tm2.append(sum(tmp))
                tmp.clear()
                if len(tm2) == l:
                    print(*tm2)
                    tm2.clear()



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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int s,i,j,k,x,y,z,mod=1000000007;
    cin>>s;
    long long int dp[s+1]={0};
    for(i=3;i<=s;i++){
        dp[i]=1;
    }
    for(i=6;i<=s;i++){
        for(j=3;i-j>=3;j++){
            dp[i]+=dp[i-j];
            dp[i]%=mod;
        }
    }
    cout<<dp[s];
    return 0;
}


Measured memory_bytes: 3592
N = int(input())
a = [int(i) for i in input().split()]
ans=0
for i in range(len(a)):
	zyou = 1
	for g in range(1145148101919):
		if a[i]%2**zyou==0:
			ans+=1
			zyou+=1
		else:
			break
print(ans)

Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e5+5;
ll n,a[MAX];
int main(){
    cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum^=a[i];
    }
    for(int i=1;i<=n;i++){
        if(i==n){
            cout<<(sum^a[i])<<endl;
        }else{
            cout<<(sum^a[i])<<" ";
        }
    }
    return 0;
}


Measured memory_bytes: 5192
// Skill Up
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define INF 1 << 30

int main() {
    int N, M, X = 0, min_money = INF;
    int A[13][13] = {0};
    cin >> N >> M >> X;
    for (int i = 0; i < N; i++) for (int j = 0; j < M + 1; j++) { cin >> A[i][j]; }

    int money;
    int rikai[M] = {0};
    for (int i = 1; i < (1 << N); i++) {
        money = 0;
        for (int j = 0; j < M; j++) rikai[j] = 0;

        for (int j = 0; j < N; j++) {
            if (i & (1 << j)) {
                money += A[j][0];
                for (int k = 0; k < M; k++) rikai[k] += A[j][k+1];
            }
        }
        int count = 0;
        for (int j = 0; j < M; j++) {
            if (rikai[j] >= X) count++;
        }
        if (count == M) min_money = min(min_money, money);
    }

    if (min_money == INF) cout << -1 << endl;
    else cout << min_money << endl;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		int[][] xy = new int[N][2];
		for(int i = 0; i<N; i++) {
			String[] in = br.readLine().split(" ");
			xy[i][0] = Integer.parseInt(in[0]);
			xy[i][1] = Integer.parseInt(in[1]);
		}
		
		double sum = 0;
		
		for(int j=0; j<N;j++) {
			for(int k=j+1; k<N; k++) {
				sum += LEN(xy[j][0],xy[j][1],xy[k][0], xy[k][1]);
			}
		}
		
		System.out.print(sum*2/N);
	}
	
	private static double LEN(int px, int py, int qx, int qy) {
	    return Math.sqrt((px-qx)*(px-qx) + (py-qy)*(py-qy));
	}
}


Measured memory_bytes: 33284
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007 
typedef long long ll;

void dfs(int i,vector<int> adj[],vector<int> &dp,vector<bool> &vis)
{
	vis[i]=1;

	for(int j=0;j<adj[i].size();j++)
	{
		if(!vis[adj[i][j]])
		{
			dfs(adj[i][j],adj,dp,vis);
		}

		dp[i]=max(dp[i],1+dp[adj[i][j]]);
	}
}

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n,m;
	cin>>n>>m;

	vector<int> adj[n+1];

	int x,y;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y;
		adj[x].push_back(y);
	}

	vector<int> dp(n+1,0);
	vector<bool> vis(n+1,0);
 

	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
			dfs(i,adj,dp,vis);
	}

	int mi=0;
	for(int i=1;i<=n;i++)
		mi=max(mi,dp[i]);
	cout<<mi<<"\n";

	return 0;
}

Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[3 * N];
        for (int i = 0; i < N * 3; i++) {
            A[i] = scan.nextInt();
        }
        Arrays.sort(A);
        long answer = 0;
        for (int i = N; i < N * 3; i+=2) {
            answer += A[i];
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 91076
import java.util.*;
class Main{
    public static void main(String[] args)
    {
	Scanner in = new Scanner(System.in);
	String s,s2;
	int n,de=0;
	s = in.next();
	n = in.nextInt();
	for(int i=0;i<n;i++)
	    {
		s2 = in.next();
		int ln = 2*s2.length();
s2 = s2 + s2;
		while(ln-- > 0)
		    {

			if(s2.contains(s))
			    {
				de++;
				break;
			    }
			
		    }
	    }
	System.out.println(de);
    }
} //Res***2Dツつウツづアツづ個づーツ参ツ考

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W ==0){
                break;
            }else{
                for(int i = 0; i < H; i++){
                    for(int j = 0; j < W; j++){
                        if((i+j) % 2 == 0){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}



Measured memory_bytes: 36860
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;

        signed main() {
        int n;
        cin>>n;
        string s;
        map<string,int> mp;
        for(int i=0;i<n;i++){
                cin>>s;
                mp[s]++;

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

        }
        int ans=0;
        for(auto it=mp.begin();it!=mp.end();it++){
                ans=max(ans,it->second);
        }
        cout<<ans;

        
        
        


      }


        


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

using namespace std;

int main()
{
    int A, B, C, D;
    
    cin >> A >> B >> C >> D;
    
    auto area1 = A * B;
    auto area2 = C * D;
    
    printf("%d\n",
        (area1 >= area2) ? area1 : area2);
        
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

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

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

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */

#include <iostream>
#include <fstream>

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

class BResistorsInParallel {
public:
	void solve(std::istream& in, std::ostream& out) {
        out << setprecision(12);
        int n;
        in >> n;
        vector<double> a(n);
        rep(i,n){
            in >> a[i];
        }
        double t=0.0;
        rep(i,n){
            t+=1.0/a[i];
        }
        out << 1.0/t << endl;
	}
};


int main() {
	BResistorsInParallel solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char c[109][109];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> c[i][j];
        }
    }
    for(int i=0;i<2*h;i++){
        for(int j=0;j<w;j++){
            cout << c[i/2][j];
        }
        cout << endl;
    }
}

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

int main(){
    int n, a[15], xy[15][15];

    cin >> n;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j) xy[i][j] = -1;
    }

    for(int i=0;i<n;++i){
        cin >> a[i];
        for(int j=0;j<a[i];++j){
            int x, y;
            cin >> x >> y;
            xy[i][x-1] = y;
        }
    }

    int ans = 0;
    for(int p=0;p<(1<<n);++p){
        int c = 0;
        for(int b=0;b<n;++b) if(p & (1<<b)) ++c;
        for(int i=0;i<n;++i){
            if((p & (1<<i)) == 0) continue;
            for(int j=0;j<n;++j){
                if(xy[i][j] < 0) continue;
                if(xy[i][j] != ((p>>j)&1)) goto l_ng;
            }
        }
        ans = max(ans, c);
        l_ng:;
    }

    cout << ans << endl;

    return 0;
}

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


//System.out.println();
public class Main implements Runnable { //クラス名はMain

    public static void main(String[] args) {
    	Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if (u.equals(s)) {
        	a = a- 1;
        }else {
        	b = b-1;
        }
        System.out.println(a+" "+b);

    }
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

signed main() {
  int n;
  cin >> n;
  vector<int> a(n);
  unordered_map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[i+1-a[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += m[a[i]+i+1];
  }
  cout << ans << endl;
}


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

void printVec(const vector<vector<int>> v) {
	for (int i = 0;i < v.size();i++) {
		for (int j = 0;j < v[i].size();j++) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}


int main() {
	int n;
	long long takashi=0;
	
	cin >> n;
	vector<int>A(n);
	vector<int>B(n);
	vector<vector<int>>A_B(n,vector<int>(2));

	
	for (int i = 0;i < n;i++) {
		cin >> A[i] >> B[i];
		A_B[i][1] = A[i] + B[i];

		A_B[i][0] = i;
	}

	sort(A_B.begin(), A_B.end(), [](const vector<int>& alpha, const vector<int>& beta) {return alpha[1] < beta[1];});


	int bit = 1;
	for (int i = 0;i < n;i++) {
		if (bit == 1) {
			takashi += A[A_B[n - i-1][0]];
			bit *= (-1);

		}
	
		else {

			takashi -= B[A_B[n - i-1][0]];
			bit *= (-1);

			
		}

	}

	cout << takashi << endl;
	return 0;
}




Measured memory_bytes: 6528
#include<iostream>
#include <string>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main(){
  ll N, K, r, s;
  cin >> N >> K;
  vector<int> A(N+1, 0), B(N+1, -1), C(N+1, -1);
  //B[i]はi番目に訪れる街。C[i]は街iを訪れる順番。
  for (ll i = 1; i <= N; i++) {
    cin >> A[i];
  }

  B[0] = 1;
  C[1] = 0;
  for (ll i = 1; i <= N; i++) {
    B[i] = A[B[i-1]];
    if (C[B[i]] == -1) {
      C[B[i]] = i;
    }else{
      s = C[B[i]];
      r = i - s;
      break;
    }
  }

  if (K <= s) {
    cout << B[K] << endl;
  }else{
    cout << B[s + ((K-s)%r)] << endl;
  }

  return 0;
}


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  string s;
  cin >> s;
  int odd = 0;
  int evn = 0;
  for (int i = 0; i < s.length(); i++) {
    if (i % 2 == 0) {
      if (s[i] == '0') {
        evn++;
      } else {
        odd++;
      } 
    } else {
      if (s[i] == '1') {
        evn++;
      } else {
        odd++;
      } 
    }
  }
  cout << min(odd, evn) << endl;
  return 0;
}


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

int main(){
    string S;
    string Si,Sk;
    long long int answer=1;
    cin >> S;
    Si = S[0];
    if(S.size()==1){
        cout << 1 << endl;
        return 0;
    }
    if(S.size()==2){
        Sk = S[1];
        if(Si == Sk) cout << 1 << endl;
        else cout << 2 << endl;
        return 0;
    }
    Sk = S[1];

    for(int i=1;i<S.size();i++){
        Sk = S[i];
        if(Si == Sk && i < S.size()-1){
            Sk += S[i+1];
            i++;
        }

        if(Si == Sk && i == S.size()-1){
            answer--;
        }

        answer++;
       // cout << "i:" << i << " " << "Si:" << Si << " " << "Sk:" << Sk << endl;
        Si = Sk;
    }
    cout << answer << endl;
    return 0;
}

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

int main()
{
  int N, M;
  cin >> N >> M;
  
  int A[1010];
  int sum = 0;
  for(int i = 0; i < N; ++i)
  {
    cin >> A[i];
    sum += A[i];
  }
  
  int m = 0;
  for(int i = 0; i < N; ++i)
  {
    if(A[i] * 4 * M >= sum)
    {
      m++;
    }
  }
  
  if(m >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,a,b,e,i;
    e=0;
    cin>>n;
    for(i=1;i<=(n/2);i++)
    {
        a=n-i;
        b=n-a;
        if(a!=b)
        {
            e++;
        }
    }
    cout<<e<<endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin


def find_sum_of_digits(n, base=10):
    _sum = 0
    while n>0:
        _sum += n%base
        n //= base
    return _sum


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'Yes' if N%find_sum_of_digits(N)==0 else 'No'
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)


Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int X, Y;
  cin >> X >> Y;
  cout << X + Y / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;

#define Inf 10000000000


int main(){
	int N,W;
	cin>>N>>W;
	vector<int> w(N),v(N);
	for(int i=0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	
	vector<vector<long long>> dp(N+1,vector<long long> (100001,Inf));//dp[i][j] i個の品物で価値jの時の重さ最小値
	int ans = 0;
	for(int i=0;i<=N;i++){
		for(int j=0;j<=100000;j++){
			if(j==0){
				dp[i][j]=0;
			}
			else if(i!=0){
				if(j>=v[i-1]){
					dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
					dp[i][j]=min(dp[i][j],(long long)Inf);
				}
				else{
					dp[i][j]=dp[i-1][j];
				}
			}
			if(i==N){
				if(dp[i][j]<=W)ans=j;
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 80256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
li = list(t[:k])
cnt = 0
for itr, val in enumerate(t):
  if itr >= k and val == li[itr % k]:
    li[itr % k] = "x"
  else:
    if val == "r":
      cnt += p
    elif val == "s":
      cnt += r
    else:
      cnt += s
    li[itr % k] = val
print(cnt)

Measured memory_bytes: 3956
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double[] array = new double[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        int lowerBound = -(Arrays.binarySearch(array, - 0.1)) - 1;
        int start = Math.max(lowerBound - k, 0);
        double ans = Double.MAX_VALUE;
        for (int i = start; i <= n - k; i++) {
            double min = array[i];
            double max = array[i + k - 1];
            double time;
            double absMax = Math.max(Math.abs(min), Math.abs(max));
            if (min * max < 0) {
                double absMin = Math.min(Math.abs(min), Math.abs(max));
                time = 2 * absMin + absMax;
            } else {
                time = absMax;
            }
            ans = Math.min(time, ans);
        }
        System.out.println((long) ans);
    }
}

Measured memory_bytes: 50444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

ll gcd(int n, int m) {
    if (n < m) swap(n, m);
    while (m != 0) {
        int r = n % m;
        n = m;
        m = r;
    }
    return n;
}

struct P {
    ll s0, s1;
};

int main() {
    int n, x, d;
    cin >> n >> x >> d;

    if (d == 0) {
        if (x == 0) {
            cout << 1 << endl;
        } else {
            cout << n + 1 << endl;
        }
        exit(0);
    }

    if (d < 0) x *= -1, d *= -1;

    int g = gcd(abs(x), d);
    x /= g;
    d /= g;

    ll r = 0, s0 = 0, s1 = 0, t0 = x, t1 = x + (ll)d * (n - 1);

    if (d > n) {
        for (int i = 0; i <= n; i++) {
            r += (s1 - s0) / d + 1;
            s0 += t0;
            s1 += t1;
            t0 += d;
            t1 -= d;
        }
    } else {
        vector<P> vp(d, { numeric_limits<ll>::max(), numeric_limits<ll>::min() });
        ll x1 = x % d;
        if (x1 < 0) x1 += d;

        for (int i = 0; i <= n; i++) {
            P &p = vp[x1 * i % d];

            if (s1 < p.s0 || p.s1 < s0) {
                r += (s1 - s0) / d + 1;
            } else {
                r += max(s1 - p.s1, 0LL) / d;
                r += max(p.s0 - s0, 0LL) / d;
            }
            p.s0 = min(p.s0, s0);
            p.s1 = max(p.s1, s1);

            s0 += t0;
            s1 += t1;
            t0 += d;
            t1 -= d;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 2048
function Main(input) {
  const [x, k, d] = input.trim().split(" ").map((a) => parseInt(a, 10));
  const absX = Math.abs(x);
  const n = Math.floor(absX / d);
  if (k <= n) {
    console.log(absX - k * d);
  } else {
    const rem = k - n;
    if (rem % 2 === 0) {
      console.log(absX - d * n);
    } else {
      console.log(d - (absX - d * n));
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29524
/*
ID: leihaow1
TASK: 
LANG: C++              
*/ 
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if (n/100==1) cout<<"9";
	else cout<<"1";
	if (n/10%10==1) cout<<"9";
	else cout<<"1";
	if (n%10==1) cout<<"9";
	else cout<<"1";
	cout<<endl;
    return 0;
}

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

int main(){
    int N;
    string S[10010];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> S[i];
    }
    
    //まず内部のBAを数える
    int inside_BA=0;

    for(int i=0; i<N; i++){
        for(int j=0; j< ( S[i].size()-1 );j++){
            if(S[i].at(j)=='A' && S[i].at(j+1)=='B') inside_BA++;
        }
    }

    int B_A=0;
    int B_hoge=0;
    int hoge_A=0;

    for(int i=0; i<N; i++){
        if(S[i].at(0)=='B' && S[i].at(S[i].size()-1)=='A'){
            B_A++; continue;
        }
        if(S[i].at(0)=='B'){
            B_hoge++; 
        }
        if(S[i].at(S[i].size()-1)=='A'){
            hoge_A++;
        }
    }

    if(B_hoge>0 || hoge_A>0){
        cout << inside_BA + B_A + min(B_hoge, hoge_A)  << endl;
    }
    else{
        cout << inside_BA  + max(B_A,1) -1 << endl;
    }
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int xd = x2 - x1;
    int yd = y2 - y1;
    int x3 = x2 - yd;
    int y3 = y2 + xd;
    int x4 = x1 - yd;
    int y4 = y1 + xd;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        S: chars,
    }

    let c = 'C'; // ???????
    let mut iter = S[2..S.len() - 1].iter().filter(|c| c.is_uppercase());
    if S[0] == 'A'
        && iter.next() == Some(&c)
        && iter.next() == None
        && S[1].is_lowercase()
        && S.last().unwrap().is_lowercase()
    {
        println!("AC");
    } else {
        println!("WA");
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

  ll n,m;
  cin >> n >> m;
  vll s(m);
  vector<char> c(m);
   
  string res="";
  rep(i,0,n) res+='x';
  

  bool flag=true;
  rep(i,0,m) {
    cin >> s[i] >> c[i];
    s[i]--;

    if(res[s[i]]=='x') res[s[i]]=c[i];
    else if(res[s[i]]!=c[i]) flag=false;
  }
  
  if(res[0]=='x'&&res.size()!=1) res[0]='1';
  rep(i,0,n) if(res[i]=='x') res[i]='0';
     
  
  
  
  if(!flag||(res[0]=='0'&&res.size()!=1)) cout << -1 << endl;
  else cout << res << endl;
  
  
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<utility>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[25],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=2;i<n;i++)
		if(a[i-1]<=a[i]&&a[i]<=a[i+1]||a[i]>=a[i+1]&&a[i]<=a[i-1])
			ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,c=0;
	cin>>n>>k;
	int a[n];
	for (int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(a[i]>=k)
		c++;
	}
	cout<<c;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll B=1e6+7;
const ll mod=1e9+7,mod2=998244353;
ll t_mod(ll x,ll m){
  if(x>=0) return x%m;
  else{
    ll x2=x*(-1);
    x2/=m;
    x2+=2;
    return (x+m*x2)%m;
  }
}
vector<ll> contain(string b,string a){
  int al=a.length(),bl=b.length();

  ll t=1,t2=1,t3=1;
  for(int i=0;i<al;i++) {
    t*=B;
    t%=mod;
    t2*=B;
    t2%=mod2;
//    t3*=B;
//    t3%=mod3;
  }

  ll ah=0,bh=0,ah2=0,bh2=0,ah3=0,bh3=0;
  for(int i=0;i<al;i++) {
    ah=ah*B+a[i];
    ah%=mod;
    ah2=ah2*B+a[i];
    ah2%=mod2;
//    ah3=(ah3*B)%mod3+a[i];
//    ah3%=mod3;
  }
  for(int i=0;i<al;i++) {
    bh=(bh*B)+b[i];
    bh%=mod;
    bh2=(bh2*B)+b[i];
    bh2%=mod2;
//    bh3=(bh3*B)%mod3+b[i];
//    bh3%=mod3;
  }

  vector<ll> ans;
  for(int i=0;i+al<=bl;i++){
    if(ah==bh&&ah2==bh2/*&&ah3==bh3*/) {
      ans.push_back(i);
    }
    if(i+al<bl){
      bh=bh*B+b[i+al]-b[i]*t;
      bh=t_mod(bh,mod);
      bh2=bh2*B+b[i+al]-b[i]*t2;
      bh2=t_mod(bh2,mod2);
//      bh3=(bh3*B)%mod3+b[i+al]-b[i]*t3;
//      bh3=t_mod(bh3,mod3);
    }
  }
  return ans;
}
vector<ll> all_ans[200005];
int main(){
  int n;
  cin>>n;
  vector<ll> a,b;
  for(int i=0;i<n;i++) all_ans[i].push_back(0);
  for(int i=0;i<n;i++){
    ll k;
    scanf("%lld",&k);
    a.push_back(k);
  }
  for(int i=0;i<n;i++){
    ll k;
    scanf("%lld",&k);
    b.push_back(k);
  }
  for(int bi=0;bi<30;bi++){
    string rev,nrev,goal;
    for(int i=0;i<n;i++){
      ll ft=((a[i]>>bi)&1);
      if(ft){
        rev.push_back('a');
        nrev.push_back('b');
      }
      else{
        rev.push_back('b');
        nrev.push_back('a');
      }
    }
    for(int i=0;i<n;i++){
      ll ft=((b[i]>>bi)&1);
      if(ft) goal.push_back('a');
      else goal.push_back('b');
    }
    for(int i=0;i<n;i++){
      goal.push_back(goal[i]);
    }

    vector<ll> v1=contain(goal,rev),v2=contain(goal,nrev);
    vector<ll> bv1(200005,0),bv2(200005,0);
    for(int i=0;i<v1.size();i++) bv1[v1[i]]++;
    for(int i=0;i<v2.size();i++) bv2[v2[i]]++;
    ll bt=(1<<bi);
    for(int i=0;i<n;i++){
      queue<ll> kans;
      for(int j=0;j<all_ans[i].size();j++){
        if(bv1[i]==1) kans.push(all_ans[i][j]);
      }
      for(int j=0;j<all_ans[i].size();j++){
        if(bv2[i]==1) kans.push(all_ans[i][j]+bt);
      }
      ll js=all_ans[i].size()-1;
      for(;js>=0;js--) all_ans[i].pop_back();
      while(!kans.empty()){
        all_ans[i].push_back(kans.front());
        kans.pop();
      }
    }
  }
  vector<P> ans_v;
  for(int i=0;i<n;i++){
    for(int j=0;j<all_ans[i].size();j++){
      ans_v.push_back(P((n-i)%n,all_ans[i][j]));
    }
  }
  sort(ans_v.begin(),ans_v.end());
  for(int i=0;i<ans_v.size();i++) printf("%lld %lld\n",ans_v[i].first,ans_v[i].second);
  cout<<endl;
}


Measured memory_bytes: 24284
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define ft front
#define inf 1e9+7
lo a,b,c,d,e,n,m,k,x,y,z,t,a1[500005],a2[100005];
char c1,c2,c3,c4; 
string s1,s2,s3,s4;
double d1;
// map <lo,bool> id;
bool av=false;
vector <lo> v[10000];
map <pair<lo,lo >,lo> mp1;
bool vis[10000];
int main(){
    // freopen("gir.gir","r",stdin);
    // freopen("cik.cik","w",stdout);
    cin>>n;
    cin>>s1;
    for(lo i=0;i<n-2;i++){
        if(s1[i]=='A'&&s1[i+1]=='B'&&s1[i+2]=='C'){
            x++;
        }
    }
    cout<<x<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i,k,x;
string s;

int main()
{
    cin>>n>>a>>b;
    k=b-a;
    int ar[n]={};
    for(i=0;i<b;i++){
        cin>>x;
        ar[x-1]++;
    }
    for(i=0;i<n;i++){
        if(ar[i]>k)
            cout<<"Yes";
        else
            cout<<"No";
        cout<<endl;
    }
}



Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
const int MN = 3012;
string s,t;
int dp[MN][MN],bt[MN],ln[MN];
int ds (int i, int j) {
    if (i == -1 or j == -1) return 0;
    if (dp[i][j] != -1) return dp[i][j];
    int res = 0;
    if (s[i] == t[j]) res = max(res, 1+ds(i-1,j-1));
    res = max(res, ds(i-1,j));
    res = max(res, ds(i,j-1));
    return dp[i][j] = res;
}
int main (void) {
    memset(ln,-1,sizeof(ln));
    memset(bt,-1,sizeof(bt));
    memset(dp,-1,sizeof(dp));
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int cur = ds(n-1,m-1);
    int i = n-1, j = m-1;
    string ans;
    while (i >= 0 and j >= 0) {
        if (s[i] == t[j]) {
            ans += s[i];
            --i; --j;
            --cur;
        } else if (dp[i-1][j] == cur) --i;
        else --j;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
}



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

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

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

struct Point {
  int x;
  int y;
  char type;
  Point() {;}
  Point(double x, double y, int type) : x(x), y(y), type(type) {;}
  bool operator<(const Point &rhs) const {
    if (y != rhs.y) { return y < rhs.y; }
    return x < rhs.x;
  }
};

struct Event {
  int x;
  Point p;
  char in;
  Event() {;}
  Event(int x, Point p, int in) : x(x), p(p), in(in) {;}
  bool operator<(const Event &rhs) const {
    if (x != rhs.x) { return x < rhs.x; }
    return in > rhs.in;
  }
};

inline int square(int x) { return x * x; }

inline int dist2(const Point &a, const Point &b) {
  return square(a.x - b.x) + square(a.y - b.y);
}

int an, bn, n;
int r;
Event event[500000];

int PlaneSweep() {
  int ans = 0;
  set<Point> open[2];
  REP(iter, n) {
    Event &e = event[iter];
    Point &p = e.p;
    if (e.in) {
      set<Point>::iterator lower = open[(int)p.type ^ 1].lower_bound(Point(0, p.y - 4 * r - 1, 0));
      set<Point>::iterator upper = open[(int)p.type ^ 1].upper_bound(Point(0, p.y + 4 * r + 1, 0));
      for (set<Point>::iterator it = lower; it != upper; it++) {
        if (dist2(*it, p) <= 16 * r * r) { ans++; }
      }
      open[(int)p.type].insert(p);
    } else {
      open[(int)p.type].erase(open[(int)p.type].find(p));
    }
  }
  return ans;
}

int main() {
  while (scanf("%d %d %d", &an, &bn, &r), an|bn) {
    n = (an + bn) * 2;
    REP(i, an) {
      int x, y;
      scanf("%d %d", &x, &y);
      event[2 * i + 0] = Event(x - 2 * r, Point(x, y, 0), 1);
      event[2 * i + 1] = Event(x + 2 * r, Point(x, y, 0), 0);
    }
    REP(i, bn) {
      int x, y;
      scanf("%d %d", &x, &y);
      event[2 * an + 2 * i + 0] = Event(x - 2 * r, Point(x, y, 1), 1);
      event[2 * an + 2 * i + 1] = Event(x + 2 * r, Point(x, y, 1), 0);
    }
    sort(event, event + n);
    int ans = PlaneSweep();
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 8756
dx = (0,1,0,-1)
dy = (1,0,-1,0)


H, W = map(int, input().split())

S=[input() for i in range(H)]
S_check = [[False]*W for _ in range(H)]

start = (0, 0, 1)
goal = (H-1, W-1)

Q = []
Q.append(start)

step = 0
is_reached = False

while Q:
    current = Q.pop(0)
    step = current[2]
    
    for i in range(4):
        next_pos = (current[0]+dx[i], current[1]+dy[i])

        if next_pos[0] < 0 or next_pos[0] > H-1 or next_pos[1] < 0 or next_pos[1] > W-1:
            continue
        elif S_check[next_pos[0]][ next_pos[1]]:
            continue
        elif next_pos == goal:
            is_reached = True
            break
        elif S[next_pos[0]][ next_pos[1]] == "#":
            continue
        else:
            S_check[next_pos[0]][ next_pos[1]] = True
            Q.append((next_pos[0], next_pos[1], step+1))

    if is_reached:
        break

cnt = 0
for i in range(H):
    for j in range(W):
       if S[i][j] == "#":
           cnt += 1
ans = -1
if is_reached:
    ans = H * W - step -1 - cnt
print(ans)




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

int N;

int main() {
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)  cin >> A[i];
    sort(A.begin(), A.end());
    
    long long ans = 0;
    if (N % 2) {
        if (A[N / 2] - A[N / 2 - 1] > A[N / 2 + 1] - A[N / 2]) {
            for(int i = 0; i < N / 2; i++) {
                ans += 2 * (A[N / 2 + i + 1] - A[i]);
            }
            ans += A[N / 2] - A[N / 2 + 1];
        } else {
            for(int i = 0; i < N / 2; i++) {
                ans += 2 * (A[N / 2 + i + 1] - A[i]);
            }
            ans += A[N / 2 - 1] - A[N / 2];
        }
    } else {    //Nが偶数のとき
        for (int i = 0; i + 1 < N / 2; i++) {
            ans += 2 * (A[N / 2 + i + 1] - A[i]);
        }
        ans += A[N / 2] - A[N / 2 - 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r\
:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p==NIL) printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", "); 
    printf("%d", c);
  }
  printf("]\n");

}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l!=NIL) calcDepth(T[u].l,p+1);
  if(T[u].r!=NIL) calcDepth(T[u].r,p);
}
int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)    
    scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);

  return 0;
}
    
    

    


Measured memory_bytes: 3340
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
#define int ll
/*
問題文

高橋王国には N個の町があります。町は 1 から Nまで番号が振られています。

それぞれの町にはテレポーターが 1
台ずつ設置されています。町 i(1≤i≤N) のテレポーターの転送先は町 Aiです。

高橋王は正の整数 Kが好きです。わがままな高橋王は、町 1 から出発してテレポーターをちょうど K回使うと、どの町に到着するかが知りたいです。

高橋王のために、これを求めるプログラムを作成してください。
*/
signed main() {
    int N, K; cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a; --a;
        A[i] = a;
    }

    int logK = 1;
    while ((1LL << logK) < K) logK++;

    vector<vector<int>> doubling(N, vector<int>(logK));

    for (int i = 0; i < N; i++) {
        doubling[i][0] = A[i];
    }

    for (int k = 1; k < logK; k++) {
        for (int i = 0; i < N; i++) {
            doubling[i][k] = doubling[doubling[i][k - 1]][k - 1];
        }
    }

    int now = 0;
    for (int k = 0; K > 0; k++) {
        //Note that the for loop above uses both k and K
        if (K & 1) {
            now = doubling[now][k];
        }

        K = K >> 1;
        /*シフト演算の考え方
        0b0010111011
        これを右にずらすのが>>で
        左にずらすのが<<である
        */
    }

    cout << now + 1 << endl;
}

Measured memory_bytes: 106340
def solve():
    N = int(input())
    A = [0] + list(map(int, input().split())) + [0]
    
    sum_cost = 0
    for i in range(1, N + 2):
        sum_cost += abs(A[i - 1] - A[i])
    
    for i in range(1, N + 1):
        ans = sum_cost - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1])
        print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14048
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define mp make_pair
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
using namespace std;
ll mod = 1000000007;
ll INF = 1000000000000000000;
ll n, k;
ll a[101];
bool dp[100001][2];
bool vis[100001][2];

bool foo(ll sum, ll cnt)
{


	if (vis[sum][cnt]) return dp[sum][cnt];

	bool res = false;

	for (int i = 0; i < n; i++)
	{
		if (sum + a[i] <= k)
			res |= !foo(sum + a[i], (cnt + 1) % 2 );
	}

	vis[sum][cnt] = true;
	dp[sum][cnt] = res;
	return res;
}

void solve(int t)
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	memset(vis, false, sizeof(vis));
	if (foo(0, 0))
	{
		cout << "First" << endl;
		return;
	}
	cout << "Second" << endl;


}

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




	int t = 1;
	//cin >> t;

	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

long long p = 1000000007;

typedef struct {
    int factor[100000];
    int index[100000];
} factors_t;

long long fac_dp[1000000] = {1, 1};

long long powp(long long a, long long b) {
    if (b == 0)
        return 1ll;
    else if (b == 1)
        return a % p;
    else if (b % 2 == 0) {
        long long t = powp(a, b/2);
        return t * t % p;
    } else {
        long long t = powp(a, b/2);
        return t * t % p * a % p;
    }
}

long long inv(long long n) {
    return powp(n, p-2) % p;
}

long long fac(long long n) {
    if (fac_dp[n] != 0) {
        return fac_dp[n];
    } else {
        for (long long i = 2; i <= n; i++) {
            if (fac_dp[i] == 0) {
                fac_dp[i] = i * fac_dp[i-1] % p;
            }
        }
        return fac_dp[n];
    }
}

long long nCr(long long n, long long r) {
    return fac(n) * inv(fac(r)) % p * inv(fac(n-r)) % p;
}

void init_factors(factors_t *f) {
    for (int i = 100000; i--;) {
        f->factor[i] = 0;
        f->index[i] = 0;
    }
}

void add_factor(factors_t *f, int a) {
    for (int i = 0; i < 100000; i++) {
        if (f->factor[i] == a) {
            f->index[i]++;
            return;
        }
        if (f->factor[i] == 0) {
            f->factor[i] = a;
            f->index[i] = 1;
            return;
        }
    }
}

void factorize(factors_t *f, int m) {
    
    init_factors(f);
    
    int limit = (int)sqrt(m);
    
    while (m > 1 && m % 2 == 0) {
        m /= 2;
        add_factor(f, 2);
    }
    for (int i = 3; i <= limit; i += 2) {
        while (m > 1 && m % i == 0) {
            m /= i;
            add_factor(f, i);
        }
        if (m <= 1) return;
    }
    
    if (m > 1) add_factor(f, m);
    
}

int main() {
    
    int N, M;
    factors_t a;
    
    cin >> N >> M;
    factorize(&a, M);
    
    long long ans = 1ll;
    for (int i = 0; a.factor[i] != 0; i++) {
        int r = a.index[i];
        ans *= nCr(r+N-1, N-1);
        ans %= p;
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 1792
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int n, d, x;
	cin >> n >> d >> x;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	int ans = x;

	for(int i = 0; i < n; i++){
		ans += ceil((ld)d / (ld)a[i]);
	}

	cout << ans << endl;


}



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

long long permutation(int N){
    if (N==1){
        return 1;
    }else{
        return N * permutation(N-1) % 1000000007;
    }
}

int main()
{
    // 整数の入力
    long long total,N,M;
    cin >> N >> M;
    if (abs(N - M) > 1){
        cout << 0 << endl;
    }else if(N == M){
        cout << (2 * permutation(N)* permutation(M)) % 1000000007<< endl;
    }else{
        cout << (permutation(N)* permutation(M)) % 1000000007<< endl;
    }
    return 0;
}

Measured memory_bytes: 1792
while line = gets
  n,x = line.split(" ").map { | val | val.to_i}
  break if 0 == n && 0 == x

  cnt = 0
  ave = x/3
  for i in (1..ave-1 )    
    ave2 = (x-i) / 2
    for j in (i+1..ave2 )
      k = x-i-j
      if j < k && k<= n
        cnt += 1
      end
    end
  end

 puts ( cnt )
 end

Measured memory_bytes: 8712
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n,ans=0;
	string s;

	cin >> n;

	if (n >= 500)
	{
		ans += (n / 500)*1000;
		n %= 500;
	}
	if (n >= 5)
	{
		ans += (n / 5) * 5;
		n %= 5;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []
for i in range(M):
    b, c = map(int, input().split())
    D.append((b, c))
A = sorted(A)
D = sorted(D, key=lambda x: x[1], reverse=True)

i = 0
for j in range(M):
    p, q = D[j]
    while p > 0:
        if i < N and q > A[i]:
            A[i] = q
            i += 1
        else:
            break
        p -= 1
print(sum(A))

Measured memory_bytes: 23260
#include<bits/stdc++.h>
  
   using namespace std;
   
   int main()
   {
       string str;
      int kount = 0; 
      
     getline(cin, str);
      
     for(int i = 0; i < str.size(); i++){
          if(str[i] == '1') kount++;
      }
    
      cout << kount << "\n"; 
  
    
      return 0;
  }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,r) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define lower(a,x) lower_bound(all(a), x) - a.begin();
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x);
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x);
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end());
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll a[MAX*2];
int main(void) {
  ll le, ri;
  SET st;
  cin >> n;
  FOR(i, 1, n + 1) {
	cin >> tmp;
	a[tmp] = i;
  }

  st.insert(0);
  st.insert(n+1);
  FOR(i, 1, n + 1) {
	auto it = st.lower_bound(a[i]);
	ri = *it - a[i];
	it--;
	le = a[i] - *it;

	ans += le * ri*i;
	st.insert(a[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11136