akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main () {
  int A;
  cin >> A;
  for (int i = 1; i < 10; i ++) {
    for (int j = 1; j < 10; j ++) {
      if (A == i * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
ll x[50], y[50];

double func(double cx, double cy) {
	double R = 0;
	REP(i, N) chmax(R, pow(x[i] - cx, 2) + pow(y[i] - cy, 2));
	return R;
}

double solve(double bx) {
	double l = 0, r = 1000;
	double R = numeric_limits<double>::max();
	REP(t, 500) {
		double x1 = (2*l + r) / 3;
		double x2 = (l + 2*r) / 3;
		double v1 = func(bx, x1), v2 = func(bx, x2);
		if (v1 > v2) l = x1;
		else r = x2;
		chmin(R, v1);
	}
	return R;
}

int main() {
	cin >> N;
	REP(i, N) cin >> x[i] >> y[i];
	
	double ans = numeric_limits<double>::max();
	double l = 0, r = 1000;
	REP(t, 500) {
		double x1 = (2*l + r) / 3;
		double x2 = (l + 2*r) / 3;
		double v1 = solve(x1), v2 = solve(x2);
		if (v1 > v2) l = x1;
		else r = x2;
		chmin(ans, v1);
	}
	ans = sqrt(ans);
	printf("%.16f\n", ans);
	return 0;
}


Measured memory_bytes: 256
s = str(input())
s_len = int((len(s) - 1) / 2)

s_1 = s[:s_len]
s_1_len = int((len(s_1) - 1) / 2)

s_2 = s[s_len+1:]
s_2_len = int((len(s_2) - 1) / 2)

ans = 'Yes'

for i in range(s_len+1):
  if s[i] != s[-i-1]:
    ans = 'No'
    break

for i in range(s_1_len+1):
  if s_1[i] != s_1[-i-1]:
    ans = 'No'
    break

for i in range(s_2_len+1):
  if s_2[i] != s_2[-i-1]:
    ans = 'No'
    break

print(ans)

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    stack<int> l;
    int r = 0;
    for(int i = 0;i < n;i++){
        if(s[i] == '(')l.push(1);
        if(s[i] == ')'){
            if(!l.empty())l.pop();
            else r++;
        }
    }
    for(int i = 0;i < r;i++){
        cout << '(';
    }
    cout << s;
    for(int i = 0;i < l.size();i++){
        cout << ")";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,b,a) for (ll i=b;i>=a;i--)
#define ff first
#define ss second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
typedef long double ld;
ll ESP=1e18;
ll FCB=1e9+7;
ll dir[][2]={{0,-1},{0,1},{1,0},{-1,0}};


int main()
{
 hs;
 ll n;
 cin>>n;
 bool ff=0,gg=0;
 ll ans=1;
ll a[n];
 rep(i,0,n)
 {
  cin>>a[i];
  if(a[i]==0)
    ff=1;
 }
if(ff==1)
{
  cout<<"0"<<"\n";
  return 0;
}
   
 rep(i,0,n)
 {
  
  if(a[i]<=1000000000000000000/ans)
    ans*=a[i];
  else
   {
     cout<<"-1"<<"\n";
    return  0;
   }
  
    
 }
 
 

    cout<<ans<<"\n";
 return 0;
 }


Measured memory_bytes: 4444
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int a[n];
  int b[n];
  rep(i,n){
    cin >> a[i];
    b[i] = a[i];
  }

  sort(b,b+n,greater<int>());
  rep(i,n){
    if(a[i] != b[0]){
      printf("%d\n", b[0]);
    }else{
      printf("%d\n", b[1]);
    }
  }

  return 0;
}


Measured memory_bytes: 3200
n = int(input())

k = int(input())

keta = len(str(n))

dp = [[[0 for j in range(keta+2)] for _ in range(2)]  for i in range(keta)]

s = str(n)

#dp[何桁目か][未満フラグ 0 = 未満][ゼロ以外のの個数]

x = int(s[0])
if x == 1:
    dp[0][1][0] = 1
else:
    dp[0][1][0] += 1
    dp[0][0][0] += x - 1


for index, c in enumerate(s[1:]):
    i = index + 1
    x = int(c)
    dp[i][0][0] += 9
    for j in range(keta+1):
        dp[i][0][j] += dp[i - 1][0][j]
        if x == 0:
            dp[i][1][j] += dp[i - 1][1][j]
            dp[i][0][j + 1] += dp[i - 1][0][j] * 9
        elif x:
            dp[i][1][j + 1] += dp[i - 1][1][j]
            dp[i][0][j]     += dp[i - 1][1][j]
            dp[i][0][j + 1] += dp[i - 1][0][j] * 9
            dp[i][0][j + 1] += dp[i - 1][1][j] * (x - 1)
    # print(sum(dp[i][0]) + sum(dp[i][1]))
    # print(s[:index + 2])
    # print(dp)




print(dp[-1][0][k-1] + dp[-1][1][k-1])



Measured memory_bytes: 44272
import sys

input = sys.stdin.readline
N, M = map(int, input().split())
AB = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[1])[::-1]
plan = [i for i in range(M+1)]
ans = 0
for a, b in AB:
    i = a
    while i < (M + 1) and plan[i] != i:
        plan[i] += 1
        i = plan[i] -1
    if i < (M+1):
        plan[i] += 1
        ans += b
print(ans)


Measured memory_bytes: 98108
# coding: utf-8

if __name__ == "__main__":
    def A(now):
        return 2*now

    def B(now, K):
        return now + K

    N = int(input())
    K = int(input())
    now = 1

    for i in range(N):
        if A(now) < B(now, K):
            now = A(now)
        else:
            now = B(now, K)

    print(now)

Measured memory_bytes: 3060
#include <stdio.h>
#include <ctype.h>
     int main(){
     int count[26]={0};
     char ch;
     int i, num;
     while(scanf("%c", &ch)!=EOF){
         if(islower(ch)){
             num=ch-'a';
         }
else if(isupper(ch)){
             num=ch-'A';
         }
else{
             continue;
         }
         count[num]++;
     }
     for(i=0;i<26;i++){
         printf("%c : %d\n", 'a'+i, count[i]);
     }
         return 0;
 }


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
using namespace std;
long long n,k,s,a[1000],i;
int main()
{
	cin >> n >> k;
	for ( i = 0 ; i < n ; i++ ) cin >> a[i];
	sort(a,a+n);
	for ( i = 0 ; i < k ; i++ ) s+=a[i];
	cout << s;
}

Measured memory_bytes: 3172
'''
A
  歳の高橋君が観覧車に乗ろうとしています。

この観覧車は、
13
 歳以上が乗るには
B
 円 (
B
 は偶数) かかりますが、
6
 歳以上
12
 歳以下の人はその半額で乗ることができ、 さらに
5
 歳以下の人は無料で
'''

a, b = map(int, input().split())
if a > 12:
    print(b)
elif a >= 6:
    print(b//2)
else:
    print(0)


Measured memory_bytes: 2940
import java.util.List;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> ar = Arrays.stream(sc.next().split("")).collect(Collectors.toList());

        int cnt = 1;
        String temp = ar.get(0);
        for (int i = 1; i < ar.size(); i++) {
            if (!ar.get(i).equals(temp)) {
                temp = ar.get(i);
                cnt++;
            }
        }

        System.out.println(cnt);
        sc.close();
    }
}

Measured memory_bytes: 35260
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
using namespace std;
int n, p1, p2, q, s, t, k;
int a[234567];
signed main() {
	cin >> n >> q >> s >> t;
	cin >> p1;
	for (int i = 1; i <= n; i++) {
		cin >> p2;
		a[i] = p2 - p1;
		p1 = p2;
		k -= (a[i] > 0 ? s : t)*a[i];
	}
	for (int i = 1; i <= q; i++) {
		int l, r, x; cin >> l >> r >> x;
		if (l != 0) {
			p1 = a[l] + x;
			k -= (p1 > 0 ? s : t)*p1 - (a[l] > 0 ? s : t)*a[l];
			a[l] = p1;
		}
		if (r != n) {
			p1 = a[r + 1] - x;
			k -= (p1 > 0 ? s : t)*p1 - (a[r + 1] > 0 ? s : t)*a[r + 1];
			a[r + 1] = p1;
		}
		cout << k << endl;
	}
}


Measured memory_bytes: 4676
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string s;cin>>s;
  sort(s.begin(),s.end(),greater<char>());
  s.erase(unique(s.begin(),s.end()),s.end());
  int NS = 0,WE = 0;
  for(int i = 0; s.size() > i; i++){
    if(s[i] == 'N' || s[i] == 'S')NS++;
    if(s[i] == 'W' || s[i] == 'E')WE++;
  }
  if((NS == 0 || NS == 2) && (WE == 0 || WE == 2))cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(e)-1 for e in input().split()]

