akhauriyash/Code-Regression huggingface dataset:
MOD = 10**9 + 7
N = int(input())
arr = list(map(int, input().split()))
check = [0]*N
check[0] = arr[0]
check2 = [sum(arr)]*N
ans = 0
for i in range(N-1):
    check[i+1] = check[i]+arr[i+1]
for i in range(N):
    check2[i] -= check[i]
for i in range(N-1):
    ans += check2[i]*arr[i]
    ans %= MOD
print(ans)

Measured memory_bytes: 105124
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<int> x(n),y(n);
    fr(i,n) in>>x[i]>>y[i];
    double d{};
    fr(i,n) fr(j,i){
        d+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
    d/=(double)n/2;
    cout<<setprecision(12)<<d<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n; cin>>n;
  vector<ll> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
    a[i]-=b[i];
  }
  vector<ll> plus;
  ll minus=0,ans=0;
  for(int i=0;i<n;i++){
    if(a[i]>0){
      plus.push_back(a[i]);
    }else if(a[i]<0){
      minus-=a[i];
      ans++;
    }
  }
  sort(plus.rbegin(),plus.rend());
  for(int i=0;i<plus.size();i++){
    if(minus>plus[i]){
      minus-=plus[i];
      ans++;
    }else{
      if(minus!=0) ans++;
      cout<<ans<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}





void _main() {
        int x, a, b; cin >> x >> a >> b;
        if (abs(x - a) < abs(x - b)) cout << "A";
        else cout << "B";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

int main(){
  int m,f,r;
  do{
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1)
      ;
    else if(m == -1 || f == -1)
      cout << 'F' << endl;
    else if(m+f >= 80)
      cout << 'A' << endl;
    else if(m+f >= 65)
      cout << 'B' << endl;
    else if(m+f >= 50)
      cout << 'C' << endl;
    else if(m+f >= 30)
      r >= 50 ? cout << 'C' << endl : cout << 'D' << endl;
    else if(m+f >= 0)
      cout << 'F' << endl;
  }while(!(m == -1 && f == -1 && r == -1));
}



Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;

int main() {

	string n;
	cin >> n;

	string ans = "ABC";
	ans = ans + n;
	cout << ans << endl;

	
	return 0;
	
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<ll,ll>
#define pb push_back
#define mk make_pair
using namespace std;
const ll INF = 1e10;
 
#define MAX_V 1000
 
struct edge {
    int to;
    ll cost;
};
 
 
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];
////////////////////////////////////////////////////////
int m,n;
int b[510],r[510];
vector<int> g[1010];
bool v[1010];
int f[1010];
 
bool dfs(int t){
  v[t] = true;
  for(int i=0;i<(int)g[t].size();i++){
    int u = g[t][i], o = f[u];
    if(o<0 || !v[o] && dfs(o)){
      f[t] = u;
      f[u] = t;
      return true;
    }
  }
  return false;
}
 
int bi_matching(void){
  int res = 0;
  memset(f,-1,sizeof(f));
  for(int i=0;i<m+n;i++){
    if(f[i] < 0){
      memset(v,0,sizeof(v));
      if(dfs(i))res++;
    }
  }
  return res;
}
 

 
int main() {
  int num;
  cin >> num;
  vector <P> a;
  vector <P> c;
  REP(i,num){
    P p;
    cin >> p.first >> p.second;
    a.pb(p);
  }
  REP(i,num){
    P p;
    cin >> p.first >> p.second;
    c.pb(p);
  }
  n = num;
  m = n;

  REP(i,num){
    REP(j,num){
      if(a[i].first < c[j].first && a[i].second < c[j].second){
	g[i].pb(n+j);
	g[n+j].pb(i);
      }
    }
  }
  cout << bi_matching() << endl;
}


Measured memory_bytes: 384
while (h,w=gets.split.map(&:to_i)) != [0,0] do
 (1..h).each {|x| 
  (1..w).each {|y|
  print (x % 2 != 0 && y % 2 != 0) || (x % 2 == 0 && y % 2 == 0) ? "#" : "." 
  }
  puts()
 }
 puts()
end

Measured memory_bytes: 8740
#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);

	ll n,m,k;
	cin>>n>>m>>k;
	string s[n];
	for(ll i=0;i<n;++i){cin>>s[i];}

	ll ans=n+m;

	for(ll mask=0;mask<(1<<(n-1));++mask)
    {
        ll cost=0;
        vector<ll> idx;
        idx.pb(0);
        for(ll i=0;i<n-1;++i)
        {
            if((mask&(1<<i))!=0){
                idx.pb(i+1);++cost;
            }
        }
        ll ch[idx.size()]={0};
        ll index=0;
        int ff=1;
        for(ll j=0;j<m;++j)
        {
            index=-1;
            for(ll i=0;i<n;++i)
            {
                if(i==idx[index+1]){++index;}
                ch[index]+=(s[i][j]-'0');
            }
            int f=1;
            for(ll i=0;i<idx.size();++i){
                if(ch[i]>k){f=0;}
            }
            if(f){

            }
            else{
                ++cost;
                for(ll i=0;i<idx.size();++i){ch[i]=0;}
                index=-1;
                for(ll i=0;i<n;++i){
                    if(i==idx[index+1]){++index;}
                    ch[index]+=(s[i][j]-'0');
                }
                for(ll i=0;i<idx.size();++i){
                    if(ch[i]>k){ff=0;break;}
                }
            }
            if(ff==0){cost=INT_MAX;break;}
        }
        ans=min(ans,cost);
    }
    cout<<ans<<endl;

	return(0);
}


