akhauriyash/Code-Regression huggingface dataset:
program main
  implicit none
  integer :: n, a(100)
  integer :: cons(100)
  read(*, *) n
  read(*, *) a(1:n)
  cons = consecutives(n, a(1:n))
  cons(:) = cons(:) / 2
  write(*, "(i0)") sum(cons)
  contains
  function consecutives(n, a)
    implicit none
    integer, intent(in) :: n, a(n)
    integer :: consecutives(100)
    integer :: i, j, last
    consecutives(:) = 0
    last = 9999999
    j = 0
    do i = 1, n
      if (a(i) /= last) then
        last = a(i)
        j = j + 1
      end if
      consecutives(j) = consecutives(j) + 1
    end do
  end function consecutives
end program main


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

int main(){
  string s, ans="No";
  cin >> s;

  if(s[0]==s[1]){
    if(s[2]==s[3]&&s[0]!=s[2]){
      ans="Yes";
    }
  }
  else{
    if(s[1]==s[2]){
      if(s[0]==s[3]&&s[1]!=s[0]){
        ans="Yes";
      }
    }
    else{
      if(s[0]==s[2]){
        if(s[1]==s[3]&&s[0]!=s[1]){
          ans="Yes";
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>

int main(void) {
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  if (n*a < b) {
    printf("%d",n*a);
  } else {
    printf("%d",b);
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.PriorityQueue;
class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        int[] l = new int[n];
        int[] r = new int[n];
        for(int i = 0;i < n;i++) {
            l[i] = stdIn.nextInt();
            r[i] = stdIn.nextInt();
        }
        int count = 0;
        for(int i = 0;i < n;i++){
            count += (r[i] - l[i] + 1);
        }
        System.out.println(count);
        
    }

}

Measured memory_bytes: 24908
#include <stdio.h>

int main(void)
{
	int n, m, l, a[100][100], b[100][100];
	long long c[100][100] = {0};
	int i, j, k;
	
	scanf("%d %d %d", &n, &m, &l);
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) {
			scanf("%d", &b[i][j]);
		}
	}
	
	for (i = 0; i < n; i++){
		for (j = 0; j < m; j++) {
			for (k = 0; k < l; k++) {
				c[i][k] += a[i][j] * b[j][k];
			}
		}
	}
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			if (j < l - 1) {
				printf("%lld ", c[i][j]);
			} else {
				printf("%lld\n", c[i][j]);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    string s;   cin >> s;
    ll res=0;
    rep(i, s.size()){
        res += (s[i]-'0');
    }
    if(res%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3688
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
static const double PI=acos(-1.0);

int main(){
    double a,b,x;
    cin>>a>>b>>x;

    x/=a;
    double ans;
    if(x>a*b/2) ans=atan(2*(a*b-x)/(a*a));
    else ans=atan(b*b/(2*x));
    ans=ans*180/PI;
    
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 4028
#include <iostream>

using namespace std;

int main()
{
    int h, w;
    char map[100][100];

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> map[i][j];
        }
    }


    for (int i = 0; i < h; i++) {
        for(int k = 0; k < 2; k++) {
            for(int j = 0; j < w; j++) {
                cout << map[i][j];
            }
            cout << endl;
        }
    }

   
    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, x;
	char buf[100];

	for (i = 1; ; i++) {
		gets(buf);
		x = atoi(buf);
		if (x == 0) break;
		printf("Case %d: %d\n", i, x);
	}
	return 0;
}

Measured memory_bytes: 524
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

    static class Pair {
        int left;
        int right;
        Pair(int l, int r) {
            left = l;
            right = r;
        }
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int m = std.nextInt();
        int[] from = new int[m];
        int[] to = new int[m];
        for (int i = 0; i < m; i++) {
            from[i] = std.nextInt() - 1;
            to[i] = std.nextInt() - 1;
        }

        int[][] dp = new int[1000010][3];
        for (int i = 0; i < dp.length; i++) {
            Arrays.fill(dp[i], -1);
        }

        int start = std.nextInt() - 1;
        int end = std.nextInt() - 1;
        List<List<Integer>> edgeTo = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            edgeTo.add(new ArrayList<>());
        }

        for (int i = 0; i < m; i++) {
            int v = from[i];
            edgeTo.get(v).add(to[i]);
        }

        dp[start][0] = 0;
        Deque<Pair> deque = new ArrayDeque<>();
        deque.add(new Pair(start, 0));
        while (!deque.isEmpty()) {
            int v = deque.peekFirst().left;
            int l = deque.peekFirst().right;
            deque.pop();

            List<Integer> tos = edgeTo.get(v);
            for (int i = 0; i < tos.size(); i++) {
                int nv = tos.get(i);
                int nl = (l + 1) % 3;
                if (dp[nv][nl] != -1) {
                    continue;
                }
                int cost = dp[v][l] + 1;
                dp[nv][nl] = cost;
                deque.add(new Pair(nv, nl));
            }
        }

        if (dp[end][0] % 3 == 0) {
            int count = dp[end][0] / 3;
            System.out.println(count);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 141660
import java.util.*;

public class Main {
    static int MOD = 1000000007;
	static int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        long res = lcm(a, b);
        
        System.out.println(res);
    }
    // GCD
    public static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    // LCM
    public static long lcm(int a, int b) {
		int d = gcd(a, b);
        return (long)a / d * b;
    }
}

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

using namespace std;

int H, W;

int main(){
  cin >> H >> W;
  
  vector<vector<char>> P(H,vector<char> (W,'x'));
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> P[i][j];
    }
  }
  
  for(int i = 0; i < 2 * H; i++){
    for(int j = 0; j < W; j++){
      cout << P[(i)/2][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
import math
d,g=map(int,input().split())
pc=[list(map(int,input().split())) for i in range(d)]
ans=10000000000000000000
for i in range(1<<d):
    s=0
    ans_=0
    for j in range(d):
        if (i>>j)&1:
            s+=(pc[j][1]+pc[j][0]*100*(j+1))
            ans_+=pc[j][0]
    #print(s,ans_)
    if s>=g:
        ans=min(ans,ans_)
    else:
        for j in range(d-1,-1,-1):
            if not((i>>j)&1):
                if s+(pc[j][0]*100*(j+1))>=g:
                    h=-((s-g)//(100*(j+1)))
                    s+=(h*100*(j+1))
                    ans_+=h
                    ans=min(ans,ans_)
                    break
                else:
                    break
print(ans)
#ansとans_
#謎のWA

Measured memory_bytes: 40944
#include<cstdio>
#include<algorithm>
#include<functional>
#include<queue>
#include<cstring>

using namespace std;

class data{
public:
	int x,y,c,w;
	bool operator<(const data &d)const{
		return d.c<c;
	}
};

int w,h;
int fie[31][31];
int dp[31][31][4];
int c[5];
int sx[4]={1,0,-1,0};
int sy[4]={0,1,0,-1};
int dijk(){
	priority_queue<data> que;
	data ind;
	memset(dp,-1,sizeof(dp));
	ind.x=0,ind.y=0,ind.c=0,ind.w=0;
	que.push(ind);
	while(que.size()){
		data d=que.top();
		que.pop();
		if(dp[d.x][d.y][d.w]!=-1 && dp[d.x][d.y][d.w]<d.c)continue;
		if(d.x==w-1 && d.y==h-1)return d.c;
		dp[d.x][d.y][d.w]=d.c;
		for(int i=0;i<4;i++){
			data nd=d;
			if(fie[d.x][d.y]!=i)nd.c+=c[i];
			nd.w=(nd.w+i)%4;
			nd.x+=sx[nd.w];
			nd.y+=sy[nd.w];
			if(nd.x>=0 && nd.x<w && nd.y>=0 && nd.y<h){
				if(dp[nd.x][nd.y][nd.w]>nd.c || dp[nd.x][nd.y][nd.w]==-1){
					dp[nd.x][nd.y][nd.w]=nd.c;
					que.push(nd);
				}
			}
		}
	}
	return -1;
}

int main(void){
	while(1){
		scanf("%d %d",&w,&h);
		if(w+h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				scanf("%d",&fie[j][i]);
			}
		}
		for(int i=0;i<4;i++){
			scanf("%d",&c[i]);
		}
		printf("%d\n",dijk());
	}
	return 0;
}

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

ll modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

ll choose(ll n, ll r, ll mod){
    ll mul = 1, div = 1;
    for(ll i = 0; i < r; i++){
        mul *= n - i;
        div *= i + 1;
        mul %= mod;
        div %= mod;
    }   
    return mul * modPow(div, mod - 2, mod) % mod;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;

    ll kit = 10e8 + 7;

    ll ans = modPow(2, n, kit);
    ans--;
    ans -= choose(n, a, kit);
    ans -= choose(n, b, kit);
    ans %= kit;
    if (ans < 0){
        ans += kit;
    }

    cout << ans << endl;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S=in<string>();
    
    string T=in<string>();
    string ans;ans=T+S;
    print(ans);
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<math.h>

int main()
{
	int A[9];
	int B[9];
	int r;
	
	for(r=0; r<3; r++){
		scanf("%d %d %d", &A[r], &A[r+3], &A[r+6]);
		B[r] = 0;
		B[r+3] = 0;
		B[r+6] = 0;
	}
	
	int N;
	scanf("%d", &N);
	
	int Z[N];
	int s;
	for(r=0; r<N; r++){
		scanf("%d", &Z[r]);
		for(s=0; s<9; s++){
			if(A[s] == Z[r]) B[s]++;
			}
	}
	
	s = 0;
	
	for(r=0; r<3; r++){
		if(B[r] == 1 && B[r+3] == 1 && B[r+6]){
			printf("Yes");
			s = 1;
			break;
		}
		
		else if(B[3*r] == 1 && B[3*r+1] ==1 && B[3*r+2]==1){
			printf("Yes");
			s = 1;
			break;
		}
	}
	
	if( s != 1){
		if (B[0] ==1 && B[4] ==1 && B[8] ==1) printf("Yes");
		else if (B[2] ==1 && B[4] ==1 && B[6] ==1) printf("Yes");	
		else printf("No");
	}
	
	return 0;
	
}


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

Measured memory_bytes: 3632
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    s = input()
    print("ARC" if s=="ABC" else "ABC")

if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> vec (100000,0);
    int N;
    cin >> N;
    for(int i = 0;i < N;i++){
        int test;
        cin >> test;
        if(test == 0){
            vec[0]++;
            vec[1]++;
        }
        else if(test == 99999){
            vec[99998]++;
            vec[99999]++;
        }
        else{
            vec[test-1]++;
            vec[test]++;
            vec[test+1]++;
        }
    }
    SORT(vec);
    REV(vec);
    cout << vec[0] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	cout<<max(0LL,a-2*b)<<"\n";
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	ll a[100001];
	bool ana[100001]={};
	ll ans[100001]={};
	scan(N>>M);
	rep(i,M){
		scan(a[i]);
		ana[a[i]]=1;
	}
	ll MOD=1e+9+7;
	ans[0]=1;
	rep1(i,N){
		if(ana[i]==0){
			if(i>1){
				ans[i]+=ans[i-2];
				ans[i]%=MOD;
			}
			ans[i]+=ans[i-1];
			ans[i]%=MOD;
		}
	}
	prin(ans[N]);
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

struct deal { int A, B; } dish[3000];
int dp[3000][3000];

bool comp(deal& a, deal& b) { return a.A < b.A; }

int main()
{
	int N, T, ans = 0;

	cin >> N >> T;
	rep(i, N) cin >> dish[i].A >> dish[i].B;
	sort(dish, dish + N, comp);

	rep(i, N - 1) repc(j, 0, T - 1) {
		if (i == 0) {
			if (dish[i].A <= j) dp[i][j] = dish[i].B;
			else dp[i][j] = 0;
		}
		else if (j == 0) dp[i][j] = 0;
		else if (j - dish[i].A >= 0) {
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - dish[i].A] + dish[i].B);
		}
		else dp[i][j] = dp[i - 1][j];
	}

	rep(i, N - 1) ans = max(ans, dp[i][T - 1] + dish[i + 1].B);

	cout << ans << endl;

	return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

    vector<int> c(n);
    vector<int> s(n);
    vector<int> f(n);

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

    for (int i = 0; i < n-1; ++i) {
        int sum = c[i] + s[i];

        for (int j = i+1; j < n-1; ++j) {
            if (sum <= s[j]) {
                sum = c[j] + s[j];
            } else {
                for (int k = 0; k <= f[j]; ++k) {
                    if ((sum + k) % f[j] == 0) {
                        sum += k + c[j];
                        break;
                    }
                }
            }
        }

        cout << sum << endl;
    }

    cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;


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

    string s,t;
    cin>>s>>t;
    map<string,int> m;
    ll a,b;
    cin>>a>>b;
    m[s]=a;
    m[t]=b;
    string u;
    cin>>u;
    m[u]-=1;
    cout<<m[s]<<" "<<m[t];

    return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#define MAX_N 200000
#define p2 262144
#define inf 100000000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
string s,rs;
int m;
int rank[MAX_N+1];
int tmp[MAX_N+1];
int sa[MAX_N+1],rsa[MAX_N+1];
int segmn[p2*2-1],segmx[p2*2-1];
int n,k;
int minquery(int a,int b,int l,int r,int id,int *seg){
	if(b<=l||r<=a) return inf;
	if(a<=l&&r<=b) return seg[id];
	return min(minquery(a,b,l,(l+r)/2,id*2+1,seg),minquery(a,b,(l+r)/2,r,id*2+2,seg));
}
int maxquery(int a,int b,int l,int r,int id,int *seg){
	if(b<=l||r<=a) return -1;
	if(a<=l&&r<=b) return seg[id];
	return max(maxquery(a,b,l,(l+r)/2,id*2+1,seg),maxquery(a,b,(l+r)/2,r,id*2+2,seg));
}
bool compare_sa(int i,int j){
	if(rank[i]!=rank[j]) return rank[i]<rank[j];
	else {
		int ri=i+k<=n ? rank[i+k] : -1;
		int rj=j+k<=n ? rank[j+k] : -1;
		return ri<rj;
	}
}
void make_sa(string s,int *sa){
	n=s.length();
	for(int i=0;i<=n;i++){
		sa[i]=i;
		rank[i]=i<n?s[i]:-1;
	}
	for(k=1;k<=n;k*=2){
		sort(sa,sa+n+1,compare_sa);
		tmp[sa[0]]=0;
		for(int i=1;i<=n;i++){
			tmp[sa[i]]=tmp[sa[i-1]]+(compare_sa(sa[i-1],sa[i]) ? 1 : 0);
		}
		for(int i=0;i<=n;i++) rank[i]=tmp[i];
	}
}
int low(string s,int *sa,string t){
	int a=0,b=s.length();
	while(b-a>1){
		int c=(a+b)/2;
		if(s.compare(sa[c],t.length(),t)<0) a=c;
		else b=c;
	}
	if(s.compare(sa[b],t.length(),t)==0) return b;
	else return inf;
}
int high(string s,int *sa,string t){
	int a=0,b=s.length()+1;
	while(b-a>1){
		int c=(a+b)/2;
		if(s.compare(sa[c],t.length(),t)>0) b=c;
		else a=c;
	}
	return a;
}
int main(){
	cin>>s>>m;
	n=s.size();
	make_sa(s,sa);
	rep(i,n+1) segmn[p2-1+i]=sa[i],segmx[p2-1+i]=sa[i];
	for(int i=p2-2;i>=0;i--){
		segmn[i]=min(segmn[i*2+1],segmn[i*2+2]);
		segmx[i]=max(segmx[i*2+1],segmx[i*2+2]);
	}
	rep(i,m){
		string x,y;
		cin>>x>>y;
		int l=low(s,sa,x);
		if(l==inf){
			printf("0\n");
			continue;
		}
		int r=high(s,sa,x);
		r++;
		int a=minquery(l,r,0,p2,0,segmn);
		l=low(s,sa,y);
		if(l==inf){
			printf("0\n");
			continue;
		}
		r=high(s,sa,y);
		r++;
		int b=maxquery(l,r,0,p2,0,segmx);
		if(a<=b && a+x.size()<=b+y.size()){
			printf("%d\n",b+y.size()-a);
		}else printf("0\n");
	}
/*	rep(i,s.size()+1){
		cout<<i<<" "<<sa[i]<<endl;
	}*/
/*	while(true){
		string x;
		cin>>x;
		printf("low%d high%d\n",low(s,sa,x),high(s,sa,x));
	}*/
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N, K;
    cin >> N >> K;
    deque<ll> _D;
    REP(i,0,N) {
        ll v;
        cin >> v;
        _D.push_back(v);
    }

    ll m = -INF;
    REP(i,0,K+1) {
        REP(j,0,i+1) {
            REP(k,0,j+1) {
                ll a = i - j, b = j - k, c = k;
                deque<ll> D = _D;
                priority_queue<ll, vec, greater<ll>> Q;
                ll sum = 0;
                REP(l,0,a) {
                    if(D.empty()) break;
                    ll v = D.front();
                    D.pop_front();
                    Q.push(v);
                }
                REP(l,0,b) {
                    if(D.empty()) break;
                    ll v = D.back();
                    D.pop_back();
                    Q.push(v);
                }
                REP(l,0,c) {
                    if(Q.empty()) break;
                    ll v = Q.top();
                    Q.pop();
                }
                while(!Q.empty()) {
                    sum += Q.top();
                    Q.pop();
                }
                m = MAX(m,sum);
            }
        }
    }
    PR(m);



    return 0;
}

/*



*/

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

namespace abc100_c
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var al = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
            var pl = new List<int>();
            int r = 0;

            for (int i = 1; i <= 29; i++)
                pl.Add(int.Parse(Math.Pow(2, double.Parse(i.ToString())).ToString()));

            for(int i = 0; i< al.Count(); i++) 
                for (int j = pl.Count() - 1; j >= 0; j--)
                    if (al[i] % pl[j] == 0)
                    {
                        r += j + 1;
                        break;
                    }

            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 12128
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  w = new Array(n).fill(0);
  var ans = "Yes";
  for(i=0;i<n;i++){
    w[i]=input[i+1];
    if(i>0){
      if(w[i].substr(0,1)!=w[i-1].substr(w[i-1].length-1,1)){
        ans="No";
        break;
      }
    }
    for(j=0;j<i;j++){
      if(w[i]==w[j]){
        ans="No";
        break;
      }
    }
  }


  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn reads<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().split(' ').map(|x| x.parse().unwrap()).collect()
}

fn readln<T>() -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug {
    get_line().parse().unwrap()
}

use std::collections::BinaryHeap;
use std::cmp::Ordering;

#[derive(Clone, Copy, Eq, PartialEq)]
struct E {
    d: u64,
    v: usize,
}

impl Ord for E {
    fn cmp(&self, other: &Self) -> Ordering {
        other.d.cmp(&self.d)
    }
}

impl PartialOrd for E {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    let inf = std::u64::MAX;

    let n = readln();

    let mut es = vec![vec![]; n];

    for _ in 0..(n - 1) {
        let abc: Vec<usize> = reads();
        es[abc[0] - 1].push((abc[1] - 1, abc[2] as u64));
        es[abc[1] - 1].push((abc[0] - 1, abc[2] as u64));
    }

    let qk: Vec<usize> = reads();
    let mut ds = vec![inf; n];
    let mut q = BinaryHeap::new();
    ds[qk[1] - 1] = 0;
    q.push(E{d: 0, v: qk[1] - 1});

    while let Some(e) = q.pop() {
        if e.d > ds[e.v] {
            continue;
        }

        for &(d, w) in &es[e.v] {
            if ds[d] > ds[e.v] + w {
                ds[d] = ds[e.v] + w;
                q.push(E{d: ds[d], v: d});
            }
        }
    }

    for _ in 0..qk[0] {
        let xy: Vec<usize> = reads();

        println!("{}", ds[xy[0] - 1] + ds[xy[1] - 1]);
    }
}


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

double arr[3000];
int z;

double dp[3005][3005][2];

double rekur(int a,int s,int d)
{
	if(a==1)
	{
		double temp=1.00-arr[a];
		if(d==0)return arr[a];
		else return temp;
	}
	if(dp[a][s][d]!=-1.00)
	{
//		cout<<dp[a][s][d]<<" "<<a<<" "<<s<<" "<<d<<endl;
		return dp[a][s][d];
	}
	dp[a][s][d]=0.00;
	double temp=1.00-arr[a];
	
	if(d==0)
	{
		if((s-1)>0)
		dp[a][s][d]+=(arr[a]*(rekur(a-1,s-1,0)));
		if((a-1)>(s-1))
		{
			dp[a][s][d]+=(arr[a]*(rekur(a-1,s-1,1)));
		}
	}
	else
	{
		if(s>0)
		dp[a][s][d]+=(temp*(rekur(a-1,s,0)));
		if((a-1)>s)
		{
			dp[a][s][d]+=(temp*rekur(a-1,s,1));
		}
	}
//	cout<<a<<"    "<<s<<"   "<<d<<"   "<<dp[a][s][d]<<endl;
	return dp[a][s][d];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	for(int q=0;q<=3000;q++)
	{
		for(int w=0;w<=3000;w++)
		for(int e=0;e<2;e++)dp[q][w][e]=-1.00;
	}
	cin>>z;
	for(int q=1;q<=z;q++)cin>>arr[q];
	
	int asd=(z/2)+1;
	double ans=0.00;
	for(int q=asd;q<=z;q++)
	{
		double temp=1.00-arr[z];
		ans+=(rekur(z,q,0));
		if(q!=z)
		ans+=(rekur(z,q,1));
//		cout<<q<<" asdasdasd    "<<ans<<endl;
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
}


//5
//0.42 0.01 0.42 0.99 0.42
//3    1   0   0
//2    1   0   0.0058
//2    1   1   0.4158
//3    1   1   0.244528
//4    2   0   0.242083
//3    2   0   0.177072
//2    2   0   0.0042
//3    2   1   0.002436
//4    2   1   0.00179508
//5    3   0   0.102429
//4    3   0   0.177713
//3    3   0   0.001764
//4    3   1   1.764e-005
//5    3   1   0.103084
//5    4   0   0.0746468
//4    4   0   0.00174636
//5    4   1   0.00101289
//5    5   0   0.000733471
//0.2819055960
//
//
//
//
//5
//0.42 0.01 0.42 0.99 0.42
//2    0   1   0.5742
//3    1   0   0.241164
//2    1   0   0.0058
//2    1   1   0.4158
//3    1   1   0.244528
//4    2   0   0.480835
//2    1   0   0.0058
//2    1   1   0.4158
//3    2   0   0.177072
//2    2   0   0.0042
//3    2   1   0.002436
//4    2   1   0.00179508
//5    3   0   0.202705
//2    1   0   0.0058
//2    1   1   0.4158
//3    2   0   0.177072
//2    2   0   0.0042
//3    2   1   0.002436
//4    3   0   0.177713
//2    2   0   0.0042
//3    3   0   0.001764
//4    3   1   1.764e-005
//5    3   1   0.103084
//2    1   0   0.0058
//2    1   1   0.4158
//3    2   0   0.177072
//2    2   0   0.0042
//3    2   1   0.002436
//4    3   0   0.177713
//2    2   0   0.0042
//3    3   0   0.001764
//4    3   1   1.764e-005
//5    4   0   0.0746468
//2    2   0   0.0042
//3    3   0   0.001764
//4    4   0   0.00174636
//5    4   1   0.00101289
//2    2   0   0.0042
//3    3   0   0.001764
//4    4   0   0.00174636
//5    5   0   0.000733471
//0.3821815872


Measured memory_bytes: 141568
#include <iostream>

using namespace std;

int ipow(int i, int j){
    if(i==1)return 1;
    if(j==1)return i;
    return i*ipow(i, j-1);
}

int main(){
    int X, t, max = 1;
    cin >> X;
    for(int i=1;i<=31;i++){
        for(int j=2;j<=10;j++){
            if(X<ipow(i,j))break;
            t = ipow(i,j);
            if(t>max)max = t;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
	int num;
	int i;
	int temp;
	int *data;
	int *rev;
	
	scanf("%d", &num);
	data = (int*)malloc(sizeof(int) * num);
	rev = (int*)malloc(sizeof(int) * num);

	for(i=0; i<num; i++){
		scanf("%d", &data[i]);		
		rev[num - 1 - i] = data[i];
	}
	
	for(i=0; i<num; i++){
		if(i>0){
			printf(" ");
		}

		printf("%d", rev[i]);
	}
	printf("\n");

	free(data);
	free(rev);

	return 0;

}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 

const int D=60;
int basis[D];
void add(int x){
    for(int i=0;i<D;i++){
        if(x&(1ll<<i)){
            if(basis[i]==0) {basis[i]=x; return;}
            x^=basis[i];
        }
    }
}
int can(int x){
    for(int i=0;i<D;i++){
        if((x & (1ll<<i))&&basis[i]) x^=basis[i];
    }
    return x;
}
int solve(){

    memset(basis,0,sizeof(basis));
    int n;cin>>n;
    int a[n];
    inputarr(a,n);
    string s;cin>>s;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='0') add(a[i]);
        else{
            if(can(a[i])){
                // trace(can(a[i]),i);
                return cout<<1<<endl,0;
            }
        }
    }
    cout<<0<<endl;


    return 0;
}
signed main(){
    asdf
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main(){
  string s;
  cin>>s;
  vector<string> t={"Sunny","Cloudy","Rainy","Sunny"};
  for(int i=0;i<3;i++){
    if(t[i] == s) {
      cout << t[i+1] << endl;
      break;
    }
  }
}

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

long attack(long h);

int main(void)
{
  long h;
  cin >> h;
  long dig = 1;
  while (h != 1)
  {
    h = h >> 1;
    dig = 2 * dig + 1;
  }
  cout << dig << endl;
  return 0;
}

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

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

using ll = long long int;
using P = pair<int,int>;

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; }

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

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
}



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

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2253&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
int n,t;
map<pii,int> mp;
set<pii> s;

int dx[6] = {1,1,0,-1,-1,0};
int dy[6] = {0,1,1,0,-1,-1};
int solve(){
    mp.clear(); s.clear();
    int res = 0;
    for(int i = 0; i < n;i++){
        int x,y; cin >> x >> y;
        s.insert(make_pair(x,y));
    }
    int x,y; cin >> x >> y;
    using piii = pair<pii,int>;
    queue<piii> q; q.push({{x,y},1});
//    mp[make_pair(x,y)] = 1;
    while(q.size()){
        int T,X,Y; auto P = q.front(); q.pop();
        T = P.second; tie(X,Y) = P.first;
        if(mp[{X,Y}] == 0 || mp[{X,Y}] > T){
            mp[{X,Y}] = T;
        }else{
            continue;
        }
        if(T > t) continue;
        for(int k = 0; k < 6;k++){
            int nX = X + dx[k],nY = Y + dy[k];
            if(s.find({nX,nY}) != s.end()) continue;
            q.push({{nX,nY},T+1});
        }
    }
    res = (int)mp.size();
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> t >> n,t){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3236
#include<stdio.h>

int main (void){
    char str[21] = "";
    int i = 0;

    scanf("%s",str);

    while(1){

        if(str[i] == NULL)
            break;
            i++;
    }

    while(1){

        i--;
        printf("%c",str[i]);
        if(i == 0){
            printf("\n");
            break;
        }
    }

    return 0;
}

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

using namespace std;

#define int long long

int32_t main() {
    ios::sync_with_stdio(false);

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

    int n, answ = 0;
    cin >> n;

    int a[n], u[n+5] = {0}, l = 2;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n, greater<int>());
    u[1] = a[0];

    for(int i = 1; i < n; i++) {
        if(l >= n)
            break;
        u[l] = u[l+1] = a[i], l += 2;
    }

    for(int i = 0; i < n; i++)
        answ += u[i];

    cout << answ;

    return 0;
}


Measured memory_bytes: 6808
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }





void solve(void)
{
  int H,W;cin>>H>>W;
  vector<vector<char> > vv (H+2,vector<char>(W+2,'#'));
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin>>vv[i+1][j+1];
    }
  }

  for (int i = 0; i < H+2; i++)
  {
    for (int j = 0; j < W+2; j++)
    {
      cout<<vv[i][j];
    }
    cout<<endl;
  }
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define br              "\n"
#define sp              " "
#define debug(x)        cout << #x << " : " << x << endl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;


// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

inline ll add(ll a, ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a, ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a, ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x, ll n) {
	x = x % mod;
	if (!n) return 1;
	if (n & 1) return mul(x, pwr(mul(x, x), (n - 1) / 2));
	else return pwr(mul(x, x), n / 2);
}
// O(nlogn) for [1,n]
ll modinv(ll n) {
	return pwr(n, mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i) {
	if (i == 1) return 1;
	return (MOD - (MOD / i) * inv(MOD % i) % MOD) % MOD;
}
// =============================



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

	vector<bool> dp(k + 1, false);

	for (int index = 1; index <= k; index++)
	{
		for (int i = 0; i < n; i++)
		{
			if ((index - a[i]) >= 0 && dp[index - a[i]] == false)
			{
				dp[index] = true;
				break;
			}
		}
	}

	if (dp[k])
		cout << "First";
	else
		cout << "Second";

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t;

	solve();


	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
struct Edge {
    int to,next,val;
    Edge(){}
    Edge(int to,int next,int val):to(to),next(next),val(val){}
    bool operator < (const Edge& rhs)const{
        return val>rhs.val;
    }
}edge[N*2];
int tot,head[N];
void addEdge(int from,int to,int val) {
    edge[tot].next=head[from];
    edge[tot].to=to;
    edge[tot].val=val;
    head[from]=tot++;
}
bool vis[N];
int dis[N];
int SPFA(int s,int e) {
    memset(vis,false,sizeof(vis));
    memset(dis,INF,sizeof(dis));
    dis[s]=0;

    priority_queue<Edge> Q;
    Q.push(Edge(s,0,0));
    while (!Q.empty()) {
        Edge temp=Q.top();
        Q.pop();
        if(vis[temp.to])
            continue;
        vis[temp.to]=true;

        for(int i=head[temp.to]; i!=-1; i=edge[i].next) {
            if(dis[edge[i].to]>dis[temp.to]+edge[i].val) {
                dis[edge[i].to]=dis[temp.to]+edge[i].val;
                Q.push(Edge(edge[i].to,0,dis[edge[i].to]));
            }
        }
    }
    if(dis[e]!=INF)
        return dis[e]/2;
    return -1;
}
map<int,int> mp[N];
int allPoint;
int getPoint(int x,int y) {
    if (!mp[x][y])
        mp[x][y]=++allPoint;
    return mp[x][y];
}
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    allPoint=n;
    for (int i=1; i<=m; i++) {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);

        int newX=getPoint(x,w);
        int newY=getPoint(y,w);

        addEdge(x,newX,1);
        addEdge(newX,x,1);
        addEdge(newX,newY,0);
        addEdge(newY,newX,0);
        addEdge(y,newY,1);
        addEdge(newY,y,1);
    }
    int res=SPFA(1,n);
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 94324
import sys
import numpy as np
input = sys.stdin.readline

_n = int(input())
_alist = list(map(int, input().split()))
_blist = list(map(int, input().split()))


def chker(n, A, B):
    ba = list(zip(B, A))
    ba.sort()
    ba = np.array(ba)
    A, B = ba[:, 1], ba[:, 0]
    Ap = np.array(sorted([(a, index) for index, a in enumerate(A)]))

    for a, b in zip(Ap[:, 0], B):
        if a > b:
            print('No')
            return

    stt, cnt = 0, 0
    Apc, index = Ap[:, 1], stt
    while True:
        if Apc[index] == stt:
            if cnt < n - 1:
                print('Yes')
                return
            else:
                break
        else:
            cnt += 1
            index = Apc[index]

    for a, b in zip(Ap[1:, 0], B[:-1]):
        if a <= b:
            print('Yes')
            return

    print('No')


chker(_n, _alist, _blist)


Measured memory_bytes: 37596
#include <stdio.h>
#include <string.h>
void swap(char* a, char* b){
	char tmp[101];
	strcpy(tmp,a);
	strcpy(a,b);
	strcpy(b,tmp);
}
int main(void){
	int n,l,i;
	scanf("%d%d",&n,&l);
	char s[100][101];
	for(i=0;i<n;i++)scanf("%s",s[i]);
	for(i=0;i<n;i++){
		for(int j=0;j<i;j++){
			if(strcmp(s[i],s[j])<0)swap(s[i],s[j]);
		}
	}
	
	for(i=0;i<n;i++)printf("%s",s[i]);
	return 0;
}

Measured memory_bytes: 128
from itertools import product
n = int(input())
if n%2 == 0:
  print(n,n,n//2)
else:
  for h,l in product(range(max(2, n//4),3501),repeat=2):
    m = n*h*l
    c = 4*h*l - n*(h+l)
    if c > 0 and m%c == 0:
      w = m//c
      break
  print(h,l,w)

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

int main() {
    int n, k;
    cin >> n >> k;
    set<int> snukes;
    while (n>0) {
        snukes.insert(n--);
    }
    for (int i=0; i<k; i++) {
        int d;
        cin >> d;
        while (d--) {
            int snuke;
            cin >> snuke;
            snukes.erase(snuke);
        }
    }
    cout << snukes.size() << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N; cin >> N;
  vector<string> S(N); rep(i, N) cin >> S.at(i);
  sort(all(S));
  map<string, int> aaaa;
  int maxnum = 0;
  vector<string> name(0);
  rep(i, N){
    aaaa[S.at(i)]++;
    if(aaaa[S.at(i)] == 1){
      name.push_back(S.at(i));
    }
    maxnum = max(maxnum, aaaa[S.at(i)]);
  }
  rep(i, name.size()){
    if(aaaa[name.at(i)] == maxnum){
      cout << name.at(i) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 28272
#include<bits/stdc++.h>
using namespace std;
int f[300009];
main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++)
    {
        if(i < s.size()-1 && s[i] == '#' && s[i+1] =='#') f[i+1] = f[i]+1;
        else f[i+1] = f[i];

    }
    int fl = 0;
    for(int i = b-2; i < min(c,d)-1; i++){
        if(i < s.size()-2 && s[i] == '.' && s[i+1]=='.' && s[i+2] == '.')
            fl = 1;
    }
    if(c> d && !fl) cout<<"No"; else
    if(f[b] == f[a-1] && f[d] ==f[c-1]) cout<<"Yes";
    else cout<<"No";

}


Measured memory_bytes: 1284
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;


int main()
{
	int n, l;
	cin >> n >> l;
	int sum = 0;
	int mi = 30000;
	for (int i = 1; i <= n; ++i) {
		sum += l + i - 1;
		if (abs(l + i - 1) < abs(mi)) {
			mi = l + i - 1;
		}
	}
	cout << sum - mi << endl;

	return 0;
}


Measured memory_bytes: 256