c = [0]*n

for i in range(n):
    c[a[i]] += 1

sum_c = 0
for j in range(n):
    sum_c += (c[j]*(c[j]-1))//2

for k in range(n):
    print(sum_c - c[a[k]] + 1)

Measured memory_bytes: 25768
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

bool like[30][30];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        int K;
        cin >> K;
        for(int j = 0; j < K; j++){
            int a;
            cin >> a;
            like[i][a - 1] = true;
        }
    }

    int ans = 0;
    for(int i = 0; i < M; i++){
        bool liked_by_every_one = true;
        for(int j = 0; j < N; j++){
            if(!like[j][i]){
                liked_by_every_one = false;
                break;
            }
        }
        if(liked_by_every_one){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import copy

def patterns(n):
    if(n==2):
        return [[0,1],[1,0]]
    else:
        a = patterns(n-1)
        new = []
        for i in a:
            for j in range(n):
                copied = copy.copy(i)
                copied.insert(j,n-1)
                new.append(copied)
        return new

N = int(input())
X = []
Y = []
for i in range(N):
    p = input().split()
    X.append(int(p[0]))
    Y.append(int(p[1]))

lengthsum = 0.0
pattern = patterns(N)
for i in pattern:
    for j in range(N-1):
        lengthsum += ((X[i[j+1]]-X[i[j]])**2+(Y[i[j+1]]-Y[i[j]])**2)**0.5

print(lengthsum/len(pattern))  

Measured memory_bytes: 10868
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    if (a == b) PRINT(1);
    else if (a > b || n == 1) PRINT(0);
    else PRINT((a+b*(n-1))-a*(n-1)-b+1);
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H,W = map(int, readline().split())
    C = [[int(i) for i in readline().split()] for _ in range(10)]
    A = [[int(i) for i in readline().split()] for _ in range(H)]

    # 頂点kを経由する場合としない場合を比較
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][k] + C[k][j], C[i][j])
    
    ans = 0
    for a in A:
        for i in a:
            if i != -1 and i != 1:
                ans += C[i][1]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
