akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
max_n = A[0]
min_n = A[0]
for i in range(N):
    if max_n < A[i]:
        max_n = A[i]
    if min_n > A[i]:
        min_n = A[i]
print(max_n - min_n)

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


int main() 
{ 

string s,s1;
cin>>s>>s1;
		char  key[s.length()+1] ;
		 strcpy(key, s.c_str());
		 char flagment[s1.length()+1] ;
		 strcpy(flagment, s1.c_str());
		 
		 int n = s.length()-s1.length();
		
		for ( int i=n; i>= 0 ;i--) { //Search from behind S
			
			bool temp = true ;
			 for ( int j= 0 ;j<s1.length(); j++) {
				 if (key[i+j]!= '?' && key[i+j]!=flagment[j]) {
					temp = false ;
					 break ;
				}
			}
			
			if (temp == true ){
				 for ( int j= 0 ;j<s1.length(); j++) {
					key[i+j] = flagment[j];
				}
				for ( int j= 0 ;j<s.length(); j++) {
				
					cout<<(key[j]== '?' ? 'a' :key[j]);
				}

				return 0;
			}
			
		}
		
	cout<< "UNRESTORABLE"<<endl;
		
}

Measured memory_bytes: 3628
from math import gcd
k = int(input())
sum = 0
lst = []
for a in range(1,k+1):
  for b in range(1,k+1):
      g = gcd(a,b)
      lst.append(g)
for c in range(1,k+1):
    for i in range(len(lst)):
        sum += gcd(lst[i],c)     
print(sum)      

Measured memory_bytes: 9224
def divisors(n, reverse=False):
    table = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            table.append(i)
            if i != n // i:
                table.append(n // i)
    table.sort(reverse=reverse)
    return table

x = int(input())
for div in divisors(x, reverse=True):
    b = -(div//2)
    a = div + b
    exist = False
    i = 0
    while True:
        val = (a+i)**5 - (b+i)**5
        if val == x:
            exist = True
            break
        if val > x:
            break
        i += 1
    if exist:
        print(a+i, b+i)
        break


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,i,sum=0;
    cin>>a;
    for(i=1;i<=a;i++)
    {
    	int len=0,n=i;
    	while(n>0)
    	{
    		n=n/10;
    		len++;
		}
    	if(len%2==1)
    	sum++;
    }
	cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define  ll  long long
int main()
{
    ft
    ll i,j,n,m,a[60],s=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            s+=(a[i]*a[j]);
        }
    }
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
inline size_t func(size_t x) {
    size_t sum = 0;
    while (0 < x) {
        sum += x % 10;
        x /= 10;
    }
    return sum;
}

int main() {
    size_t N;
    cin >> N;
    size_t end = (N/2 + 1);
    
    size_t min = N;
    size_t temp = 0;
    for (size_t i = 1; i < end; i++) {
        temp = func(i) + func(N - i);
        if (temp < min) min = temp;
    }
    cout << min;

    return 0;

}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    cin >> n;
    vector<i64> t(n + 1);
    t[0] = 2;
    t[1] = 1;
    for(int i = 2; i <= n; ++i)
        t[i] = t[i - 1] + t[i - 2];
    cout << t.back() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        ll n;
        cin>>n;
        vi a(n);
        for(auto &x:a)cin>>x;
        ll ans=0;
        for(int i=0;i<n;i++)
        {
            ans+=a[i]/2;
            a[i]%=2;
            if(a[i]&&i!=n-1&&a[i+1])ans++,a[i+1]--;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1024
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2];
	auto arr = [A, B, C];
	arr.sort!"a > b"();
	writeln(arr[0] * 10 + arr[1] + arr[2]);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define SZ(c) int(c.size())
#define pb push_back
#define loop(i,start,n)  for(int i=start;i<n;i++)
#define rloop(i,start,n)  for(int i=start;i>n;i--)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
const ll inf = 2e9+3;

void solve(){
    int tc=1 ;
    //cin >> tc;
    while(tc--) {
        ll n,m,k,res=0;
        cin >> n >> m >> k;
        vll va(n+1) , vb(m+1);
        ll A=0, B=0;
        loop(i,1,n+1) { cin >> va[i]; va[i] = va[i]+va[i-1]; }
        loop(i,1,m+1) { cin >> vb[i]; vb[i] = vb[i]+vb[i-1]; }
        ll b = m;
        loop(i,0,n+1){
            if(va[i]>k) break;
            while(vb[b] > k-va[i]) b-=1;
            res = max(res,i+b);
        }
        cout << res;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 
#define pb push_back
#define sz(a) (int)a.size()

void solve(){
	int n;
	cin >> n;
	int h[n];
	for(int i=0;i<n;++i) cin >> h[i];
	vi dp(n,0);
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;++i){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] <<  nl;
}

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

	solve();
	
	return 0;
}




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

int main() {				
  char op;					// *constarint*
  int A,B,ans;			    // 1 <= A,B <= 10＾9
  					        // op i s'+' or '-'
  cin >> A >> op >> B;
 if(op == '+'){
   ans = A + B;
 }else if(op == '-'){
   ans = A - B;
 }
  
 cout << ans << endl;
  
}


Measured memory_bytes: 3632
# your code goes here
#linear
n=int(input())
S=[int(i) for i in input().split()]
q=int(input())
T=[int(i) for i in input().split()]
c=0
for i in range(q):
    j=0
    while j<n and T[i]!=S[j]:
        j+=1
    if j<n:
        c+=1
print(c)

Measured memory_bytes: 8620
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    while(true){
        double a,b,c,d; cin >> a >> b >> c >> d;
        if(a==0 && b==0 && c==0 && d==0) break;
        cout << max(0ll,(ll)ceil(((c-a/b)*b)/d)) << "\n";
    }
}