Measured memory_bytes: 256
#include <stdio.h>

int getMinNum(int *A, int N){
  int min = A[0];
  for(int i=0;i<N;i++){
    if(min > A[i]) min = A[i];
  }
  return min;
}

int getMaxNum(int *A, int N){
  int max = A[0];
  for(int i=0;i<N;i++){
    if(max < A[i]) max = A[i];
  }
  return max;
}

long getArraySum(int *A, int N){
  long sum = 0;
  for(int i=0;i<N;i++){
    sum += A[i];
  }
  return sum;
}

int main(){

  int N;
  scanf("%d",&N);

  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  printf("%d ",getMinNum(A,N));
  printf("%d ",getMaxNum(A,N));
  printf("%ld\n",getArraySum(A,N));

  return 0;
}


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

int main ()
{
    int h1, m1, h2, m2, k ;

    cin >> h1 >> m1 >> h2 >> m2>> k ;

    cout << ((h2*60 + m2) - (h1*60 + m1)) - k << "\n";
}

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

int main () {
  string s;
  cin >> s;
  map<char, int> m;
  for (int i = 0; i < s.size(); i++) {
    m[s[i]]++;
  }
  bool flag = true;
  for (auto i = m.begin(); i != m.end(); i++) {
    if (i->second != 2) {
      flag = false;
    }
  }
  if (flag && m.size() == 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}




void oneCase () {
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << "\n";




}





int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define mod 1000000007
using namespace std;
vector<int>ed[100005];
int n;
long long dp[100005][2];
long long dfs(int i,int c,int pa){
	if(i!=0&&ed[i].size()==1)return 1;
	if(dp[i][c])return dp[i][c];
	long long s=0,cc=1;
	for(int j:ed[i]){
		if(j==pa)continue;
		s=dfs(j,1-c,i);
		if(!c){
			s=(s+dfs(j,c,i))%mod;
		}
		cc=(cc*s)%mod;
	}
	return dp[i][c]=cc;
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		ed[x].push_back(y);
		ed[y].push_back(x);
	}
	ed[0].push_back(1);
	ed[1].push_back(0);
	cout<<dfs(0,0,-1);
}

Measured memory_bytes: 15616
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

n = input()
ls = []
for i in range(n):
    a, b = map(int, raw_input().split())
    ls.append((b, a))
ls.sort()

INF = 10 ** 18
DP = [0] + [INF] * n