import collections

n = int(input())
a = list(map(int, input().split()))

C = collections.Counter(a)
total = 0
for i in C.keys():
    total += C[i] * (C[i] - 1) // 2
for i in range(n):
    A = a[i]
    print(total - C[A] + 1)


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

using namespace std;

#define int long long
#define tie() ios_base :: sync_with_stdio(0); cin.tie(0) ; cout.tie(0);
#define err(x) cerr << #x << " is : " << x << endl
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define pb           push_back
#define ff           first
#define ss           second

int32_t main()
{
      tie();
      int n , m;
      cin >> n >> m;
      cout << ((n * ( n - 1)) /2) + (((m) * (m - 1)) / 2) << endl;;
      return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int lzw=4000+3,mod=1e9+7;
int dp[lzw][lzw],a[200000+3],b[200000+3],n,ans;
int fac[lzw<<1],ine[lzw<<1],f[lzw<<1];
int power(int a,int p){
	int ans=1;
	while(p){
		if(p&1) ans=ans*a%mod;
		p>>=1;
		a=a*a%mod;
	}
	return ans;
}
int comb(int a, int b) {
	if (b > a) return 0;
	return b ? fac[a] * f[a - b] % mod * f[b] % mod : 1; 
}
void pre(){
	fac[0]=1;
	for(int i=1;i<=(lzw<<1)-3;i++) fac[i]=fac[i-1]%mod*i%mod;
	ine[1]=1;
	for(int i=2;i<=(lzw<<1)-3;i++){
		int a=mod/i,b=mod%i;
		ine[i]=(-a*ine[b]%mod+mod)%mod;
	}
	f[0]=1;
	for(int i=1;i<=(lzw<<1)-3;i++) f[i]=f[i-1]%mod*ine[i]%mod;
}
signed main(){
	pre();
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
		dp[2001-a[i]][2001-b[i]]++;
	}
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
	for(int i=1;i<=n;i++) ans=(ans+dp[2001+a[i]][2001+b[i]])%mod;
	for(int i=1;i<=n;i++) ans=(ans-comb(2*(a[i]+b[i]),2*a[i])%mod+mod)%mod;
	printf("%lld\n",ans*power(2,mod-2)%mod);
	return 0;
}


Measured memory_bytes: 132280
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int n;
  cin>>n;
  int c[8]={0};
  int o=0;
  int a=0;
  for(int i=0; i<n; i++) {
    int x;
    cin>>x;
    if(x>=3200) o++;
    else if(c[x/400]==0) {
      a++;
      c[x/400]=1;
    }
  }
  if(a==0) cout<<1<<" "<<o<<endl;
  else cout<<a<<" "<<a+o<<endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = [0]
for i in range(N):
    B.append(B[i]+A[i])
dmin = 10**15
for i in range(1,N):
    dmin = min(dmin,abs(B[N]-2*B[i]))
print(dmin)

Measured memory_bytes: 24832
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n=Integer.parseInt(scan.next());
    		int m=Integer.parseInt(scan.next());
    		
    		int[] memo =new int[n];
    		Arrays.fill(memo, -1);
    		boolean ans =true;
    		int s,c;
    		for (int i=0;i<m;++i) {
    			s=Integer.parseInt(scan.next());
    			c=Integer.parseInt(scan.next());
    			
    			if (s==1 && c==0 && n!=1) {
    				ans=false;
    				break;
    			}else {
    				if (memo[s-1]==-1 || memo[s-1]==c) {
    					memo[s-1]=c;
    				}else {
    					ans=false;
    					break;
    				}
    				
    			}
    			
    		}
    		if (ans) {
    			if(memo[0]==-1&&n!=1) {
    				memo[0]=1;
    			}
    			for (int i:memo) {
    				if (i!=-1) {
    					System.out.print(i);
    				}else {
    					System.out.print(0);
    				}
    			}
    		}else {
    			System.out.print(-1);
    		}
    		
    		
    }	
    }