Measured memory_bytes: 3280
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	int a, b, ans, n;
	cin >> s;
	n = s.length();
	for (a = 0; s[a] != 'A'; a++);
	for (b = s.length() - 1; s[b] != 'Z'; b--);
	ans = b + 1 - a;
	cout << ans;

	return 0;
}



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

using namespace std;

bool query(int x, int y){
	if(x == y) return true;
	cout << "? " << x << ' ' << y << endl;
	char ans;
	cin >> ans;
	return (ans == 'Y');
}

int main(){
	int A, B;
	cin >> A >> B;
	if(A <= B){
		cout << "Impossible" << endl;
		return 0;
	}
	stack <int> S;
	for(int i = 0; i < A + B; ++i){
		if(S.empty() || query(S.top(), i)){
			S.push(i);
		}
		else{
			S.pop();
		}
	}
	int honest = S.top();
	vector <int> res;
	for(int i = 0; i < A + B; ++i){
		res.push_back(query(honest, i));
	}
	cout << "! ";
	for(auto i : res) cout << i;
	cout << endl;
	return 0;
}


Measured memory_bytes: 724
#include <stdio.h>
int main(void)
{
        int a=0,b=0,m,n,i,j=0,k,l=0;

        scanf("%d",&n);
        
                while(n>499){
                        n=n-500;
                        a++;
        }

        while(n>4){
                        n=n-5;
                        b++;
        }
       // printf("%d %d\n",a,b);
                printf("%d\n",1000*a+5*b);
                return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

// 解答1
int hoge(void){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());


  vector<pair<ll, ll>> b(m);
  for (int i = 0; i < m; i++){
    cin >> b[i].second >> b[i].first;
  }
  sort(b.begin(), b.end());

  int id_m = m - 1;
  for (int i = 0; i < n; i++){
    if (a[i] < b[id_m].first){
      a[i] = b[id_m].first;
      b[id_m].second--;
    }
    else 
      break;

    if (b[id_m].second == 0)
      id_m--;
    if (id_m < 0)
      break;
  }
  ll sum = 0;

  for (int i = 0; i < n; i++){
    sum += a[i];
  }

  cout << sum << endl;



  return 0;
}

// 解答2
int main(void){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());


  vector<pair<ll, ll>> b(m + n);
  for (int i = 0; i < m; i++){
    cin >> b[i].second >> b[i].first;
  }
  for (int i = m; i < m + n; i++){
    b[i] = pair<ll, ll>(a[i - m], 1);
  }
  sort(b.begin(), b.end());

  ll sum = 0, num = 0;
  for (int i = m + n - 1; i >= 0; i--){
    if (num + b[i].second >= n){
      sum += (n - num) * b[i].first;
      break;
    }
    else {
      sum += b[i].second * b[i].first;
      num += b[i].second;
    }
  }
  cout << sum << endl;


}


