akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3
#coding: utf-8

N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ret = 0
for i in range(N):
    if V[i] > C[i]:
        ret += (V[i]-C[i])

print(ret)


Measured memory_bytes: 2940
let rec find s = 
    match s with
    | [] -> true
    | 'r' :: 'e' :: 'm' :: 'a' :: 'e' :: 'r' :: 'd' :: tail -> find tail
    | 'm' :: 'a' :: 'e' :: 'r' :: 'd' :: tail -> find tail
    | 'r' :: 'e' :: 's' :: 'a' :: 'r' :: 'e' :: tail -> find tail
    | 'e' :: 's' :: 'a' :: 'r' :: 'e' :: tail -> find tail
    | _ -> false

let result flag = if flag then "YES" else "NO"

stdin.ReadLine().ToCharArray()
|> Array.toList
|> List.rev
|> find
|> result
|> printfn "%s"


Measured memory_bytes: 22744
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] c = new int[10][10];
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                c[i][j] = sc.nextInt();
            }
        }
        int[][] A = new int[H][W];
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                A[i][j] = sc.nextInt();
            }
        }

        System.out.println(solve(A, c));

        sc.close();
    }

    static int solve(int[][] A, int[][] c) {
        int H = A.length;
        int W = A[0].length;

        for (int k = 0; k < 10; ++k) {
            for (int i = 0; i < 10; ++i) {
                for (int j = 0; j < 10; ++j) {
                    c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
                }
            }
        }

        int result = 0;
        for (int i = 0; i < H; ++i) {
            for (int j = 0; j < W; ++j) {
                if (A[i][j] != -1) {
                    result += c[A[i][j]][1];
                }
            }
        }

        return result;
    }
}

Measured memory_bytes: 48048
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int A, B;
    cin>>A>>B;
    
    if(A==1&&2<=B&&B<=13){
        cout<<"Alice";
    }
    else if(2<=A&&A<=13&&A>B&&B>1){
        cout<<"Alice";
    }
    else if(A==B){
        cout<<"Draw";
    }
    else{
        cout<<"Bob";
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(int argc, char const *argv[]) {
    long long h, n, a, cnt=0;
    cin >> h >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        cnt += a;
    }
    if(cnt<h){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;

    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
// #include <numeric>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
#define endl '\n'

void solve(){
    int n;
    cin >> n;
    vi a(n);
    f( i , 0 ,n){
        cin >> a[i];
    }
    int temp = 1;
    int count = 0;
    f( i , 0 , n){
        if (temp == a[i]){
            count++;
            temp++;
        }
    }
    if (count == 0){
        cout << -1 << endl;
    }
    else{
        cout << n - count << endl;
    }
}

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

    int t = 1;
    // cin >> t;
    
    while(t--){    
        solve();
    }
}

Measured memory_bytes: 3964
from collections import defaultdict
from functools import reduce
from math import sqrt
def factorint(n):
    d = {}
    for i in range(2, int(sqrt(n))+1):
        c = 0
        q, r = divmod(n, i)
        while not r:
            c += 1
            n = q
            q, r = divmod(n, i)
        if c:
            d[i] = c
    if n != 1:
        d[n] = 1
    return d

n = int(input())
mod = 10**9 + 7
A = defaultdict(lambda:1)
for i in range(1, n+1):
    for k, v in factorint(i).items():
        A[k] += v

print(reduce(lambda x, y: x*y % mod, A.values()) if A else 1)

Measured memory_bytes: 3564
#include <stdio.h>
#include <string.h>
int main(void){
  char S[201]="";
  char str[101]="";
  char str2[101]="";
  int i,j;
  scanf("%s",S);
  for(i=strlen(S)-1;i>=0;i-=2){
    for(j=0;j<i/2;j++){
      str[j] = S[j];
      str2[j] = S[j+i/2];
    }
    if(strcmp(str,str2) == 0){
      printf("%d\n",2*strlen(str));
      break;
    }
    for(j=0;j<101;j++){
      str[j] = '\0';
      str2[j] = '\0';
    }
  }
  return 0;
}

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

bool check(string s){
    string t = s;
    reverse(t.begin() ,t.end());
    return s == t;
}

int main()
{
    string s;
    cin >> s;

    bool ans = true;
    if(!check(s)) ans = false;
    if(!check(s.substr(0, s.size()/2))) ans = false;
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())

using namespace std;


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

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

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> dp(N, INF);
  dp[0] = 0;

  REP(i, N) REP(j, K+1){
    if(i+j >= N) break;
    chmin(dp[i+j], dp[i]+abs(A[i+j]-A[i]));
  }

  cout << dp[N-1] << "\n";

  return 0;
}

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