// end 

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

using namespace std;

int wynik;

int main(void)
{

  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;

  int prev;
  cin >> prev;
  wynik+=prev;

  int c =0;

  for(int i=2;i<n;i++)
  {

    cin >> c;

    wynik+=min(prev, c);

    prev = c;

  }

  wynik+=prev;

  cout << wynik;

  return 0;

}


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

int main(){
  int c[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  string ans = "No";
  for (int a1 = 0; a1 <= c[0][0]; a1++){
    int b1 = c[0][0] - a1;
    int b2 = c[0][1] - a1;
    int b3 = c[0][2] - a1;
    int a2 = c[1][0] - b1;
    int a3 = c[2][0] - b1; 
    if (a2+b2 == c[1][1] && a2+b3 == c[1][2] && 
            a3+b2 == c[2][1] && a3+b3 == c[2][2]) ans = "Yes";
  }
   cout << ans << endl;
}


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

using namespace std;

const int MOD = 1000000007;

int main(){
    int N, M; cin >> N >> M;
    vector<long long> dp(M);
    dp[0] = 2;
    for(int i=1;i<M;i++) dp[i] = 2 * dp[i-1] % MOD;
    for(int i=1;i<N;i++){
        long long add = 0;
        for(int j=0;j<M;j++){
            long long cur = dp[j];
            dp[j] = (cur * (j+2) + add) % MOD;
            add = (2 * add + cur * (j+1)) % MOD;
        }
    }
    cout << dp.back() << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define debug 1

int main() {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;
	cin>>n;
	long long a[n+1],b[n];
	for(int i=0;i<=n;i++)
		cin>>a[i];
	for(int j=0;j<n;j++)
		cin>>b[j];
	
	long long ans=0;
	for(int i=0;i<n;i++) {
		if(a[i]<b[i]) {
			b[i]-=a[i];ans+=a[i];a[i]=0;
			if(a[i+1]<b[i])
			{	b[i]-=a[i+1];ans+=a[i+1];a[i+1]=0;}
			else if(a[i+1]==b[i])
			{	b[i]=0;ans+=a[i+1];a[i+1]=0;}
			else if(a[i+1]>b[i])
			{	a[i+1]-=b[i];ans+=b[i];b[i]=0;}
		}
		else if(a[i]==b[i]) {a[i]=0;ans+=b[i];b[i]=0;}
		else if(a[i]>b[i]) {a[i]-=b[i];ans+=b[i];b[i]=0;}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#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) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

ll N, M, a[110000] = {};
int main() {
	cin >> N >> M;
	REP(i, 110000) {
		a[i] = INF;
	}
	REP(i, M) {
		ll tmp;
		cin >> tmp;
		a[tmp] = 0;
	}

	a[0] = 1;
	if (a[1] == INF) a[1] = 1;
	FOR(i,2, N+2) {
		if (a[i] == INF) {
			a[i] = a[i - 1] + a[i - 2];
			a[i] = a[i] % 1000000007;
		}
	}


	cout << a[N] << endl;

}

Measured memory_bytes: 4464
import math
n = int(input())
x = [int(i) for i in input().split()]
y = [int(j) for j in input().split()]
Manhattan = sum([abs(x[m]-y[m]) for m in range(n)])
Euclidean = math.sqrt(sum([(x[e]-y[e])**2 for e in range(n)]))
p_3 = (sum([(abs(x[c]-y[c]))**3 for c in range(n)]))**(1/3)
Chebyshev = max([abs(x[m]-y[m]) for m in range(n)])
print(Manhattan)
print(Euclidean)
print(p_3)
print(Chebyshev)


Measured memory_bytes: 5700
use std::cmp::min;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let _n = i.read::<usize>();
    let s = i.read_line().as_bytes();

    writeln!(o, "{}", solve(&s)).unwrap();
}
fn solve(s: &[u8]) -> usize {
    let mut b = 0; // 現在の文字を黒にするためのコスト
    let mut w = 0; // 現在の文字を白にするためのコスト
    if *s.last().unwrap() == b'.' {
        b = 1;
    }
    for &s in s[..s.len() - 1].iter().rev() {
        if s == b'.' {
            b += 1;
        } else {
            w = min(w + 1, b);
        }
    }
    min(b, w)
}


mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
var lines = [];
//最大の移動距離を格納しておく為初期化
var D = -1;
//都市の数
var N;
//xの座標を保存しておく
var x = [];
//初期座標
var first;
//初期座標からxまでの距離を格納
var absTotal = [];
//標準出力
var stdout = "Yes";
//一つ前の最後の文字を初期化
var lastWord = null;

function gcd(m, n) {
  // 剰余
  var r;

  if(m < n) {  // m >= nにする
    r = m;  //一時退避
    m = n;
    n = r;
  }

  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }

  return n;
}

var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function(line) {
  lines.push(line);
});
reader.on('close', function() {
  //標準出力から格納
  N = lines[0].split(' ')[0];
  first = lines[0].split(' ')[1];
  x = lines[1].split(' ');
  //console.log(x);

  //最大公約数を調べる為、各都市間の間隔を求める
  for(var i = 0; i < x.length; i++ ){
    //都市x[i]の座標を格納
    var toshi = x[i];
    //各都市と出発点の距離を格納
    var abs = Math.abs(first - toshi);
    //リストに各距離を格納
    absTotal.push(abs);
  }

  //最大公約数を求めるため、最大公約数となりえるものを先頭に持ってくる
  absTotal.sort();
  //console.log(absTotal);
  var D = absTotal[N-1];
  //最大公約数を探し終わるまでフラグをfalseにしておく
  var find = false;
  while(!(find)){
    for(var i = 0; i < absTotal.length; i++ ){
      var hikaku = absTotal[i];
      //console.log(hikaku % maxNum);
      if(hikaku % D != 0){
        D = gcd(D,hikaku);
        break;
      }
      find = true;
    }
  }

  console.log(D);
});


Measured memory_bytes: 27468
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005;
int n,m,q,a[MAXN],b[MAXN];
int main(){
	n=read();
	FOR(i,1,n) a[i]=read();
	FOR(i,1,n) b[i]=read();
	//sort(a+1,a+1+n);
	//sort(b+1,b+1+n);
	LL x=0,y=0,z=0;
	FOR(i,1,n) x+=a[i],y+=b[i];
	if (x>y) { printf("No\n"); return 0; }
	FOR(i,1,n)
	if (a[i]<b[i]) z+=(b[i]-a[i]+1)/2;
	if (y-x>=z) printf("Yes\n"); else printf("No\n");
	
	return 0;
}

/*
*/


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

ll pref[MAXN];
int n;

ll sum(int l, int r){
    if(l > r) return 0;
    return pref[r] - (l == 0 ? 0 : pref[l-1]);
}

ll dif(int l, int r, int m){
    return abs(sum(l, m-1) - sum(m, r));
}

void mxze(ll &a, ll b){
    a = max(a,b);
}
void mnze(ll &a, ll b){
    a = min(a,b);
}

ll result(int m1, int m, int m2){
    ll mx = sum(0,m1-1);
    mxze(mx, sum(m1,m-1));
    mxze(mx, sum(m,m2-1));
    mxze(mx, sum(m2,n-1));

    ll mn = sum(0,m1-1);
    mnze(mn, sum(m1,m-1));
    mnze(mn, sum(m,m2-1));
    mnze(mn, sum(m2,n-1));

    return mx - mn;
}

bool check(int l, int r, int m){
    return dif(l, r, m) > dif(l,r,m+1);
}

int findBest(int l, int r){
    int lo = l + 1, hi = r;
    while(lo < hi){
        int mid = (lo + hi)>>1;
        if(check(l, r, mid)) lo = mid + 1;
        else hi = mid;
    }
    return hi;
}

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

    ri(n);
    FOR(i,0,n) lri(pref[i]);
    FOR(i,1,n) pref[i] += pref[i-1];

    ll ans = INFLL;
    FOR(m,2,n-1){
        mnze(ans, result(findBest(0,m-1), m, findBest(m, n-1)));
    }

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

    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    E = []
    G = [dict() for _ in range(N)]

    for _ in range(N - 1):
        a, b = read_ints()
        a -= 1
        b -= 1
        E.append((a, b))
        G[a][b] = -1
        G[b][a] = -a

    K, C = solve(N, E, G)
    print(K)
    for c in C:
        print(c + 1)


def solve(N, E, G):
    K = max([len(d) for d in G])

    q = [(-1, 0)]
    while q:
        p, i = q.pop()

        used = -1
        if p != -1:
            used = G[p][i]

        c = 0
        for j in G[i]:
            if j == p:
                continue
            if c == used:
                c += 1
            G[i][j] = c
            G[j][i] = c
            q.append((i, j))
            c += 1

    C = [-1] * len(E)
    for i, (a, b) in enumerate(E):
        C[i] = G[a][b]
    return K, C


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


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

struct Edge {
    int to;
    int length;
    Edge(int t, int l) : to(t), length(l) { }
};

using Graph = vector<vector<Edge>>;

vector<int> color;
// 1（黒）, 0（白）, -1（未訪問）

void dfs(const Graph &G, int v, int cur = 0) {
    color[v] = cur;

    for (auto next_v : G[v]) {
        if (color[next_v.to] != -1) continue;

        if (next_v.length % 2 == 0) dfs(G, next_v.to, cur);
        else dfs(G, next_v.to, 1 - cur); 
    }

    return;
}

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

    Graph G(N);

    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    // cout << "here?" << endl;
    color.assign(N, -1);

    dfs(G, 0);

    for (auto c : color) {
        cout << c << endl;
    }
}