// どこが遅いのかわからんけどTLEした
/*
int main(void){
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());


  vector<pair<ll, ll>> b(m);
  for (int i = 0; i < m; i++){
    cin >> b[i].second >> b[i].first;
  }
  sort(b.begin(), b.end());

  int id = n;
  for (int i = m - 1; i > -1; i--){
    int left = -1, right = id, mid;
    while (left + 1 < right){
      mid = (left + right)/2;
      if (a[mid] < b[i].first)
        left = mid;
      else
        right = mid;
    }
    if (left + 1 > b[i].second){
      for (int j = 0; j < left + 1 - b[i].second ; j++){
        a[j] = a[j + b[i].second];
      }
      for (int j = left + 1 - b[i].second; j < left + 1; j++){
        a[j] = b[i].first;
      }
      id = left + 1 - b[i].second;
    }
    else {
      for (int j = 0; j < left + 1; j++){
        a[j] = b[i].first;
      }
      break;
    }
  }

  ll sum = 0;

  for (int i = 0; i < n; i++){
    sum += a[i];
  }

  cout << sum << endl;


  return 0;
}
*/


Measured memory_bytes: 4096
#include <stdio.h>
#define N 400000
#define mod 1000000007
int main(int argc, char *argv[])
{
	long long a[N]={0},n,i,sum=0;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	long long s=0,dum;
	for(i=0;i<=n-2;i++){
		sum-=a[i];
		dum=sum;
		dum%=mod;
		s+=(dum*a[i])%mod;
	}
	printf("%lld\n",(s+mod)%mod);
}

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

typedef long long ll;

int main() {
    ll n;
    ll a = 1;
    cin >> n;
    for(ll i = 1; i*i <= n; i++) if(n % i == 0) a = i;
    ll b = n / a;
    ll ans = (a - 1) + (b - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;


struct graph{
    int V;
    vector<VP > v;
    graph(int V) : V(V), v(vector<VP >(V)){}
    void add_diedge(int v1, int v2, ll w){
        v[v1].pb({v2, w});
        v[v2].pb({v1, w});
    }
    void add_edge(int v1, int v2, ll w){
        v[v1].pb({v2, w});
    }
    VL dist = vector<ll>(V, -1);
    VI prever = vector<int>(V,-1);
    VL dijkstra(int start){
        priority_queue<P, vector<P>, greater<P> > que;
        que.push(P(0,start));
        while(!que.empty()){
            P pa = que.top();
            que.pop();
            int u = pa.se;
            if(dist[u] >= 0 && dist[u] < pa.fi)continue;
            dist[u]=pa.fi;
            for(P e : v[u]){
                if(dist[e.fi] < 0 || dist[e.fi] > dist[u] + e.se){
                    dist[e.fi] = dist[u] + e.se;
                    prever[e.fi] = u;
                    que.push(P(dist[e.fi],e.fi));
                }
            }
        }
        return dist;
    }
    void dfs(ll now, ll prv, ll c){
        d(dist[now])
        d(now)
        d(c)
        d(prv)
        dist[now]=c;
        for(auto nxt : v[now])if(nxt.fi != prv){
            d(nxt.se)
            d(prv)
            d(nxt.se % 2)
            d(nxt.fi)
            if(nxt.se % 2)dfs(nxt.fi, now, !c);
            else{d("debug")dfs(nxt.fi, now, c);}
        }
    }
    void gprint(){
        rep(i,V){ps(i);ps(": ");for(P x : v[i]){ps(x.fi);ps(",");ps(x.se);ps(" ");}p("");}
    }
 
};



int main(){
    cin>>n;
    graph G(n);
    rep(i,n-1){
        cin>>a>>b>>c;
        a--;b--;
        G.add_diedge(a,b,c);
    }
    //G.gprint();
    G.dfs(0,-1,0);
    rep(i,n)p(G.dist[i]);
    return 0;
}


Measured memory_bytes: 12672
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    vector<int> a(26,0);
    string s;
    cin >> s;
    REP(s.length()){

        a[s[i]-'a']++;

    }

    bool exist = true;
    REP(26){
        if(a[i]%2 != 0){
            exist = false;
        }
    }
    if(exist){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
   

    return 0;
}

Measured memory_bytes: 256
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 1000000;

ll fac[maxn+1];
ll rfac[maxn+1];
ll mod=INF;

//最小二乗法
ll pow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll a=pow(x,y/2);
        return (a*a)%mod;
    }else{
        ll a=pow(x,(y-1)/2);
        return a*a%mod*x%mod;
    }
}