int main(){
    int N, M, C; cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; i++) cin >> B[i];

    long long cnt = 0;
    for (int i = 0; i < N; i++)
    {
        long long num = 0;
        for (int j = 0; j < M; j++)
        {
            int a; cin >> a;
            num += a * B[j];
        }
        num += C;
        if(num>0) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n,m,maxi=-1,mini=1e9;
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
    {
        int left,right;
        scanf("%d%d",&left,&right);
        maxi=max(maxi,left);
        mini=min(mini,right);
    }
    printf("%d",maxi<=mini?mini-maxi+1:0);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define M 1000000007
#define pi acos(-1)
/*ll power(ll a,ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res*a)%M;
        a = (a*a)%M;
        b = b >> 1;
    }
    return res;
}*/
/*ll modinv(ll a)
{
   return power(a,M - 2); 
}*/
/*vector<ll> primes(ll n)
{
    bool *sieve = new bool[n + 1];
    ll i,j;
    vector<ll> v;
    for(i = 3; i <= n; i+=2)
        sieve[i] = true;
    sieve[2] = true;
    for(i = 3; i*i <= n; i+=2)
    {
        if(sieve[i])
            for(j = i*i; j <= n; j+=i)
                sieve[j] = false;
    }
    if(n >= 2)
    {
        v.pb(2);
        for(i = 3; i <= n; i+=2)
        {
            if(sieve[i])
                v.pb(i);
        }
    }
    return v;
}*/

/*class graph{
public:
    vector<ll> *g;
    ll n;
    graph(ll v)
    {
        n = v + 1;
        g = new vector<ll> [n];
    }
    void addegde(ll f,ll s)
    {
        g[f].pb(s);
        g[s].pb(f);
    }
    void dfs(bool *visited,ll sv)
    {
        visited[sv] = true;
        for(auto x: g[sv])
        {
            if(!visited[x])
            {
                dfs(visited,x);
            }
        }
    }
    void bfs(ll sv){
       queue<ll> q;
       bool visited[n] = {};
       q.push(sv);
       visited[sv] = true;
       while(!q.empty())
       {
           ll node = q.front();
           q.pop();
           for(auto x : g[node])
           {
               if(!visited[x])
               {
                   visited[x] = true;
                   q.push(x);
               }
           }
       }
    }
};*/
int main()
{
    fast;
    map<string,ll> m;
    ll i,n;
    cin >> n;
    for(i = 0; i < n; i++)
    {
        string temp;
        cin >> temp;
        m[temp]++;
    }
    ll count = 0;
    vector<string> v;
    for(auto x : m)
    {
        if(x.second >= count)
            count = x.second;
    }
    for(auto x : m)
    {
        if(x.second == count)
            v.pb(x.first);
    }
    sort(v.begin(),v.end());
    for(auto x : v)
        cout<<x<<endl;
    return 0;
}



Measured memory_bytes: 25584
// Maximize the Formula
#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<int>vec(3);
    for(int i=0;i<3;i++)cin>>vec.at(i);
    sort(vec.begin(),vec.end());

    //for(int i=0;i<3;i++)cout<<vec.at(i)<<endl;
    cout<<(10*vec.at(2)+vec.at(1))+vec.at(0)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int A[32]={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<<A[K-1]<<endl;
}

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;

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

int f(int x) {
  int res = 0;
  while (x%2 == 0) {
    x /= 2;
    res++;
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  // a -> a'
  rep(i,n) {
    if (a[i]%2 == 1) {
      cout << 0 << endl;
      return 0;
    }
    a[i] /= 2;
  }

  // a' -> a''
  int t = f(a[0]);
  rep(i,n) {
    if (f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t; // a[i] /= 2^t
  }
  m >>= t;

  ll l = 1;
  rep(i,n) {
    l = lcm(l, a[i]);
    if (l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  m /= l;
  int ans = (m+1)/2;
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int a,b,c,d,e,f,g;
    cin >> a;
    cin>> b;
    cin >> c;
    d=(a-b);
    e=(d/c);
    f=(e*c);
    g=(d-f);
    cout << g<< endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    map<int64_t,int> mp;
    while(N--) {
        int A;
        cin >> A;
        mp[A]++;
    }

    int64_t ans = 0;
    vector<int64_t> tmp;
    for(auto e: mp) {
        if(e.second >= 4) ans = max(ans, e.first*e.first);
        if(e.second >= 2) tmp.emplace_back(e.first);
    }

    if(tmp.size() >= 2) {
        sort(tmp.rbegin(), tmp.rend());
        ans = max(ans, tmp[0] * tmp[1]);
    }

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


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main() {
  string s; cin>>s;
  int a=0;
  rep(i,s.size()){
    int l;
    rep(j,s.size()-i){
      bool f=true;
      string t=s.substr(i,j+1);
      l=t.size();
      rep(k,l) if(t[k]!='A'&&t[k]!='C'&&t[k]!='G'&&t[k]!='T'){f=false; break;}
      if(f) a=max(a,l);
    }
  }
  cout<<a;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

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

Measured memory_bytes: 256
a,b,K=map(int,input().split())
C=998244353
fac=[0]*a #階乗 fac[i]=i!
finv=[0]*a# i!の逆元
inv=[0]*a
N=a-1
def com_init():
	fac[0],finv[0]=1,1
	if a<2:return
	fac[1],finv[1]=1,1
	inv[1]=1
	for i in range(2,N+1):
		fac[i]=fac[i-1]*i%C
		inv[i]=C-inv[C%i]*(C//i)%C#ある数の逆元
		finv[i]=finv[i-1]*inv[i]%C
def com(m,k):
	if m<k: return 0
	elif m<0 or k<0:return 0
	else:
		return fac[m]*(finv[k]*finv[m-k]%C)%C
com_init()
bfac=[0]*a
bfac[0]=1
for i in range(1,a):
  bfac[i]=bfac[i-1]*(b-1) %C
ans=0

for i in range(K+1):
  ans+= com(a-1,i)*bfac[a-1-i]%C
print(ans*b%C)

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mxn = 1e6 + 5;
int n;
char s[mxn];
int bg[mxn], ln[mxn];
int a[mxn], b[mxn];
int id[mxn];

bool comp(int x, int y) {
	return min(-a[x], -a[x] + b[x] - a[y]) > min(-a[y], -a[y] + b[y] - a[x]);
}

void NO() {
	puts("No");
	exit(0);
}

int main() {
	scanf("%d", &n);
	rep(i, n) {
		scanf("%s", s + bg[i]);
		ln[i] = strlen(s + bg[i]);
		rep(j, ln[i]) {
			if (s[bg[i] + j] == '(') {
				++ b[i];
			} else {
				if (b[i]) -- b[i];
				else ++ a[i];
			}
		}
		bg[i + 1] = bg[i] + ln[i];
		id[i] = i;
	}
	sort(id, id + n, comp);
	int A = 0;
	rep(xx, n) {
		int i = id[xx];
		A -= a[i];
		if (A < 0) NO();
		A += b[i];
	}
	if (A != 0) NO();
	puts("Yes");
	return 0;
}


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

int main()
{
    int input_time_sec = 0;
    cin >> input_time_sec;

    int time_hour = input_time_sec / 3600;
    int time_remaining_sec = input_time_sec % 3600;

    int time_min = time_remaining_sec / 60;
    int time_sec = time_remaining_sec % 60;

    cout << time_hour << ":" << time_min << ":" << time_sec << endl;
    
    return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>

int main(void) {

	int N;
	int K;
	char S[112];

	scanf("%d %d", &N, &K);
    scanf("%s",S);

		if (S[K - 1] == 'A') {
          S[K - 1] = 'a';
		}
		else if (S[K - 1] == 'B') {
          S[K - 1] = 'b';
		}
		else if (S[K - 1] == 'C') {
          S[K - 1] = 'c';
		}
  
  printf("%s",S);

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int H, W, A, B;
	cin >> H >> W >> A >> B;
	vector<vector<int>>ans(H, vector<int>(W, 0));

	for (int i = 0; i < B; i++) {
		for (int j = 0; j < A; j++){
			ans[i][j] = 1;
		}
	}
	for (int i = B; i < H; i++) {
		for (int j = A; j < W; j++) {
			ans[i][j] = 1;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
  int a, b, c, d;
  cin >> a >> b;
  c = a % 2;
  d = b % 2;
  if(d == 0 || c == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
import copy
N=int(input())
p=[int(i) for i in input().rstrip().split()]
p_c=copy.deepcopy(p)
p_c.sort()

cnt=0
for i in range(len(p)):
  if p[i]!=p_c[i]:
    cnt+=1
  else:
    continue


if cnt==2 or cnt==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3444
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// namespace
using namespace std;
// type
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
// input
#define INIT              ({ ios::sync_with_stdio(false); cin.tie(0); })
#define VAR(type, ...)    type __VA_ARGS__; var_scan(__VA_ARGS__);
template<typename T>
static void var_scan(T& t)
{
    cin >> t;
}
template<typename T, typename... R>
static void var_scan(T& t, R&... rest)
{
    cin >> t;
    var_scan(rest...);
}
// output
#define OUT(var)          cout << (var)
#define SPC               cout << ' '
#define TAB               cout << '\t'
#define BR                cout << '\n'
#define ENDL              cout << endl
#define FLUSH             cout << flush
// debug
#ifdef DEBUG
#define EPRINTF(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#define DUMP(var)         cerr << #var << '\t' << (var) << '\n'
#define DUMPITERABLE(i) do {                            \
        cerr << #i << '\t';                             \
        for (const auto& it : i) { cerr << it << ' '; } \
        cerr << '\n';                                   \
} while (0)
#define DUMPITERABLE2(i2) do {                          \
        cerr << #i2 << '\t';                            \
        for (const auto& it : i2) {                     \
            for (const auto& it2: it) {                 \
                cerr << it2 << ' ';                     \
            }                                           \
        }                                               \
        cerr << '\n';                                   \
} while (0)
#else
#define EPRINTF(fmt, ...)
#define DUMP(var)
#define DUMPITERABLE(i)
#define DUMPITERABLE2(i)
#endif
// util
// [l, r)
#define REP(i, n)       for (int i = 0; i < (n); i++)
#define RREP(i, n)      for (int i = (n)-1; i >= 0; i--)
#define FOR(i, l, r)    for (int i = (l); i < (r); i++)
#define RFOR(i, r, l)   for (int i = (r)-1; i >= (l); i--)
#define REPLL(i, n)     for (ll i = 0; i < (n); i++)
#define RREPLL(i, n)    for (ll i = (n)-1; i >= 0; i--)
#define FORLL(i, l, r)  for (ll i = (l); i < (r); i++)
#define RFORLL(i, r, l) for (ll i = (r)-1; i >= (l); i--)

int main(void)
{
    INIT;
    VAR(int, N);
    pair<int, int> D;
    int count = 0;
    REP(i, N) {
        cin >> D.first >> D.second;
        if (D.first == D.second)
            count++;
        else
            count = 0;
        if (count == 3) {
            OUT("Yes");
            goto end;
        }
    }
    OUT("No");
end:
    ENDL;
    return 0;
}


Measured memory_bytes: 3660
n = int(input())
l_i_1 = 2
l_i_2 = 1
if n >= 2:
  while n>=2:
    l_i = l_i_1 + l_i_2
    n -= 1
    l_i_1= l_i_2
    l_i_2 = l_i
  print(l_i)
elif n==1:
  print(1)
else:
  print(2)

Measured memory_bytes: 3060
import collections

N = int(input())
A,B = [], []
for i,v in enumerate(input().split()):
    if i%2==0:
        A.append(int(v))
    else:
        B.append((int(v)))

ca = collections.Counter(A).most_common(2)
cb = collections.Counter(B).most_common(2)
if len(ca)<2:
    ca.append((-1, 0))
if len(cb)<2:
    cb.append((-2, 0))

ans = 10**6
for v1,c1 in ca:
    for v2,c2 in cb:
        if v1!=v2:
            ans = min(ans, N-c1-c2)
print(ans)


Measured memory_bytes: 15332
#!/bin/bash
':' /*
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro node:5.2-slim \
   /bin/bash -c "node /vo/$(basename $0) < /vo/g.inp"
exit $?
*/
'use strict';

let main = function(input) {
   let arr = input[0].split(' ');
   let obj = {};
   obj = arr.reduce((x, y)=>{
      x[y] = 1;
      return x;
   }, {});
   let ans = "No";
   if(Object.keys(obj).length==2) ans = "Yes";
   return ans;
}

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf-8').trim().split('\n')));

Measured memory_bytes: 22964
#include<bits/stdc++.h>
using namespace std;
struct compare
{
    bool operator()(const string& first, const string& second)
    {
        return first.size()>second.size();
    }
};
void solve()
{
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Rainy") cout<<"Sunny"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
}

int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>

using std::string;

class Proc {
private:
    const string m_name;
    int m_time;

public:
    Proc(string name, int time)
        : m_name(name), m_time(time) {}

    string name() const { return m_name; }

    int time() const { return m_time; }

    Proc& operator-=(int time)
    {
        m_time -= time;
        return *this;
    }

    bool operator<=(int time)
    {
        return ((m_time <= time)? true: false);
    }
};

int main()
{
    int procs_num, quan;
    std::cin >> procs_num >> quan;

    std::queue<Proc> procs;
    for (auto i = 0; i < procs_num; i++) {
        string name;
        int time;
        std::cin >> name >> time;
        Proc in(name, time);
        procs.push(in);
    }

    int time_sum = 0;
    while (procs.size() > 0) {
        if (procs.front() <= quan) {
            time_sum += procs.front().time();
            std::cout << procs.front().name() << " "
                      << time_sum << std::endl;
            procs.pop();
        } else {
            time_sum += quan;
            procs.front() -= quan;
            procs.push(procs.front());
            procs.pop();
        }
    }

    return 0;
}

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

int main(){
	int N, K, d;
	cin >> N >> K;
	vector<vector<int>> A(K);

	rep(i, K){
		cin >> d;
		rep(j, d){
			int hito;
			cin >> hito;
			A.at(i).push_back(hito);
		}
	}

	set<int> array;
	for(auto i : A){
		for(auto j : i){
			array.insert(j);
		}
	}

	cout << (N - array.size()) << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, s, d, f;
    cin >> a >> s >> d >> f;
    
    bool j = abs(a - d) <= f || (abs(a-s) <= f && abs(s-d) <= f);
    
    cout << (j ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  long long  N, M; cin >> N >> M;
	if(M < N) { long long t = N; N = M; M = t; }
	long long ans;
	if(N == 1) {
		if(M == 1) {
			ans = 1;
		} else {
			ans = M-2;
		}
	} else {
		ans = (N-2) * (M-2);
  }
	cout << ans << endl;
  return 0;
}


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

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

Measured memory_bytes: 256
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

ll calc(ll n) {
  return n * (n - 1) / 2;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string a;
  cin >> a;

  ll n = a.length(), ans = calc(n) + 1;
  map<int, ll> m;
  rep(i, n) m[a[i] - 'a']++;
  rep(i, 26) ans -= calc(m[i]);
  cout << ans << '\n';






  
  return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

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

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int lcs(string a, string b, int x, int y) {
    if(x == 0 || y == 0) {
        return 0;
    }
    if(a[x-1] == b[y-1]) {
        return 1 + lcs(a, b, x-1, y-1);
    }
    return max(lcs(a, b, x-1, y), lcs(a, b, x, y-1));
}
int main() {
    IOS
    string a, b;
    getline(cin >> ws, a);
    getline(cin >> ws, b);
    vvi dp(a.size()+1, vi(b.size()+1));
    int x = a.size(), y = b.size();
    Fori(i, 1, x+1) {
        Fori(j, 1, y+1) {
            if(a[i-1] == b[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string res = "";
    int i = a.size(),j = b.size();
    while(i > 0 && j > 0) {
        if(a[i-1] == b[j-1]) {
            res += a[i-1];
            i--;j--;
        } else if(dp[i-1][j] > dp[i][j-1]) {
            i--;
        } else {
            j--;
        }
    }
    for(int i=0; i< res.size() / 2; i++) {
        swap(res[i], res[res.size() - i -1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 38580
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    ans += min (x, k-x);
  }
  cout << ans * 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
#define fst first
#define snd second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

int N, M;
char A[100][100+1];
int D[100][100];

int main() {
    scanf("%d%d", &N, &M);
    for(int i = 0; i < N; i++) {
        scanf("%s", A[i]);
    }
    D[0][0] = A[0][0] == '#';
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < M; j++) {
            if(i+j==0) continue;
            D[i][j] = 1e9;
            if(i > 0) {
                int v = D[i-1][j] + (A[i-1][j] == '.' && A[i][j] == '#');
                D[i][j] = min(D[i][j], v);
            }
            if(j > 0) {
                int v = D[i][j-1] + (A[i][j-1] == '.' && A[i][j] == '#');
                D[i][j] = min(D[i][j], v);
            }
        }
    }
    printf("%d\n", D[N-1][M-1]);
    return 0;
}

Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)[:X]
q = sorted(list(map(int, input().split())), reverse=True)[:Y]
r = list(map(int, input().split()))
ans = sum(sorted(p + q + r, reverse=True)[:X + Y])
print(ans)

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

#define tc(t) int t; cin>>t; while(t--)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b, c;
    cin >> a >> b >> c;
    if (a + b >= c) cout << "Yes" << endl;
    else cout << "No" << endl;
}






Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }

const int MOD = 1000000007;
const int INF = 1 << 30;

int dp[105][4][2];

int main() {
    string S;
    int K;
    cin >> S >> K;

    int n = S.size();
    
    dp[0][0][0] = 1;

    rep(i, n) {
        rep(j, 4) {
            rep(k, 2) {
                int nd = S[i] - '0';
                rep(d, 10) {
                    int ni = i+1, nj = j, nk = k;
                    if (d > 0) nj++;
                    if (nj > K) continue;
                    if (k == 0) {
                        if (d > nd) continue;
                        if (d < nd) nk = 1;
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }

    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
    return 0;
}


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

const int maxn = 100000;
typedef long long ll;

int n;
ll a[maxn];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    a[i] = x;
  }
  sort(a, a + n);
  int mid = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (i) {
      a[i] += a[i - 1];
    }
    if (a[i] * 2 < a[i + 1]) {
      mid = i + 1;
    }
  }
  printf("%d\n", n - mid);
  return 0;
}


Measured memory_bytes: 896
def gcd(a, b)
  b==0 ? a : gcd(b, a % b)
end

N = gets.to_i
as = gets.split.map(&:to_i)

from_left = [as[0]]
from_right = [as[-1]]

(N - 1).times do |i|
  from_left[i+1] = gcd(from_left[i], as[i+1])
  from_right[i+1] = gcd(from_right[i], as[-2-i])
end

max = [from_right[N-2], from_left[N-2]].max
1.upto(N-2) do |i|
  gcd_without_i = gcd(from_left[i-1], from_right[N-i-2])
  max = gcd_without_i if gcd_without_i > max
end

puts max

Measured memory_bytes: 10300
N = int(input())
A = [int(input()) for i in range(N)]
S = sum(A)
MOD = 998244353

ans = pow(3,N,MOD)

dp = [[0]*(S+1) for i in range(N+1)]
dp[0][0] = 1
dp2 = [[0]*(S+1) for i in range(N+1)]
dp2[0][0] = 1

suma = 0
for i,a in enumerate(A):
    for j in range(suma + 1):
        dp[i+1][j] += dp[i][j]*2
        dp[i+1][j] %= MOD
        dp[i+1][j+a] += dp[i][j]
        dp[i+1][j+a] %= MOD
        dp2[i+1][j] += dp2[i][j]
        dp2[i+1][j] %= MOD
        dp2[i+1][j+a] += dp2[i][j]
        dp2[i+1][j+a] %= MOD
    suma += a

ans -= sum(dp[-1][(S+1)//2:])*3
ans %= MOD

if S%2==0:
    tmp = dp2[-1][S//2]*3
    ans += tmp
    ans %= MOD

print(ans)

Measured memory_bytes: 458520
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n,p;cin>>n>>p;
    string s;cin>>s;
    ll ans=(ll)0;
    if(p!=2&&p!=5){
        vll r(p);r[0]++;
        int sum=0,res=1,tmp;
        for(int i=n-1;i>=0;i--){
            tmp=s[i]-'0';
            tmp*=res;tmp%=p;
            sum+=tmp;sum%=p;
            r[sum]++;
            res*=10;res%=p;
        }
        rep(i,p)ans+=r[i]*(r[i]-(ll)1)/2;
    }
    else{
        int tmp;
        if(p==2){
            rep(i,n){
                tmp=s[i]-'0';
                if(tmp%2==0)ans+=(ll)(i+1);
            }
        }
        else{
            rep(i,n){
                tmp=s[i]-'0';
                if(tmp==0||tmp==5)ans+=(ll)(i+1);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3704
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
for idx in range(len(B)):
	eliminatenow = min(A[idx], B[idx])
	A[idx] -= eliminatenow
	eliminatenext = min(A[idx+1], B[idx] - eliminatenow)
	A[idx+1] -= eliminatenext
	count += eliminatenow + eliminatenext
print(count)

Measured memory_bytes: 18624
#include <stdio.h>

int main()
{
	char s[5];
	for(int i=0;i<3;i++){
		scanf("%s",&s[i]);
		}
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){printf("3");}else
	if(s[0]=='R'&&s[1]=='R'){printf("2");}else
	if(s[1]=='R'&&s[2]=='R'){printf("2");}else
	if(s[0]=='R'||s[1]=='R'||s[2]=='R'){printf("1");}else printf("0");
	
	return 0;
}


Measured memory_bytes: 1644
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		String ans = "No";
		for (int i=1; i<=9; i++) {
			for (int j=1; j<=9; j++) {
				if (n == i*j) {
					ans = "Yes";
					break;
				}
			}
		}
		System.out.println(ans);
	}
}





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

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

int main(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<(x-z)/(y+z)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main(){
    int A , B;
    cin>>A>>B;
    if(10<=A || 10<=B){
        cout<<-1<<endl;
    }
    else{
        cout<<A*B<<endl;
    }

}

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

int main(){
	int n,k,input,t,ans=0;cin>>n>>k;
  	vector<int> a(n);
  	map<int,int> mp;
  
 	for(int i=0;i<n;i++){
    	cin>>input;
      	a[i]=input;
      	mp[input]=0;
    }
  	
  for(int i=0;i<n;i++){
      	mp[a[i]]++;
    }
  
  //何種る減らす必要があるか？（0だったら終了）
  t=mp.size()-k;
  if(t<=0){ cout<<0<<endl; return 0;}
  
  //mapのsecondをvector bに移し、sort
  vector<int> b(mp.size(),0);
  int w=0;
  for(auto itr=mp.begin();itr!=mp.end();++itr){
  	b[w++]=itr->second;
  }
  sort(b.begin(),b.end());
  for(int i=0;i<t;i++){
  	ans+=b[i];
  }
  cout<<ans<<endl;  	
}    

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

using namespace std;

int main(){
int n;
  cin>>n;
  int d= -1;
  vector<int> a(n);
  for(int i =0; i<n;i++) cin>>a[i];
  for(int i =0 ;i <n ;i++){
  for(int j = i+1; j< n ; j++){
  d  = max(abs(a[i]-a[j]),d);
  	}
  }
cout<<d;

return 0;
}


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


int main()
{
	string s;
	int a=0, b=0;
	cin >> s;
	for(int i=0; i<3; i++)
	{
		if(s[i] == 'R')
		{
			a++;
			b=a;
		}
		else if(s[i] != 'R')
		{
			a=0;
		}
	}
	cout << b;
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

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

  vector<int>low(N),high(N);
  for(int i=N-1;i>=0;i--){
    if(i==N-1){
      low[i]=A[i];
      high[i]=A[i];
    }
    else{
      low[i]=low[i+1]/2+low[i+1]%2+A[i];
      high[i]=high[i+1]+A[i];
    }
  }

  ll ans=0;
  for(int i=0;i<N;i++){
    if(i!=0)high[i]=min(2*(high[i-1]-A[i-1]),high[i]);
    int POW;
    if(i>=32)POW=INF;
    else POW=pow(2,i);
    high[i]=min(high[i],POW);
    ans+=high[i];
  }

  for(int i=0;i<N;i++){
    if(high[i]<low[i]){
      cout<<-1<<endl;
      return 0;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5588
import java.util.ArrayList;
import java.util.Arrays;
//import java.util.Comparator;
import java.util.Scanner;

public class Main {
	
	Main(){}
	
	public void calc() {
		Scanner sc = new Scanner(System.in);
		String[] firstLine = sc.nextLine().split(" ");
		final int n = Integer.parseInt(firstLine[0]);
		final int m = Integer.parseInt(firstLine[1]);
		
		final int inf = 100000000;
		int[] dp = new int[5000];
		
		for(int i = 0; i < 5000 ; i++) {
			dp[i] = inf;
		}
		
		ArrayList<Key> keyList = new ArrayList<>();		
		for(int i = 0; i < m; i++) {
			String[] keyInfo = sc.nextLine().split(" ");
			int keyValue = Integer.parseInt(keyInfo[0]);
			String[] lockableTreasures = sc.nextLine().split(" ");
			keyList.add(new Key(keyValue, lockableTreasures));
		}
		
		sc.close();
		
		
//		Comparator<Key> comparator = Comparator.comparing(Key::getPrice);
//		keyList.sort(comparator);
		
		int lockedItemNum = 0;
		int[] lockedArr = new int[n];
		int priceSum = 0;
        dp[0] = 0;
		
		for(int i = 0; i < m; i++) {
//			String[] lockItems = keyList.get(i).lockItems;
//			boolean isBuy = false;
//			for(String item : lockItems) {
//				int itemNo = Integer.parseInt(item);
//				if(lockedArr[itemNo - 1] == 0 ) {
//					lockedArr[itemNo - 1] = 1;
//					lockedItemNum++;
//					isBuy = true;
//				}
//			}
//			if(isBuy) {
//				priceSum += keyList.get(i).getPrice();
//			}
//			if(lockedItemNum == n) {
//				break;
//			}
			
			int now = 0;
			String[] lockItems = keyList.get(i).lockItems;
			for(String item : lockItems) {
				int itemNo = Integer.parseInt(item);
				now |= (1 << (itemNo - 1));
			}
			
			for(int bit = 0 ; bit < (1 << n) ; bit++) {
				if(dp[bit | now] > dp[bit] + keyList.get(i).getPrice()) {
					dp[bit | now] = dp[bit] + keyList.get(i).getPrice();
				}
			}
		}
		
//		if(lockedItemNum < n) {
//			System.out.println(-1);
//		}else {
//			System.out.println(priceSum);
//		}
		
		if(dp[(1 << n) - 1] == inf) {
			dp[(1 << n) - 1] = -1; 
		}
		System.out.println(dp[(1 << n) - 1]);
	}

	public static void main(String[] args) {
		Main main = new Main();
		main.calc();
	}
	
	public class Key{
		int price;
		String[] lockItems;
		
		public Key(int price, String[] lockItems) {
			this.price = price;
			this.lockItems = lockItems;
		}
		
		public int getPrice() {
			return this.price;
		}
		
		public String getLockItemStr() {
			return Arrays.toString(lockItems);
		}
	}
}


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

int n;
int t[16][17];
set<int> s;
set<int>::iterator it,it2;
bool use[16];
int two[] = {0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768};
int dp[65536];

int rec(){
  int now,tmp,res,time;
  now = 0;

  if(!s.size())return 0;

  for(it = s.begin();it != s.end();it++)now += two[*it];
  if(dp[now]>=0)return dp[now];

  res = 100000000;
  for(it = s.begin();it != s.end();it++){
    use[*it] = false;
    tmp = *it;
    s.erase(it++);
    time = t[tmp-1][0];
    for(it2 = s.begin();it2 != s.end();it2++)time = min(time,t[tmp-1][*it2]);
    res = min(res,rec()+time);
    s.insert(tmp);
    it = s.find(tmp);
    use[tmp] = true;
  }
  
  dp[now] = res;
  return res;
}

int main(){
  
  while(1){
    cin >> n;
    if(!n)break;

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

    for(int i=0;i<two[n]*2;i++)dp[i] = -1;
    dp[0] = 0;

    s.clear();
    for(int i=1;i<n+1;i++)s.insert(i);

    for(int i=0;i<n;i++)use[i] = true;

    cout << rec() << endl;    
  }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,aa,bb;
cin>>a>>b>>c;
while(c){
if(a%2==1) a--;
  b+=a/2;
  a/=2;
  c--;
  if(c==0) break;
if(b%2==1) b--;
a+=b/2;
b/=2;
  c--;
}
cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
 
#define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to)
#define dbg(...) fprintf(stderr, __VA_ARGS__)
#define File(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)
#define fi first
#define se second
#define pb push_back
 
template<typename A, typename B> inline bool smax(A &a, const B &b) {return a < b ? a = b , 1 : 0;}
template<typename A, typename B> inline bool smin(A &a, const B &b) {return b < a ? a = b , 1 : 0;}
 
typedef long long ll; typedef unsigned long long ull; typedef std::pair<int, int> pii;
 
template<typename I> inline void read(I &x) {
	int f = 0, c;
	while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0;
	x = c & 15;
	while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
	f ? x = -x : 0;
}

const int N = 2e5 + 7;

int n, tp, mid;
int a[N];
struct Pair { int l, r, v; } s[N];

inline bool qadd(int x) {
	while (tp && s[tp].l > x) --tp;
	assert(tp);
	s[tp].r = x;
	if (s[tp].v != mid) {
		if (x == s[tp].l) ++s[tp].v;
		else ++tp, --s[tp - 1].r, s[tp] = (Pair){ x, x, s[tp - 1].v + 1 };
	} else {
//		dbg("* mid = %d, x = %d, tp = %d\n", mid, x, tp);
		if (tp == 1) return 1;
//		if (s[tp - 1].l == s[tp - 1].r) ++s[--tp].v;
//		else s[tp] = (Pair){ s[tp - 1].r, s[tp - 1].r, s[tp - 1].v + 1 }, --s[tp - 1].r;
		qadd(s[--tp].r);
		++tp, s[tp] = (Pair){ s[tp - 1].r + 1, x, 1 };
	}
	return 0;
}

inline bool check() {
	tp = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] <= a[i - 1]) { if (qadd(a[i])) return 0; }
		else s[++tp] = (Pair){ a[i - 1] + 1, a[i], 1 };
		while (tp > 1 && s[tp].v == s[tp - 1].v) s[tp - 1].r = s[tp].r, --tp;
		assert(s[tp].r == a[i]);
	}
	return 1;
}

inline void work() {
	int l = 1, r = n;
	while (l < r) {
		mid = (l + r) >> 1;
		if (check()) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", l);
}

inline void init() {
	read(n);
	for (int i = 1; i <= n; ++i) read(a[i]);
}

int main() {
	#ifdef hzhkk
	freopen("hkk.in", "r", stdin);
	#endif
	init();
	work();
	fclose(stdin), fclose(stdout);
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int SURP = 1000000007;

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

	int ret = 0;

	FOR(i,1,N){
		string s1 = s.substr(0,i);
		string s2 = s.substr(i,N);
		int tmp = 0;
		vector<char> c1;
		FOR(j,0,i){
			auto result = find(c1.begin(), c1.end(), s1[j]);
			if (result == c1.end()) {
				c1.push_back(s1[j]);
				FOR(k,0,s2.length()){
					if(s1[j] == s2[k]) {
						tmp++;
						break;
					}
				}
			}
		}
		if (tmp > ret) ret = tmp;
	}
	cout << ret << endl;
	return 0;
}


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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int d,t,s;
  cin >> d >> t >> s;

  if(d<=t*s)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3648