Measured memory_bytes: 8192
import math
def resolve():
    (N, K) = list(map(int, input().split(" ")))
    ans = 0
    for n in range(1, N+1):
        ans = ans + (1/N) * pow(2, -1*(max(0, math.ceil(math.log2(K/n)))))
    print(ans)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll m = 1e9 + 7;
ll n,q;
struct matrix{
    ll g[51][51];
};
matrix a;
matrix multiply(matrix a,matrix b){
    matrix res;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            res.g[i][j] = 0;
            for(int k=1;k<=n;k++){
                ll x = (a.g[i][k] * b.g[k][j])%m;
                res.g[i][j] = (res.g[i][j] + x)%m;
            }
        }
    }
    return res;
}
matrix power(matrix a,ll k){
    matrix p;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i == j){
                p.g[i][j] = 1;
            }
            else{
                p.g[i][j] = 0;
            }
        }
    }
    while(k > 0){
        if(1 & k){
        p = multiply(a,p);
        k--;
        }
        a = multiply(a,a);
        k/=2;
    }
    return p;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a.g[i][j];
        }
    }
    matrix l = power(a,q);
    ll ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            ll x = l.g[i][j]%m;
            ans = (ans + x)%m;
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3788
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int rw = 0, re = 0;
	int lw = 0, le = 0;
	rep(i, n) if(s[i] == 'W') rw++;
	re = n - rw;
	int ans = 1e9;
	rep(i, n){
		if(s[i] == 'W') rw--;
		else lw--;
		ans = min(ans, lw + re);
		if(s[i] == 'W') lw++;
		else le++;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 720
a,b,k = map(int,input().split())
al = 0
bl = 0

if a > 0:
    al = a-k
    if a >= k:
        bl = b
    else:
        bl =b-k+a
    if al <= 0:
        al = 0
    if bl <= 0:
        bl = 0

else:
    al = 0
    bl = b-k
    if bl <= 0:
        bl = 0

print(al,bl)

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

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

    // N以下の最大の2のべき乗を求める
    int thresh = 1;
    int k = 0;
    while (thresh <= N) {
        thresh *= 2;
        ++k;
    }
    cout << thresh / 2 << endl;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    s = []
    for i in range(n):
        t = S()
        t += t
        s.append(t)
    ans = 0
    for i in range(n):
        f = True
        for j in range(i, i + n):
            for k in range(n):
                if s[k][j] != s[j - i][k + i]:
                    f = False
                    
        if f:
            ans += n
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


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

int main()
{
  int n;
  cin >> n;
  int dist[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};

  int score;
  for (int i = 0; i < n; i++)
  {
    cin >> score;
    int rank = floor(score / 400.0);
    if (rank >= 8)
    {
      dist[8]++;
    }
    else
    {
      dist[rank]++;
    }
  }

  int res = 0;
  for (int i = 0; i < 8; i++)
  {
    if (dist[i])
    {
      res++;
    }
  }

  if (res != 0)
  {
    cout << res << " " << res + dist[8] << endl;
  }
  else
  {
    cout << 1 << " " << dist[8] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

int main()
{
    ll n, l;
    cin >> n >> l;

    vector<ll> t(n);

    iota(t.begin(), t.end(), l);

    //for (auto i: t)
    //    cout << i << endl;

    ll _min(LL_MAX), id;
    rep(i, 0, n) 
        if (abs(t[i]) < _min)
            _min = abs(t[i]), id = i;
        //_min = min(abs(t[i]), _min);

    ll sum(0);
    rep(i, 0, n) 
        if (i != id)
            sum += t[i];

    cout << sum << endl;

    return 0;
}


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

int main()
{
	int x,y,tmp;

	cin >> x >> y ;

	while((x!=0)||(y!=0))
	{
		if(x>y)
		{
			tmp = x ;
			x = y ;
			y = tmp ;
		}

		cout << x << ' ' << y << endl;

		cin >> x >> y ;
	}

	return 0;
}

Measured memory_bytes: 1160
import itertools

h, w = map(int, input().split())

s = [0] * h
for i in range(h):
    s[i] = list(input())

ans = 'Yes'
for i, j in itertools.product(range(h), range(w)):
    if s[i][j] == '.':
        continue
    c = False
    for k, l in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
        in_range = i + k >= 0 and j + l >= 0 and i + k < h and j + l < w
        if in_range and s[i + k][j + l] == '#':
            c = True
            break
    if not c:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> a(N);

    for(int i = 0; i < N; i++) cin >> a[i];

    int ans = 0;

    for(int i = 0; i < N; i += 2) {
        if(a[i] % 2) ans++;
    }

    cout << ans << endl;
}

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

#define I inline void 

using namespace std ; 

using ll = long long ; 
using ld = long double ; 

const int N = 2e6 + 7 ; 

// How interesting!

int n; 


int main(){
	ios_base::sync_with_stdio(0) ; 
	cin.tie(0) ; 
	//freopen("in.in", "r" , stdin) ;
	int k ; 
	cin >> n >>  k ; 
	if(k == 1) cout<< 0 ; 
	else cout<< n - k ; 

	return 0 ; 
}

Measured memory_bytes: 3612
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', (x) => {
    lines.push(x);
});