int main(){
    
    ll x,y;
    cin >> x>>y;
    
    fac[0]=fac[1]=rfac[0]=rfac[1]=1;

    for(ll i=1;i<=maxn;i++){
            fac[i]=fac[i-1]*i%mod;
    }
    
    //逆元を求める
    rfac[maxn]=pow(fac[maxn],mod-2);
        
    for(ll i=maxn;i>=1;i--){
        rfac[i-1]=rfac[i]*i%mod;
    }
    
    
    
    x++;y++;
    
    int k =(x+y+1)/3;
    k--;
    
    if((x+y+1)%3!=0){
        cout << 0<<endl;
    }else{
        if(k+1<=x&&x<=2*k+1){
            x = x-(k+1);
            cout << fac[k]*rfac[x]%mod*rfac[k-x]%mod<<endl;
        }else{
            cout << 0<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 15872
N = int(input())
h = [10**6]+[int(i) for i in input().split()]+[10**6]*10

cost = [10**20 for i in range(N+10)]  # cost[i]: 足場iに移動するときの最小コスト
cost[1] = 0


for i in range(1, N):
    cost[i+1] = min(cost[i+1], cost[i]+abs(h[i+1]-h[i]))
    cost[i+2] = min(cost[i+2], cost[i]+abs(h[i+2]-h[i]))

print(cost[N])


Measured memory_bytes: 13980
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
A, B, C, D, E, F, G, H, I = c[0][0], c[0][1], c[0][2], c[1][0], c[1][1], c[1][2], c[2][0], c[2][1], c[2][2]

if max(A+E+I, A+F+H, B+D+I, B+F+G, C+D+H, C+E+G) == min(A+E+I, A+F+H, B+D+I, B+F+G, C+D+H, C+E+G):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e18;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  rep(i, m) cin >> b[i];
  int a[100][100] = {};
  rep(i, n) rep(j , m) cin >> a[i][j];
  int ans = 0;
  rep(i, n) {
    int res = 0;
    rep(j, m) res += a[i][j] * b[j];
    if (res + c > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}
	void solve() {
		int N = sc.nextInt();
		int D = sc.nextInt();

		int surveil = D*2+1;

		int res = N/surveil+1;
		if(N%surveil==0)res--;
		out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

}

Measured memory_bytes: 22100
H, W = map(int, input().split())

ans = []
# 横白の除去
for h in range(H):
    line = input()
    if "#" in line:
        ans.append(line)

H = len(ans)
W = len(ans[0])

# 縦白の除去
rem_list = []
for w in range(W):
    ver = [s[w] for s in ans]
    if "#" in ver:
        continue
    rem_list.append(w)

for h in range(H):
    new_ans = []
    for w in range(W):
        if w in rem_list:
            continue
        new_ans.append(ans[h][w])
    ans[h] = new_ans

for i in range(len(ans)):
    for j in range(len(ans[0])):
        print(ans[i][j], end="")
        if j >= len(ans[0])-1:
            print()


Measured memory_bytes: 4596
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 1010;
const int inf = 1e9;

char s[MR][MR];

int H, W;

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

bool ok(int i, int x, int y)
{
	return x + dx[i] >= 0 && x + dx[i] < H && y + dy[i] >= 0 && y + dy[i] < W;
}

int dist[MR][MR];

void bfs()
{
	queue<PII> Q;
	REP(i, H)REP(j, W)
		if (s[i][j] == '#')
			Q.push(MP(i, j));
		else
			dist[i][j] = inf;

	while (!Q.empty())
	{
		auto akt = Q.front(); Q.pop();
		REP(i, 4)
			if (ok(i, akt.first, akt.second) && dist[akt.first + dx[i]][akt.second + dy[i]] == inf)
			{
				dist[akt.first + dx[i]][akt.second + dy[i]] = dist[akt.first][akt.second] + 1;
				Q.push(MP(akt.first + dx[i], akt.second + dy[i]));
			}
	}
}

int main()
{
	scanf("%d%d", &H, &W);
	REP(i, H)
		scanf("%s", s[i]);

	bfs();

	int res = 0;
	REP(i, H)REP(j, W)
		res = max(res, dist[i][j]);
	printf("%d\n", res);

	return 0;
}

// FOR GNU C++ use the following pattern:
// Uncomment the code below and change your main into main2
// It does not build in MS C++
// But it does increase the stack size from 256 MB on CF and uses GNU C++

//#include <Processthreadsapi.h>
//#include <iostream>
//#include <Synchapi.h>
//#include <windows.h>
//#include <process.h>
//
//DWORD WINAPI MyThreadFunction(LPVOID lpParam) {
//    main2(nullptr);
//    return 0;
//}
//int main() {
//    auto h = CreateThread(nullptr, 1024 << 20, MyThreadFunction, nullptr, STACK_SIZE_PARAM_IS_A_RESERVATION, nullptr);
//    WaitForSingleObject(h, INFINITE);
//}

Measured memory_bytes: 11408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int s;
    int s1,s2,s3;

    cin >> s;

    s1 = s / 100;
    s2 = (s - s1 * 100) / 10;
    s3 = (s - s1 * 100 - s2 * 10);

    cout << s1 + s2 + s3 << endl;





}

Measured memory_bytes: 3556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		double res = 0;
		
		for(int i = 1; i <= n; i++) {
			
			int tmp = i;
			int cnt = 0;
			
			while(tmp < k) {
				tmp+=tmp;
				cnt++;
			}
			
			res+=1d/n * Math.pow(1d/2d, cnt);
		}
		
		out.println(res);
	}

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

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

        return tokenizer.nextToken("\n");
    }

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

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

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

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

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

Measured memory_bytes: 20820
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
n = int(input())

A = [[0,0,0],[0,0,0],[0,0,0]]

for _ in range(n):
    b = int(input())
    if b in A1:
        tmp = A1.index(b)
        A[0][tmp] = 1
    elif b in A2:
        tmp = A2.index(b)
        A[1][tmp] = 1
    elif b in A3:
        tmp = A3.index(b)
        A[2][tmp] = 1
'''
if A[0][0] + A[0][1] + A[0][2] == 3 or A[1][0] + A[1][1] + A[1][2] == 3 or A[2][0] + A[2][1] + A[2][2] == 3:
    print('Yes')
elif A[0][0] + A[1][0] + A[2][0] == 3 or A[0][1] + A[1][1] + A[2][1] == 3 or A[0][2] + A[1][2] + A[2][2] == 3:
    print('Yes')
'''
ans = 'No'

for i in range(3):
    if A[0][i] == A[1][i] == A[2][i] == 1:
        ans = 'Yes'
    elif A[i][0] == A[i][1] == A[i][2]== 1:
        ans = 'Yes'
if A[0][0] + A[1][1] + A[2][2] == 3 or A[0][2] + A[1][1] + A[2][0] == 3:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 3192
MOD = 10 ** 9 + 7

N, X, Y, Z = map(int, input().split())

pow2_XYZ = 2 ** (X + Y + Z)

# flg[hist]: 履歴がhistのとき、XYZを含むかどうか
flg = [False] * pow2_XYZ
mask = ((((1 << X) + 1) << Y) + 1) << (Z - 1)
for hist in range(pow2_XYZ):
    if hist & mask == mask:
        flg[hist] = True

# h2s[hist]: DPでの遷移先
h2s = [[0] * 10 for i in range(pow2_XYZ)]
for hist in range(pow2_XYZ):
    for A in range(1, 11):
        h2s[hist][A - 1] = ((hist << A) + (1 << (A-1))) % pow2_XYZ

# dp[i][hist]: 長さiの、履歴がhistである、XYZを含まない数列の数
dp = [[0] * pow2_XYZ for i in range(N + 1)]
dp[0][0] = 1
for i in range(N):
    for hist in range(pow2_XYZ):
        if dp[i][hist] == 0: continue

        for A in range(1, 11):
            h2 = h2s[hist][A - 1]
            if not flg[h2]:
                dp[i + 1][h2] += dp[i][hist]

    dp[i + 1] = list(map(lambda x: x % MOD, dp[i + 1]))

num = sum(dp[N]) % MOD
print((10 ** N - num) % MOD)


Measured memory_bytes: 152124
#include<iostream>

using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
  int i = 0;
  for(int j = 0; j < k; j++) {
    llong s = 0;
    while(s + T[i] <= P) {
      s += T[i];
      i++;
      if(i == n) return n;
    }
  }
  return i;
}