for b, a in ls:
    DP2 = list(DP)
    for i in range(1, n + 1):
        if DP[i - 1] + a <= b:
            DP2[i] = min(DP[i], DP[i - 1] + a)
    DP = DP2

for i in range(n + 1):
    if DP[i] < INF:
        ans = i
print ans


Measured memory_bytes: 5036
N = int(input())
balls = []
for _ in range(N):
	x, y = map(int, input().split())
	balls.append((x, y))

counts = {}
for i in range(N):
	x1, y1 = balls[i]
	for j in range(i):
		x2, y2 = balls[j]
		p = x2 - x1
		q = y2 - y1
		if p < 0 or (p == 0 and q < 0):
			p = -p
			q = -q
		diff = (p, q)
		if diff in counts:
			s, l = counts[diff]
			s.add(i)
			s.add(j)
			l.append((i, j))
		else:
			counts[diff] = ({i, j}, [(i, j)])


min_cost = N
min_pq = None
for pq in counts:
	s, l = counts[pq]
	n = len(s)
	c = len(l)
	cost = (N - n) + n - (c + 1) + 1
	if cost < min_cost:
		min_cost = cost
		min_pq = pq
print(min_cost)


Measured memory_bytes: 3700
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var kn = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var k = kn[0];
            var n = kn[1];
            var houses = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();

            var result = 0;
            for (var i = 0; i < houses.Length; i++)
            {
                var h = houses[i];
                var goal1 = houses[(houses.Length + i - 1) % n];
                var goal2 = houses[(i + 1) % n];

                var result1 = 0;
                if (goal1 < h)
                {
                    result1 = k - h + goal1;
                }
                else
                {
                    result1 = goal1 - h;
                }

                var result2 = k - (goal2 - h);
                var min = Math.Min(result1, result2);
                if (result == 0 || min < result)
                {
                    result = min;
                }
            }

            Console.WriteLine(result);
        }
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

int main() {
	int n;
  	cin >> n;
  	ll ans = 0;
  	FOR (i, 1, n+1) ans += i;
  	cout << ans << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a, b, c;

int main() {
	cin >> a >> b >> c;
	
	repst(i,1,b) {
		if (a*i%b==c) {
			cout << "YES" << ln;
			return 0;
		}
	}
	cout << "NO" << ln;
}

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

void input()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
}
#define endl "\n"
#define ll long long int
#define vll vector<ll>
#define pb push_back
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define mt make_tuple
#define INF LONG_LONG_MAX
#define mod 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define cases ll t; cin>>t; while(t--)
#define array(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define sortall(a) sort(a.begin(),a.end())
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;

// --------------- My Template End --------------- //
bool isprime(ll n)
{
    if(n%2==0)return false;
    for(int i=3;i<=sqrt(n);i+=2)
    {
        if(n%i==0)return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//input();
    ll n;
    cin>>n;
    string a="",c="abcdefghijklmnopqrstuvwxyz";
    while(n)
    {
    	ll rem=n%26;
    	if(rem==0)rem=26;
    	a=c[rem-1]+a;

    	if(n%26==0)
    	{
    		n=n/26;
    		n--;
    	}
    	else
    	{
    		n=n/26;
    	}
    }
    cout<<a<<endl;
}




Measured memory_bytes: 3668
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))