rl.on('close', () => {
    var N = Number(lines[0].split(" ")[0]);
    var M = Number(lines[0].split(" ")[1]);

    lines.shift();

    var xyz = lines.map(i => i.split(" ").map(i => Number(i)));
    var ans = 0; 

    // 0:プラス側に最大,  1:マイナス側に最大
    for (var i = 0; i < 2; i++) {

        for (var j = 0; j < 2; j++) {

            for (var k = 0; k < 2; k++) {
                var cake = Array(N).fill(0);
                for (var index = 0; index < N; index++) {
                    var x = (i === 0 ? xyz[index][0] : xyz[index][0] * (- 1));
                    var y = (j === 0 ? xyz[index][1] : xyz[index][1] * (- 1));
                    var z = (k === 0 ? xyz[index][2] : xyz[index][2] * (- 1));

                    cake[index] += x + y + z;
                }
                cake.sort((a, b) => b - a)

                var result = 0;
                for (var index = 0; index < M; index++) { result += cake[index] }
                ans = Math.max(ans, result);
            }
        }
    }
    console.log(ans)
});

Measured memory_bytes: 11680
#include <vector>
#include <algorithm>
#include <iostream>
#include <chrono>
#include<bitset>
#include<deque>
#include <map>
#define vint vector<int>
#define vint2 vector<vint>
#define vchar vector<char>
#define vchar2 vector<vchar> 
#define vchar3 vector<vchar2> 
#define pr pair<int,int>
#define vpr vector<pr>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define int long int
using namespace std;