int solve() {
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while(right - left > 1) {
    mid = (right + left) / 2;
    int v = check(mid);
    if(v == n) right = mid;
    else left  = mid;
  }

  return right;
}

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin>> T[i];
  llong ans = solve();
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;
const int MOD = 1000000007;
//sort(all(x))とするとソートできるよ

int main(){
    int N;cin >> N;
    vector<LL> A(N);
    rep(i,N){
        cin >> A[i];
        A[i] -= (i+1);
    }
    sort(all(A));
    LL b = A[N/2];
    LL ans;
    rep(i,N){
        ans += abs(A[i] - b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int k;
    cin >> k;
    vector<ll> a(k);
    for(int i = 0; i < k; ++i)  cin >> a[i];
    ll lb = 2, ub = 2;
    for(int i = k - 1; i >= 0; --i){
        lb = a[i] * ceil((double)lb / a[i]);
        if(lb > ub){
            cout << -1 << endl;
            return 0;
        }
        ub = a[i] * (ub / a[i]) + a[i] - 1;
    }
    cout << lb << " " << ub << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> v (N);
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    v.at(i) = x;
  }
  priority_queue<int, vector<int>, greater<int>> q;
  for (int i = 1; i <= 100; i++) {
    int total = 0;
    for (int j = 0; j < N; j++) {
      int e = (i - v.at(j)) * (i - v.at(j));
      total += e;
    }
    q.push(total);
  }
  cout << q.top() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;


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

    int n;
    cin >> n;
    vector<int> cnt(3);
    for(int i = 0; i < 3; i++) {
        cin >> cnt[i];
    }
    vector<string> turn(n);
    for(int i = 0; i < n; i++) {
        cin >> turn[i];
    }
    string ans;
    for(int i = 0; i < n; i++) {
        string s = turn[i];
        int& x = cnt[s[0]-'A'];
        int& y = cnt[s[1]-'A'];
        debug() nav(cnt);
        int other = -1;
        for(char c : {'A', 'B', 'C'}) {
            if(c != s[0] && c != s[1]) {
                other = cnt[c-'A'];
            }
        }
        assert(other != -1);
        if(i < n-1 && x == 1 && y == 1 && other == 0) {
            bool found_x = false, found_y = false;
            string t = turn[i+1];
            for(char c : t) {
                if(c == s[0]) {
                    found_x = true;
                }
                if(c == s[1]) {
                    found_y = true;
                }
            }
            
            if(found_x && found_y) {
                x++, y--;
                ans.push_back(s[0]);
            } 
            else if(found_x) {
                x++, y--;
                ans.push_back(s[0]);
            }
            else {
                x--, y++;
                ans.push_back(s[1]);
            }
        }
        else {
            if(x < y) {
                x++, y--;
                ans.push_back(s[0]);
            }
            else {
                x--, y++;
                ans.push_back(s[1]);
            }
        }
        
        for(int z : cnt) {
            if(z < 0) {
                cout << "No\n";
                exit(0);
            }
        }
    }
    
    cout << "Yes\n";
    for(char c : ans) {
        cout << c << '\n';
    }
}


Measured memory_bytes: 6732
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (a, b, n) = get!(usize, usize, usize);

    if n < b - 1 {
        println!("{}", a * n / b - n / b * a);
    } else {
        println!("{}", a * (b - 1) / b);
    }
}