int main(){ FastIO;

int n,i;cin>>n;int a[n];
for(i=0;i<n;i++) cin>>a[i];
int c=1,m=a[0];
for(i=1;i<n;i++)
{
	m=min(m,a[i]);
	if(m==a[i]) c++;
}
cout<<c;


return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n), pi(n);
    rep(i, n){
        cin >> p[i];
        pi[i] = p[i] - (i+1);
    }
    ll cnt = 0;
    rep(i, n){
        if(pi[i] == 0){
            if(i != n-1){
                ll tmp = p[i+1];
                p[i+1] = p[i];
                pi[i+1] = p[i] - (i+2);
                p[i] = tmp;
                pi[i] = tmp - (i+1);
            }else{
                ll tmp = p[i-1];
                p[i-1] = p[i];
                pi[i-1] = p[i] - (i);
                p[i] = tmp;
                pi[i] = tmp - (i+1);
            }
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

//----------------------------------------------------------------

int main()
{
    ll n;
    cin >> n;
    ll ans = infll;
    for (ll i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            chmin(ans, i + n / i - 2);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define ll long long
#define endl '\n'
#define pb push_back
#define loop(i, a, b) for (int i = a; i < b; i++)

const ll mod = 1e9+7;
const ll m = 1e9+7;

ll expo_mod(ll x, ll n) //Exponenciação rápida com módulo
{
    if (n == 0)
        return 1;

    ll t = expo_mod(x, n/2); //O resultado já é em módulo

    ll result = (t * t)%mod;

    if (n%2 == 1) //Se n é ímpar
        return (result * (x%mod))%mod; //(a * b) mod m = (a mod m * b mod m) mod m

    return result;
}

ll fat(int x)
{
    int r = 1%m;
    for (ll i = 1; i <= x; i++)
        r = (r * i%m)%m; //(a * b) mod m = (a mod m * b mod m) mod m

    return r;
}

int main ()
{

    ll x, y; cin >> x >> y;

    if ((x+y)%3 != 0 or 2*x-y < 0 or 2*y-x < 0)
    { //Não há solução
        cout << 0 << endl;
        return 0;
    }

    ll n = (x+y)/3;

    ll a = (2 * y - x)/3;
    ll b = (2 * x - y)/3;

    //(n escolha a) mod m = ( n! / (a! * b!) ) mod m

    //cout << ( ( ( ( fat(n) * expo_mod(fat(a), mod - 2) )%mod  ) * expo_mod(fat(b), mod - 2) )%m ) << endl;


    cout << ((fat(n) * expo_mod((fat(a) * fat(b))%m, m-2))%m) << endl;

    return 0;
}


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

int main() {
    int h1, m1, h2, m2, k, ans, a, b, cnt=0;
    cin >> h1 >> m1 >> h2 >> m2 >>k;
    a = 60*h1+m1;
    b = 60*h2+m2;
    ans = b-a;
    ans -= k;
    cout << ans << endl;
} 




Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, T b ) { if ( a < b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, T b ) { if ( a > b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp( a, b ) make_pair( a, b )
#define mt( ... ) make_tuple( __VA_ARGS__ )

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()

#define MOD ( (ll)( 1e9 + 7 ) )


int main()
{
	int A, P;
	cin >> A >> P;

	cout << ( ( A * 3 + P ) / 2 ) << endl;

	return ( 0 );
}


Measured memory_bytes: 888
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC 9(10).
01 qt         PIC 9(19).
01 dvd        PIC 9(10).
01 c          PIC 9(19).
01 c1         PIC 9(19).
01 c3         PIC 9(19).
01 c5         PIC 9(19).
01 c15        PIC 9(19).
01 accum      PIC 9(19).
01 zs         PIC Z(18)9.

PROCEDURE DIVISION.
  ACCEPT N.
  MOVE 1 TO dvd.
  PERFORM CALC.
  MOVE c TO c1.
  MOVE 3 TO dvd.
  PERFORM CALC.
  MOVE c TO c3.
  MOVE 5 TO dvd.
  PERFORM CALC.
  MOVE c TO c5.
  MOVE 15 TO dvd.
  PERFORM CALC.
  MOVE c TO c15.
  COMPUTE accum = c1 - c3 - c5 + c15.
  MOVE accum TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.

CALC SECTION.
  DIVIDE N BY dvd GIVING qt.
  COMPUTE c = (dvd + (qt * dvd)) * qt / 2.


Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c;
    int k;
    cin >> a >> b >> c >> k;
    rep(i,k){
        if(a >= b){
            b = 2*b;
            continue;
        }else if(b >= c){
            c = c*2;
            continue;
        }
    }
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int &x: a)
		cin >> x;
	vector<ll> suf(n+1);
	for(int i=n-1; i>=0; i--)
		suf[i] = suf[i+1] + a[i];
	int best_suf = 0;
	for(int i=1; i<n-k+1; i++)
		if(suf[i]-suf[i+k] > suf[best_suf]-suf[best_suf+k])
			best_suf = i;
	function<ll(int)> sum = [&sum](int a){return a? (ll)a+sum(a-1): 0;};
	double ans = 0;
	for(int i=best_suf; i<best_suf+k; i++)
		ans += (double)sum(a[i])/a[i];
	cout << fixed << setprecision(12) << ans << endl; 
	
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll x,n,i,l1,l2,r1,r2,ans,pos[200001],a[200001],nt[200001],pr[200001];
int main(){
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(i=1;i<=n;i++){
		pr[i]=i-1;nt[i]=i+1;
		pos[a[i]]=i;
	}
	for(i=1;i<=n;i++){
		x=pos[i];
		l1=pr[x];l2=pr[l1];
		r1=nt[x];r2=nt[r1];
		if(l1)ans+=i*(l1-l2)*(r1-x);
		if(r1<=n)ans+=i*(r2-r1)*(x-l1);
		nt[pr[x]]=nt[x];
		pr[nt[x]]=pr[x];
		//printf("%lld\n",ans);
	}
	printf("%lld",ans);
}
/*
只会主席树上二分找第二个大于的两只log做法。
看了题解，真是orz
按pi从小到大来，做完i，把i从链表中上去。这样查找当前值的话链表中剩下的数肯定是大于它的，那么只需在链表中查询即可~ 
这种做法查几个都可以，且复杂度O（n） 
*/

Measured memory_bytes: 5632
#include<stdio.h>
#include<stdlib.h>
main()
{
	int n,i,count=0;
	scanf("%d",&n);
	int a[51];
	for(i=0;i<n;++i)
	{
		scanf("%d",&a[i]);
	}
for(i=0;i<n;++i)
{
	if(a[i]!=(i+1))
	{
		count++;
	}
}
if(count==0 || count==2)
{
	printf("YES");
}
else
{
	printf("NO");
}
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int D, G;
    cin >> D >> G;

    int p[D + 1], c[D + 1];
    for (int i = 1; i <= D; i++) {
        cin >> p[i] >> c[i];
    }

    int minimum = MOD;

    for (int i = 0; i < (1<<D); i++) {
        int count = 0;
        int score = 0;
        for (int j = 1; j <= D; j++) {
            if (i & (1 << (j - 1))) {
                count += p[j];
                score += j * 100 * p[j] + c[j];
            }
        }
        int k = D;
        while (score < G && k > 0) {
            if (!(i & (1 << (k - 1)))) {
                int diff = min(((G - score) % (k * 100) == 0 ? (G - score) / (k * 100) : (G - score) / (k * 100) + 1), p[k] - 1);
                count += diff;
                score += diff * k * 100;
                break;
            }
            k--;
        }
        if (score >= G) minimum = min(minimum, count);
    }

    cout << minimum << endl;

    return 0;
}

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

typedef long long ll;

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    rep(i, N) cin >> S[i];
    sort(S.begin(), S.end());
    rep(i, N) cout << S[i];
    cout << "\n";
}

Measured memory_bytes: 384
while true do
	kaimono = gets.to_i
	if kaimono == 0 then
		break		
	end

	otsuri = 1000 - kaimono

	kozeni500 = otsuri / 500
	otsuri = otsuri - 500 * kozeni500

	kozeni100 = otsuri / 100
	otsuri = otsuri - 100 * kozeni100

	kozeni50 = otsuri / 50
	otsuri = otsuri - 50 * kozeni50

	kozeni10 = otsuri / 10
	otsuri = otsuri - 10 * kozeni10

	kozeni5 = otsuri / 5
	otsuri = otsuri - 5 * kozeni5

	kozeni1 = otsuri / 1

	puts(kozeni1 + kozeni5 + kozeni10 + kozeni50 + kozeni100 + kozeni500)	
end

Measured memory_bytes: 8604
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        int count = 0;
        int num[] = new int[n];
        
        for(int i = 0; i < n; i++){
            num[i] = stdIn.nextInt();
        }
        
        for(int i = 1; i < n - 1; i++){
            if(num[i - 1] > num[i]){
                if(num[i] > num[i + 1]){
                    count++;
                }
            }else{
                if(num[i] < num[i + 1]){
                    count++;
                }
            }
        }
        
        System.out.println(count);
    }
}


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

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using ull = unsigned long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << vec[k - 1] << endl;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

ll lcm(ll a, ll b)
{
    return a*b/__gcd(a, b);
}

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

    int N, K;
    cin >> N >> K;
    bool flag1 = false;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        if (A[i] == K) {
            cout << "POSSIBLE" << endl;
            return 0;
        } else if (A[i] > K) {
            flag1 = true;
        }
    }

    if (!flag1) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

    sort(ALL(A));

    bool flag2 = false;
    ll g = __gcd(A[0], A[1]);
    for (int i=2; i<A.size(); i++) {
        g = __gcd(g, A[i]);
    }

    cout << (K % g == 0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
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};

int main()
{
    int N, M, cnt = 0;
    cin >> N >> M;

    LP a[N];
    ull s = 0;

    REP(i, N)
    cin >> a[i].first >> a[i].second;

    SORT(a, N);

    REP(i, N)
    {
        if (a[i].second < M - cnt)
        {
            s += a[i].first * a[i].second;
            cnt += a[i].second;
        }
        else
        {
            cout << s + a[i].first * (M - cnt) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define MOD 1000000007
using ll = long long;
using namespace std;

int main() {
    int n, ans=1;
    cin >> n;
    while (ans*2 <= n) {
        ans *= 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	string s;
	cin >> s;
	int n = s.size();
	int a = n;
	int b = n;
	rep(i,0,n) {
		if(s[i] == '0') {
			a = min(a, max(i, n-i-1));
		} else {
			b = min(b, max(i, n-i-1));
		}
	}
	cout << max(a,b) << '\n';
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 2010;
bitset<N> dp[N], win[N];

int main() {
    int n;
    cin >> n;
    FOR(i,1,n-1){
        string s;
        cin >> s;
        REP(j,i){
            if (s[j] == '1'){
                win[i].set(j);
            }else{
                win[j].set(i);
            }
        }
    }

    REP(i,n) dp[i].set(i);

    FOR(len,1,n-1){
        REP(l,n+1-len){
            int r = l + len - 1;
            if (l > 0 && (win[l - 1] & dp[l] & dp[r]).any()) dp[r].set(l - 1);
            if (r < n - 1 && (win[r + 1] & dp[l] & dp[r]).any()) dp[l].set(r + 1);
        }
    }
    cout << (dp[0] & dp[n - 1]).count() << endl;

    return 0;
}


Measured memory_bytes: 1280
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
op = []
for i in range(M):
    b, c = map(int, input().split())
    op.append((c, b))
op.sort(reverse=True)
sum = 0
j = 0
for c,b in op:
    while j < N and b > 0 and A[j] < c:
        sum += c
        b -= 1
        j = j + 1
while j < N:
    sum += A[j]
    j += 1
print(sum)

Measured memory_bytes: 88280
'use strict';
(function(stdin) {
  var i = stdin.toString().trim();
  (function(r) {
    var r = (i * i * Math.PI).toFixed(6);
    var g = (2 * Math.PI * i).toFixed(6);
    console.log(r,g);
  }(parseInt(i,10)
      )); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15628
package main

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

func main() {
	N := nextInt()

	fmt.Println(N * N * N)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

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

  for(int k=0; k <n;k++){
    for(int i =0; i<10;i++){
      for(int j = 10-1; j>i; j--){
        if(s[k][j]<s[k][j-1]){
          char temp=s[k][j];
          s[k][j]=s[k][j-1];
          s[k][j-1]=temp;
        }
      }
    }
  }
  long int sum=0;
  vector<string> s1;
  for(int i=0; i<n;i++){
    s1.push_back(s[i]);
  }
  sort(s1.begin(), s1.end());
  long int x=0;
  for(int i =0; i<n-1; i++){
    if(s1[i]==s1[i+1]){
      x++;
    }else{
      sum += x*(x+1)/2;
      x=0;
    }
  }
  sum += x*(x+1)/2;
  cout <<sum;
}


Measured memory_bytes: 12788
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int T=in.nextInt(),P=in.nextInt(),R=in.nextInt();
			if((T|P|R)==0)
				return;
			int team[]=new int[T+1];
			int id[]=new int[T+1];
			int wrong[][]=new int[T+1][P+1];
			int plob[][]=new int[T+1][P+1];
			int tim[][]=new int[T+1][P+1];
			int pena[]=new int[T+1];
			for(int i=0;i<R;i++)
			{
				int tiD=in.nextInt();
				int piD=in.nextInt();
				int time=in.nextInt();
				String messe=in.next();
				if(messe.equals("WRONG"))
					wrong[tiD][piD]++;
				else
				{
					plob[tiD][piD]=1;
					tim[tiD][piD]+=time+wrong[tiD][piD]*1200;
				}
			}
			for(int i=1;i<=T;i++)
				for(int j=1;j<=P;j++)
				{
					if(plob[i][j]==1)
						team[i]++;
					pena[i]+=tim[i][j];
					id[i]=i;
				}
			int max;
			for(int i=1;i<=T;i++)
			{
				max=i;
				for(int j=i;j<=T;j++)
				{
					if(team[max]<team[j])
						max=j;
					else if(team[max]==team[j])
					{
						if(pena[max]>pena[j])
							max=j;
						else if(pena[max]==pena[j])
						{
							if(id[max]>id[j])
								max=j;                        
						}
					}
				}
				int tmp1=team[i];
				int tmp2=pena[i];
				int tmp3=id[i];
				team[i]=team[max];
				pena[i]=pena[max];
				id[i]=id[max];
				team[max]=tmp1;
				pena[max]=tmp2;
				id[max]=tmp3;
			}
			for(int i=1;i<=T;i++)
				System.out.println(id[i]+" "+team[i]+" "+pena[i]);
		}
	}
}

Measured memory_bytes: 13000
N=int(input())
x=input().split()
x=[int(s) for s in x]
b=sum(x)/N
if b>int(b)+0.5:
    b=int(b)+1
else:
    b=int(b)
d=0
for i in x:
    c=(i-b)**2
    d+=c
print(d)

Measured memory_bytes: 3060
/*
Educational DP Contest - K - Stones
https://atcoder.jp/contests/dp/tasks/dp_k
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {

}

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

//    int tc; cin >> tc;
//    TC(tc) solve();
	int n, k;
	cin >> n >> k;
	vi a(n);
	READ(a);
	vi dp(k+1,0); // 0: first player wins; 1: second player wins
	FORN(i,1,k){
		EACH(x,a){
			if(i>=x&&!dp[i-x]){
				dp[i]=1;
			}
		}
	}
	OUT((dp[k]?"First":"Second"));
    return 0;
}


Measured memory_bytes: 3700
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def is_kaibun(S):
    flag = True
    # print(S)
    for i in range((len(S) + 1) // 2):
        # print(i, S[i], S[len(S) - i - 1])
        if S[i] != S[len(S) - i - 1]:
            flag = False
            break
    return flag

def main():
    from builtins import int, map
    S = input()
    N = len(S)
    if is_kaibun(S) and is_kaibun(S[:N // 2]) and is_kaibun(S[N // 2 + 1:]):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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

using namespace std;
using ll = long long;

int main() {
    string s,t;
    cin>>s>>t;
    for(int i = 0;i < s.size();++i) {
        if(s[i]!=t[i]) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;


int main() {

	ll L;
	cin >> L;

	vector<pair<ll,pair<ll,ll>>> ed;

	ll seq[21];

	ll N = 1;

	while (L >0) {
		seq[N] = L;
		L /= 2;
		N++;
	}

	N--;

	for (ll i = N - 1; i >= 1; i--) {
		ed.push_back({ i,{i + 1,0} });
		ed.push_back({ i,{i + 1,seq[i + 1]} });

		if (seq[i] == 2 * seq[i+1] + 1) {
			ed.push_back({ i,{N,2 * seq[i + 1]} });
		}
	}

	cout << N << " " << ed.size() << endl;

	rep(i, ed.size()) {
		cout << ed[i].first << " " << ed[i].second.first << " " << ed[i].second.second << endl;
	}
	



	
	system("PAUSE");
}

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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

bool is_valid(int n, vector<bool> &d) {
  while (n) {
    if (d[n % 10]) {
      return false;
    }
    n /= 10;
  }
  return true;
}

void solve() {
  int n, k, x;
  vector<bool> d(10);
  cin >> n >> k;
  rep(i, 0, k - 1) {
    cin >> x;
    d[x] = true;
  }

  while (!is_valid(n, d)) {
    n++;
  }

  cout << n;
}

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

  // freopen(".in", "r", stdin);
  // freopen(".out", "w", stdout);

  solve();

  return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  int n,m;
  while(cin >> n >> m){
    if(n==0&&m==0)
      return 0;

    vector< vector<int> > cost(m+1, vector<int>(m+1,INF)),
      time(m+1, vector<int>(m+1,INF));

    REP(i,cost.size()){
      cost[i][i] = time[i][i] = 0;
    }

    REP(i,n){
      int a,b,c,t;
      cin >> a >> b >> c >> t;
      cost[a][b] = cost[b][a] = c;
      time[a][b] = time[b][a] = t;
    }

    REP(i,cost.size()){
      REP(j,cost.size()){
	REP(k,cost.size()){
	  cost[j][k] = min( cost[j][k], cost[j][i] + cost[i][k] );
	  time[j][k] = min( time[j][k], time[j][i] + time[i][k] );
	}
      }
    }

    int k;
    cin >> k;
    REP(_tmp,k){
      int p,q,r;
      cin >> p >> q >> r;
      int res= r ? time[p][q] : cost[p][q];
      cout << res << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1304
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999

int x(int a,int p){
    return a*p;
}

int y(int b,int c,int d,int p){
    int ret = b;
    p-=c;
    if(p<=0)return ret;
    ret+=d*p;
    return ret;
}


int main(){
    int a,b,c,d,p;
    cin>>a>>b>>c>>d>>p;
    
    cout<<min(x(a,p),y(b,c,d,p))<<endl;
}

Measured memory_bytes: 3092
#include <cstdio>
#include <vector>

int main(int argc, char *argv[]) {
	using namespace std;
	
	int line;
	while (EOF != fscanf(stdin, "%d", &line)) {
		vector<bool> sieve(line, true);
		int prmCount = 0;

		for (int i = 2; i <= line; i++) {
			if (sieve[i]) {
				prmCount++;
				for (int j = i+i; j <= line; j+=i) {
					sieve[j] = false;
				}
			}
		}
		printf("%d\n", prmCount);
	}
	

	return 0;
}

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


int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	int sum = 0;
	for (int n = 0;n<N;++n) {
		cin >> A[n];
		sum += A[n];
	}
	vector<int>B(N);
	B[0] = sum;
	for (int n = 1;2*n-1 < N;++n) {
		B[0] -= 2*A[2 * n - 1];
	}
	for (int n = 1; n < N; ++n) {
		B[n] = 2 * A[n-1] - B[n - 1];
	}
	for (int n = 0; n < N; ++n) {
		if (0 != n) {
			cout << " ";
		}
		cout << B[n];
	}
	

	
	return 0;
}

Measured memory_bytes: 4028