int H, W;
int h, w;

int mymin(int a, int b, int c){
	int mi = a, ma = a;
	if (mi > b)mi = b; if (mi > c)mi = c;
	if (ma < b)ma = b; if (ma < c)ma = c;
	return ma - mi;

}
int f(int a, int b, int c){
	int mi = a; if (mi > b)mi = b; if (mi > c)mi = c;
	return mi;

}

int A(int y){
	int a = y*W;
	int b = (H - y)*(W / 2);
	int c = (H - y)*(W - W / 2);
	return mymin(a, b, c);
}
int B(int y){
	int a = y*W;
	int b = (H - y)/2*(W );
	int c = (H - y-(H-y)/2)*(W );
	return mymin(a, b, c);
}

int Y(int y){
	int a = A(y);
	int b = B(y);
	return (a < b ? a : b);
}

int C(int x){
	int a = x*H;
	int b = (W - x)*(H / 2);
	int c = (W - x)*(H - H / 2);
	return mymin(a, b, c);
}
int D(int x){
	int a = x*H;
	int b = (W - x) / 2 * (H);
	int c = (W - x - (W - x) / 2)*(H);
	return mymin(a, b, c);
}
int X(int x){
	int a = C(x);
	int b = D(x);
	return (a < b ? a : b);
}


 main(){

	cin >> H >> W;

	int h = H % 3;
	int w = W % 3;

	if (h == 0 || w == 0){ cout << 0 << endl; return 0; }
	int a = H*W, b = H*W, c = H*W;

	a = Y(H / 3);
	b = Y(H / 3 + 1);
	if (h == 2)
		c = Y(H / 3 + 2); else c = H*W;
	int xmin = f(a, b, c);

	a = X(W / 3);
	b = X(W / 3 + 1);
	if (w==2)
	c = X(W / 3 + 2);
	int ymin = f(a, b, c);

	cout << (xmin < ymin ? xmin : ymin) << endl;

	//cerr << "mijissou" << endl;

	return 0;
}

//int mainB(){
//	int H, W;
//	cin >> H >> W;
//
//	REP(j, W + 2)cout << "#"; cout << endl;
//	REP(i, H){
//		cout << "#";
//		REP(j, W){ char c; cin >> c; cout << c; }
//		cout << "#"; cout << endl;
//
//	}
//	REP(j, W + 2)cout << "#"; cout << endl;
//
//	return 0;
//}