Measured memory_bytes: 2268
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define double long double

int n,k;
int a[200000+5];

bool f(long long mid){
	int cuts=0;
	for(int i=n-1;i>=0;i--){
		// if(a[i]<=mid) continue;
		cuts += (a[i]-1)/mid;
	}
	if(cuts>k) return 0;
	else return 1;
}

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

	sort(a,a+n);
	
	long long left = 1, right = a[n-1], ans=a[n-1];

	while(left <= right){
		long long mid = left + (right-left)/2;
		// cout <<"mid=" << mid ;
 		if(f(mid)){
 			// cout <<" yes" << endl;
			ans = mid;
			right = mid-1;
		}else{
			// cout <<" no" << endl;
			left = mid+1;
		}

	}

	cout << ans << endl;

}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	int t=1;
	// cin >> t;

	while(t--) test_case();
	
	return 0;
}



Measured memory_bytes: 4352
from fractions import gcd

N,ma,mb=map(int,input().split())
med=[]
for i in range(0,N):
    a,b,c=map(int,input().split())
    med.append((a,b,c))

dp=[[[float("inf") for i in range(0,401)] for j in range(0,401)] for k in range(0,N)]

for i in range(0,401):
    for j in range(0,401):
        if not (i==0 and j==0):
            g=gcd(i,j)
            I=i//g
            J=j//g
            if I==ma and J==mb:
                dp[0][i][j]=0
            else:
                g=gcd(i+med[0][0],j+med[0][1])
                I=(i+med[0][0])//g
                J=(j+med[0][1])//g
                if I==ma and J==mb:
                    dp[0][i][j]=med[0][2]

for i in range(1,N):
    a,b,c=med[i]
    for j in range(0,401):
        for k in range(0,401):
            if 400>=j+a and 400>=k+b:
                dp[i][j][k]=min(dp[i-1][j][k],c+dp[i-1][j+a][k+b])
            else:
                dp[i][j][k]=dp[i-1][j][k]

if dp[N-1][0][0]==float("inf"):
    print(-1)
else:
    print(dp[N-1][0][0])


Measured memory_bytes: 200436
n=int(input())
c, s, f=[] ,[],[]
ans = []
for i in range(n-1):
    pc, ps, pf = map(int, input().split())
    c.append(pc)
    s.append(ps)
    f.append(pf)

for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<s[j]:
            t=s[j]
        elif t%f[j]!=0:
            t=t+f[j]-t%f[j]
        t+=c[j]
    print(t)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    vector<int> dp(N+K+1, INT_INF);
    dp[0] = 0;
    
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++){
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i] - H[i + j]));
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 4032
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

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

  int n = s.size(), ans = 0;

  for (int i = 0; i < s.size(); i++)
  {
    if (i % 2 == 0 && s[i] == '0')
    {
      ans++;
    }
    else if (i % 2 == 1 && s[i] == '1')
    {
      ans++;
    }
  }

  cout << min(n - ans, ans) << endl;

  return 0;
}