//int mainA(){
//	int a[] = { 1, 3, 5, 7, 8, 10, 12 };
//	int b[] = { 4, 6, 9, 11 };
//	int c[] = { 2 };
//
//	int x, y;
//	cin >> x >> y;
//	int xx = -1, yy = -1;
//
//	REP(i, 7){
//		if (x == a[i])xx = 0;
//		if (y == a[i])yy = 0;
//	}
//	REP(i, 4){
//		if (x == b[i])xx = 1;
//		if (y == b[i])yy = 1;
//	}
//	
//		if (x == 2)xx = 2;
//		if (y == 2)yy = 2;
//		cout << ((xx == yy) ? "Yes" : "No") << endl;
//	
//
//	return 0;
//}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    REP(i,N){
        cin >> C[i];
        REP(j,M){
            cin >> A[i][j];
        }
    }
    ll sum = LINF;
    REP(i,1<<N){
        ll tmp = 0;
        vector<ll> t(N);
        REP(j,N){
            if(i >> j & 1){
                tmp += C[j];
                REP(k,M) t[k] += A[j][k];
            }
        }
        bool ok = true;
        REP(k,M) if(t[k] < X) ok = false;
        if(ok) chmin(sum, tmp);
    }
    if(sum == LINF) sum = -1;
    cout << sum << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}


Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
typedef pair<int, int> P;

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

  cin >> N;
  vector<P> A(N);
  int a;
  rep(i, N){
    cin >> a;
    A[i] = P(a, i+1);
  }

  sort(ALL(A));
  rep(i, N){
    cout << A[i].second << ' ';
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 1664
while True :
  m,f,e = map(int, input().split())
  if m == -1 and f == -1 and e == -1 :
    break
  
  t = m + f
  if m == -1 or f == -1 :
    print("F")
    continue

  if t >= 80 :
    print("A")
  elif t >= 65 and t < 80 :
    print("B")
  elif t >= 50 and t < 65 :
    print("C")
  elif t >= 30 and t < 50 :
    if e >= 50 :
      print("C")
    else:
      print("D")
  else :
    print("F")
  
  
  




Measured memory_bytes: 5596
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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

using namespace std;
// cout << setprecision(20) << ans << "\n";

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

  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> l(q), r(q);
  vector<int> cum(n, 0);
  for (int i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
    l[i]--;
    r[i]--;
  }

  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'A' && s[i] == 'C') {
      cum[i] = cum[i - 1] + 1;
    } else {
      cum[i] = cum[i - 1];
    }
  }

  for (int i = 0; i < q; i++) {
    int ans = cum[r[i]] - cum[l[i]];
    cout << ans << "\n";
  }
  // cout << "\n";
  // for (int e : cum) {
  //   cout << e << "\n";
  // }
  return 0;
}


Measured memory_bytes: 4524
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}





char s[1444];

signed main(){
	scanf("%s",s);
	if(s[2]==s[3]&&s[4]==s[5]) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n")
  tmp0 = input[0].split(" ")
  S = tmp0[0].split("")

  var ans = 0;
  for(var i=0;i < S.length - 1;i++){
    if((S[i] === '0' && S[i+1] === '1') || (S[i] === '1' && S[i+1] === '0')){
      S.splice(i,2)
      ans+=2
      i-=2
    }
  }
  console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("0\n")

Measured memory_bytes: 12748
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200010
#define LIMIT2 500010
#define INF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef long double ld;
typedef const void cv;
typedef pair<ll,ll> P;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}
// 二項係数計算
long long 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 PERM(int n,int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return (fac[n] * finv[n-k]) % MOD;
}
void initialize(){
  COMinit();
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  string s;
  
  cin >> n >> m;
  rep(i,n+1){
    ll tmp = COM(n,i);
    tmp = (tmp * PERM(m,i)) % MOD1;
    ll tmp2 = modpow(PERM(m-i,n-i),2,MOD1) % MOD1;
    tmp = (tmp * tmp2) % MOD1;
    tmp = (tmp * (i%2==1 ? -1 : 1));
    if(tmp<0) tmp += MOD1;
    //cout << tmp << endl;
    result += tmp;
    result %= MOD1;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 15548
#include <iostream>
#include <string>

using namespace std;


int main(){
	int i, j, mozisu, kaisu, taisyo, amari, ans, fact;
	ans = 0;

	string str;

	while(cin >> str){
		mozisu = str.size();
		kaisu = mozisu / 2;
		taisyo = 0;
		j = 1;
	
		while(1){
			fact = mozisu;
			fact = fact % (2 * j);

			if(mozisu == 2){
				amari = 0;
				break;
			}

			else if(fact == 1){
				amari = 1;
				break;
			}

			else if(fact == 0){
				amari = 0;
				break;
			}

			j++;
		}

			if(mozisu == 1){
				taisyo = 1;
			}

			else if(amari == 1){
				for(i = 0; i < kaisu; i++){
					if(str[i] == str[mozisu - i - 1]){
						taisyo++;
					}
				}
				if(str[kaisu + 1] == str[(mozisu - 1) - (kaisu - 1)]){
					taisyo++;
				}
			}

			else if(amari == 0){
				for(i = 0; i < kaisu; i++){
					if(str[i] == str[mozisu - i - 1]){
						taisyo++;
					}
				}
			}

			if(amari == 0 && taisyo == kaisu){
				ans++;
			}

			else if(amari == 1 && taisyo == kaisu + 1){
				ans++;
			}

			str.clear();
	}

	cout << ans << endl;
	return 0;
}

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

int main() {
  int R,G,B,N,ct,r,g,b;
  cin >> R >> G >> B >> N;
  ct = 0;
  for(r=0;r*R<=N;r++){
    for(g=0;g*G<=N-r*R;g++){
      ct = ((N-r*R-g*G)%B==0) ? ct+1 : ct;
    }
  }
  cout << ct << endl;
  return 0;
}


Measured memory_bytes: 256