// ...###..

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

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

    int n;
    cin >> n;
    vector<pair<ll, ll>> ba(n);
    rep(i, 0, n) cin >> ba[i].second;
    rep(i, 0, n) cin >> ba[i].first;
    sort(ba.begin(), ba.end());
    vector<ll> b(n), ac(n), a(n);
    rep(i, 0, n) {
        b[i] = ba[i].first;
        a[i] = ac[i] = ba[i].second;
    }
    sort(ac.begin(), ac.end());
    rep(i, 0, n) {
        if (ac[i] > b[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(i, 1, n) {
        if (ac[i] <= b[i - 1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    int c = 0, j = 0;
    vector<ll> p(n);
    rep(i, 0, n) {
        p[i] = lower_bound(ac.begin(), ac.end(), a[i]) - ac.begin();
    }
    while (p[j] != 0) {
        c++;
        j = p[j];
    }

    if (c == n - 1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=2e2;
int w[N+1],val[N+1],ans[N+1][(int)2e5];
signed main()
{
   
    CHAL_BAAP_KO_MT_SIKHA
    int n,wt;
    cin>>n>>wt;
    for(int i=1;i<=n;i++){
        cin>>w[i]>>val[i];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=wt;j++){
            if(j>=w[i])
                ans[i][j]=max(ans[i-1][j-w[i]]+val[i],ans[i-1][j]);
            else
                ans[i][j]=ans[i-1][j];
        }
    }
    int mx=0;
    for(int i=1;i<=wt;i++){
        mx=max(mx,ans[n][i]);
    }
    cout<<mx<<endl;
}

Measured memory_bytes: 156416
let X = Int(readLine()!)!
if X <= 599 {
    print(8)
} else if X <= 799 {
    print(7)
} else if X <= 999 {
    print(6)
}else if X <= 1199 {
    print(5)
}else if X <= 1399 {
    print(4)
}else if X <= 1599 {
    print(3)
}else if X <= 1799 {
    print(2)
}else if X <= 1999 {
    print(1)
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
vector<vector<int>>field;
int N = 250;
void print_field() {
	if (DBG) {
		rep(i, 0, N) {
			rep(j, 0, N) {
				cout << field[i][j] << (j == N - 1 ? '\n' : ' ');
			}
		}
	}
}
int solve(int x, int y, vector<vector<int>> &field) {
	queue<pair<int, int>>Q;
	Q.push(make_pair(x, y));
	int ans(1);
	vector<int> dx{ 1,1,0,-1,-1,0 }, dy{ 0, 1, 1, 0, -1, -1 };
	while (!Q.empty()) {
		auto a = Q.front(); Q.pop();
		if (field[a.first][a.second] == 1)continue;

		rep(i, 0, dx.size()) {
			int ax = a.first + dx[i], ay = a.second + dy[i];
			if (0 <= ax&&ax < N && 0 <= ay&&ay < N&&field[ax][ay] == -1) {
				field[ax][ay] = max(0, field[a.first][a.second] - 1);
				Q.push(make_pair(ax, ay));
				ans++;
			}
		}
	}

	return ans;
}
signed main() {
	int t, n;
	while (cin >> t >> n, t || n) {
		field = vector<vector<int>>(N, vector<int>(N, -1));

		rep(i, 0, n) {
			int x, y;
			cin >> x >> y;
			x += N / 2; y += N / 2;
			field[x][y] = INF;
		}

		int sx, sy; cin >> sx >> sy;
		sx += N / 2; sy += N / 2;
		field[sx][sy] = t + 1;

		cout << solve(sx, sy, field) << endl;


	}
	return 0;
}

Measured memory_bytes: 3364
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;


int get_ab(string str)
{
    int ret = 0;
    for(int i = 0; i < (int)str.size() - 1; i++)
    {
        if(str[i] == 'A' && str[i+1] == 'B')
            ret += 1;
    }
    
    return ret;
}

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int n; cin >> n; vector<string> ba, a, b;
    string cur = "";
    for(int i = 0; i < n; i++)
    {
        string temp; cin >> temp;
        
        if(temp[0] == 'B' && temp.back() == 'A')
            ba.push_back(temp);
        else if(temp[0] == 'B')
            b.push_back(temp);
        else if(temp.back() == 'A')
            a.push_back(temp);
        else if(get_ab(temp) == 0)
        {
            
        }
        else
            cur += temp;
    }
    
    
    
    while(!ba.empty())
    {
        auto temp = ba.back(); ba.pop_back();
        if(!ba.empty())
        {
            auto next = ba.back(); ba.pop_back();
            ba.push_back(temp + next);
        }
        else if(!a.empty())
        {
            auto next = a.back(); a.pop_back();
            a.push_back(next + temp);
        }
        else if(!b.empty())
        {
            auto next = b.back(); b.pop_back();
            b.push_back(temp + next);
        }
        else
        {
            cur += temp;
        }
    }
    
    while(!a.empty() && !b.empty())
    {
        auto as = a.back(); a.pop_back();
        auto bs = b.back(); b.pop_back();
        cur += as + bs;
    }
    
    for(auto v : a)
        cur += v;
    for(auto v : b)
        cur += v;
    
    
    cout << get_ab(cur) << endl;
    
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N;
    int *ball;
    ULL *num;
    ULL count;
    ULL temp;
    int pos;
    int i;
    cin >> N;
    ball = new int[N];
    num = new ULL[N];
    for(i=0;i<N;i++){
        num[i] = 0;
    }
    for(i=0;i<N;i++){
        cin >> ball[i];
        num[ball[i]-1]++;
    }
    count = 0;
    for(i=0;i<N;i++){
        count += num[i] * (num[i]-1);
    }
    for(i=0;i<N;i++){
        pos = ball[i] -1;       
        cout << (count - 2 * num[pos] + 2)/2 << endl;
        /*
        temp = count - ( num[pos] * (num[pos]-1));
        num[pos]^2 - num[pos];
        (num[i] -1 ) * (num[i] - 2)
        num[pos]^2 - 3num[pos] + 2;
        */
    }
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };
int main() {
	int day=0;
	int x,y;
	int md[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	string s[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(true){
		cin>>x>>y;
		if(x==0) break;
		for(int i=0;i<x-1;i++){
			day+=md[i];
		}
		day+=y;
		day%=7;
		cout<<s[day]<<endl;
		day=0;		
	}
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define f(i) for (int i=1 ; i<100 ; i++)
using namespace std;

int main(){
	
	int f[100000]={0},n; cin >> n;
		
	f(a)
		f(b)
			f(c) f[a*a+b*b+c*c+a*c+a*b+b*c]++;
				
	for (int i=1 ; i<=n ; i++) cout << f[i] << "\n";
	
	return 0;
}

Measured memory_bytes: 4028