akhauriyash/Code-Regression huggingface dataset:
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long N = lread();
    auto H = aryread();
    foreach_reverse (i; 0 .. N - 1)
    {
        if (H[i + 1] < H[i])
        {
            H[i]--;
        }
        if (H[i + 1] < H[i])
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}


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

using namespace std;

int main()
{
	int r, b, g, n;
	cin >> r >> b >> g >> n;;


	int ans = 0;
	for (int i = 0; i <= n; i += r)
	{

		for (int j = 0; j <= n; j += b)
		{
			int p = 0;
			if (n >= i + j)
			{
				p = n - (i + j);

				if (p % g == 0 || p == 0)
				{
					ans++;
					
				}
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
    string s;
    cin>>s;
    int flg = 0;

    for(int i=0;i<s.length();i++)
        if(s[i]==s[i+1])
        {
            flg=1;
            break;
        }
    if(flg)
        cout<<"Bad\n";
    else
        cout<<"Good\n";
    return 0;
}

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

int main(){
	int N, K; cin>>N>>K;
	vector<int> A(N); rep(i, N) cin>>A[i];
	int ng = 0, ok = 1e9; // (ng,ok] = (l,r]
	while(ok - ng > 1){
		int m = (ok + ng) / 2;
		int c = 0;
		rep(i, N) c += (A[i] - 1) / m;
		if(c <= K) ok = m; else ng = m;
	}
	cout<< ok <<endl;
}


Measured memory_bytes: 4060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
for i in range(N, 0, -1):
	if sqrt(i) == int(sqrt(i)):
		print(i)
		exit()

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

int main(){
  int n;
  cin >> n;
  int a[n], b[n];
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  int ans = 0;
  rep(i,29) {
    int c = 1 << i;
    vector<int> ad(n), bd(n);
    rep(j,n) {
      ad[j] = a[j] % (c*2);
      bd[j] = b[j] % (c*2);
    }
    sort(bd.begin(),bd.end());
    int num = 0;
    rep(j,n) {
      num += lower_bound(bd.begin(),bd.end(),2*c-ad[j]) - lower_bound(bd.begin(),bd.end(),c-ad[j]);
      num += lower_bound(bd.begin(),bd.end(),4*c-ad[j]) - lower_bound(bd.begin(),bd.end(),3*c-ad[j]);
    }
    if(num % 2) ans += c;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();

lli dp[81][81][81*161];
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    
    lli h,w;
    cin>>h>>w;
    lli a[h][w],b[h][w],d[h][w];
    for(lli i=0;i<h;i++)for(lli j=0;j<w;j++)cin>>a[i][j];
    for(lli i=0;i<h;i++)for(lli j=0;j<w;j++)cin>>b[i][j];
	for(lli i=0;i<h;i++)for(lli j=0;j<w;j++)d[i][j]=abs(a[i][j]-b[i][j]);
 	lli diff=81*161;
	//lli dp[h][w][diff];
	//rec(0,0)
	/*for(lli i=0;i<h;i++){
		for(lli j=0;j<w;j++){
			cout<<d[i][j]<<" ";	
		}
		cout<<endl;
	}*/
	for(lli i=0;i<h;i++)for(lli j=0;j<w;j++)for(lli k=0;k<diff;k++)dp[i][j][k]=0;
	for(lli i=0;i<h;i++){
		for(lli j=0;j<w;j++){
			if(i==0 && j==0){
				dp[i][j][d[0][0]]=1;
				continue;
			}
			if(i==0){
					for(lli di=0;di<diff;di++){
						if(dp[i][j-1][di]==1){dp[i][j][abs(di+d[i][j])]=1;if(1)dp[i][j][abs(di-d[i][j])]=1;}
					}
				continue;
			}
			if(j==0){
					for(lli di=0;di<diff;di++){
						if(dp[i-1][j][di]==1){dp[i][j][abs(di+d[i][j])]=1;if(1)dp[i][j][abs(di-d[i][j])]=1;}
					}
				continue;
			}
			for(lli di=0;di<diff;di++){
						if(dp[i-1][j][di]==1){dp[i][j][abs(di+d[i][j])]=1;if(1)dp[i][j][abs(di-d[i][j])]=1;}
						if(dp[i][j-1][di]==1){dp[i][j][abs(di+d[i][j])]=1;if(1)dp[i][j][abs(di-d[i][j])]=1;}
					}
		}
	}
	lli ani=INT_MAX;
	
	for(lli i=diff-1;i>=0;i--){
		if(dp[h-1][w-1][i]==1)ani=i;
	}
	cout<<ani;


 
 
 
  return 0;
}


Measured memory_bytes: 661888
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

const long long MOD=1e9+7;
const long long BASE=0x234567;

struct RollingHash {
    string s;
    long long mod, base;
    vector<long long> hash, pow;
    RollingHash() {}
    RollingHash(string s, long long m, long long b): s(s), mod(m), base(b) {
        pow.resize(s.length()+1); pow[0]=1;
        for (size_t i=0; i<s.length(); ++i)
            (pow[i+1] = pow[i]*base) %= mod;

        hash.assign(s.length()+1, 0);
        for (size_t i=0; i<s.length(); ++i)
            (hash[i+1] = hash[i]+pow[i]*s[i]) %= mod;
    }
    long long get_hash(size_t first, size_t last) {
        return (hash[last]-hash[first]+mod) % mod;
    }
    long long make_hash(string t) {
        long long h=0;
        for (size_t i=0; i<t.length(); ++i)
            (h += pow[i]*t[i]) %= mod;

        return h;
    }
    long long diff(long long h, size_t pos, size_t len) {
        return (h*pow[pos]-get_hash(pos, pos+len))%mod;
    }
    bool is_equiv(long long h, size_t pos, size_t len) {
        return !diff(h, pos, len);
    }
};

int main() {
    char buf[1<<20];
    scanf("%s", buf);
    string T(buf);

    RollingHash rhash(T, MOD, BASE);

    scanf("%s", buf);
    string P(buf);

    long long h=rhash.make_hash(P);
    for (size_t i=0; i+P.length()<=T.length(); ++i)
        if (rhash.is_equiv(h, i, P.length()))
            printf("%zd\n", i);

    return 0;
}

Measured memory_bytes: 21000
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n, k;
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
    }
    ll ans = (n - 1 + k - 2) / (k - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
hoge_x=[]
hoge_y=[]
huga_x=[]
huga_y=[]
for i in range(n):
  a,b=map(int,input().split())
  hoge_x.append(a)
  hoge_y.append(b)
  
for j in range(m):
  a,b=map(int,input().split())
  huga_x.append(a)
  huga_y.append(b)

for i in range(n):
  ans_kyori=-1
  ans_index=-1
  for j in range(m):
    kyori=abs(hoge_x[i]-huga_x[j])+abs(hoge_y[i]-huga_y[j])
    if(kyori<ans_kyori or ans_kyori==-1):
      ans_kyori=kyori
      ans_index=j+1
  print(ans_index)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, M_a: int, M_b: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    M = (max(a+b)+1)*N
    DP = [[INF]*(M) for _ in range(M)]
    for aa, bb, cc in zip(a, b, c):
        DP_next = [DP[i][:] for i in range(M)]
        DP_next[aa][bb] = min(cc, DP_next[aa][bb])
        for i in range(1, M):
            if M <= i + aa:
                break
            for j in range(1, M):
                if M <= j+bb:
                    break
                DP_next[i+aa][j+bb] = min(DP[i][j]+cc, DP_next[i+aa][j+bb])
        DP = DP_next

    m = INF
    for i in range(1, M//M_a):
        anum = M_a*i
        bnum = M_b*i
        if anum >= M or bnum >= M:
            break
        m = min(DP[anum][bnum], m)
    if m == INF:
        print(-1)
    else:
        print(m)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M_a = int(next(tokens))  # type: int
    M_b = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M_a, M_b, a, b, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 105948
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
    

fast;

ll l,r,d;
cin>>l>>r>>d;
l=max((ll)0,l-1);

ll ans=r/d-l/d;
cout<<ans;


}


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

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

void Main()
{
  int N,M,X; cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  vector<int> understand(M);
  rep(i,N) {
    cin >> C[i];
    rep(j,M) {
      cin >> A[i][j];
      understand[j] += A[i][j];
    }
  }
  rep(j,M) {
    if (understand[j] < X) {cout << -1 << endl; return;}
  }
  int minmoney = 1e8;
  for (int bit = 0; bit < (1 << N); ++bit) {
        // どれを選ぶか
    	//cout << "a" << endl;
    	vector<int> S(N);
        for (int i = 0; i < N; ++i) {
        	if (bit & (1 << i)) {
            	S[i] = 1;
        	} else S[i] = 0;
    	}
    	//cout << S.size() << endl;
		vector<int> rikaido(M);
    	int money = 0;
    	//cout << bit << endl;
        rep(i,N) {
          if (S[i] == 1) {
            rep(j,M) rikaido[j] += A[i][j];
            money += C[i];
          }
        }
    	bool rikai = true;
        rep(j,M) {
          if (rikaido[j] < X) {rikai = false; break;}
        }
    	if (rikai) minmoney = min(minmoney, money);
  }
  cout << minmoney << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 3648
cards = []

for i in range(13):
    cards.append('S {0}'.format(i + 1))

for i in range(13):
    cards.append('H {0}'.format(i + 1))

for i in range(13):
    cards.append('C {0}'.format(i + 1))

for i in range(13):
    cards.append('D {0}'.format(i + 1))


n = int(input())
for _ in range(n):
    card = input()
    if card in cards:
        cards.remove(card)

for _ in range(len(cards)):
    print(cards[_])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pil;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n;
    scanf("%d", &n);
    lint a[n];
    rep(i, n) scanf("%lld", &a[i]);

    lint cur = 1, ans = 0;
    rep(i, n){
        if(a[i] == cur) ++cur;
        else if(a[i] > cur){
            ans += (a[i]-1) / cur;
            a[i] = (a[i]%cur) ? a[i]%cur : 1;
            if(a[i] == cur) ++cur;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#define ENABLE_DEBUG 1
// hidden common codes{{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(lint ngtkana_is_a_genius=0; ngtkana_is_a_genius<(lint)k; ngtkana_is_a_genius++)
using lint=long long;
using ld=long double;
template<class T> using numr=std::numeric_limits<T>;
struct input_t {
    template<class T> operator T() {
        T t;
        std::cin>>t;
        return t;
    }
} input;
#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::string s=input;
    char&c=s.at(1);
    if(c=='B')c='R';
    else if(c=='R')c='B';
    std::cout<<s<<'\n';
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <cstdint>
#define pi 3.14159
#define ll long long
// #define int ll
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int l=0,r=0;
  while(r<n && s[r]=='1') r++;
  int ans=0;
  while(k){
    while(r<n && s[r]=='0') r++;
    while(r<n && s[r]=='1') r++;
    k--;
  }
  ans=r-l;
  while(r<n){
    while(l<n && s[l]=='1') l++;
    while(l<n && s[l]=='0') l++;
    while(r<n && s[r]=='0') r++;
    while(r<n && s[r]=='1') r++;
    ans=max(ans,r-l);
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    solve();
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N,M,C; std::cin>> N >> M >> C;
    std::vector<int> B(M);
    for(int i = 0; i < B.size(); i++){
        std::cin >> B[i]; 
    }
    vector<vector<int>> A(N, vector<int>(M));
    for(size_t i = 0; i < A.size(); i++){
        for(size_t j = 0; j < A.front().size(); j++){
        cin>>A[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i<N;  i++){
        int sum = 0;
        for(int j = 0; j<M; j++){
            sum += A[i][j] * B[j];
        }
        sum += C;
        if (sum>0){
            count += 1;
        }
    }
    cout<<count;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(ll i = (ll)(m); i < (ll)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;



int main(){
  ll n;
  cin >> n;
  vector<vector<ll> > C(n, vector<ll>(n, 0));
  REP(i, n) REP(j, n) cin >> C[i][j];
  ll S = 0;

  REP(i, n)REP(j, i){
    S += min(C[i][j], C[j][i]);
  }
  cout <<S  << endl;
  return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    if(is_sorted(p.begin(), p.end()))
    {
        cout << "YES";
        return 0;
    }
    else
    {
        for(int i = 0; i < n; i++)
        {
            for(int j = i + 1; j < n; j++)
            {
                int temp = p[i];
                p[i] = p[j];
                p[j] = temp;
                if(is_sorted(p.begin(), p.end()))
                {
                    cout << "YES";
                    return 0;
                }
                else
                {
                    int temp = p[i];
                    p[i] = p[j];
                    p[j] = temp;
                }
            }
        }
    }
    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    res = [0]*(n+1)

    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                if(i**2 + j**2 + k**2 +i*j+j*k + k*i<=n):
                    res[i**2 + j**2 + k**2 +i*j+j*k + k*i]+=1
                    
    for i in range(1,n+1):
        print(res[i])
if __name__ == '__main__':
    main()


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

int main() {
  long long n;
  cin >>n;
  string ans="" ;
  while(n){
    n--;
    ans += ('a' + (n%26));
    n=n/26;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void) {
				long long int A,B,C,K;
				cin >> A >> B >> C >> K;
				if (K < A) printf("%Ld", K);
				else if (K <= A+B) printf("%Ld", A);
				else printf("%Ld",  A - (K - (A+B)));
				return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n; cin >> n;

 set <string>s;
 for(int i=0;i<n;i++){
     string t;
     cin >> t;
     s.insert(t);
 }

 int b=s.size();
cout << b << endl;

}


Measured memory_bytes: 19216
# cadidates of no shortest paths
n, m = map(int, input().split())

d = [[float("inf") for i in range(n + 1)] for i in range(n + 1)]
edge_data=[]
connect={i:[] for i in range(1,n+1)}
for i in range(m):
    x, y, z = map(int, input().split())
    # 有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    connect[x].append(y)
    connect[y].append(x)    
    edge_data.append((x,y,z))
for i in range(n + 1):
    d[i][i] = 0  # 自身のところに行くコストは０


def warshall_floyd(d):
    # d[i][j]=i番目の頂点からj番目の頂点までの最短距離
    for k in range(1, n + 1):
        for i in range(1, n + 1):
            for j in range(1, n + 1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)

#最短距離を求めた
cnt=0
for some in edge_data:
    x,y,z=some[0],some[1],some[2]
    if d[x][y]<z:
        cnt+=1
print(cnt)
    




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

using namespace std;

using lli = long long int;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    lli X, D;
    
    lli n, i, j, k;
    
    cin >> n >> X >> D;
    
    if (D < 0)
    {
        X = X + (n - 1) * D;
        D = -D;
    }
    
    if (D == 0)
    {
        if (X == 0)
        {
            cout << 1;
        }
        else
        {
            cout << n + 1;
        }
        return 0;
    }
    /*
    cout << "n = " << n << "  X = " << X << "   D = " << D << endl;
    for(i = 0; i < n; ++i)
    {
        cout << X + D * i << " ";
    }
    cout << endl;
    */
    
    vector<pair<lli, lli>> seg;
    
    lli max_s, min_s;
    
    lli S, l, r;
    
    S = ((n - 1) * n) / 2;
    
    lli step = 2 * D; 
    
    vector<tuple<lli , int, lli>> points;
    
    for(k = 0; k <= n; ++k)
    {
        min_s = (k * (k - 1)) / 2;
        max_s = n * k - ((k + 1) * k) / 2;
        
        l = D * (2 * min_s - S) + X * (2 * k - n);
        r = D * (2 * max_s - S) + X * (2 * k - n);
        
        //cout << "L = " << l << "  R = " << r << endl;
        
        seg.push_back({l, r});
        points.emplace_back(l, 0, k);
        points.emplace_back(r, 1, k);
    }
    
    sort(points.begin(), points.end());
    
    
   
    
    map<lli, int> rest;
    map<lli, lli> left;
    
    lli x, s, rst, ans;
    
    ans = 0;
    lli t;
    
    for(i = 0; i < points.size(); ++i)
    {
        tie(x, t, s) = points[i];
        
        if (t == 1)   // right
        {
            l = seg[s].first;
            r = x;
            rst = ((l % step) + step) % step;
            
            rest[rst] -= 1;
            if (rest[rst] == 0)
            {
                ans += (r - left[rst]) / step + 1;
                rest.erase(rst);
            }
                    
        }
        else
        {
            l = x;
            r = seg[s].second;
            rst = ((l % step) + step) % step;
            
            if (rest.count(rst) == 0)
            {
                rest[rst] = 1;
                left[rst] = l;
            }
            else
            {
                rest[rst] += 1;
            }
  
        }
    }
    
    
    cout << ans;
    
    return 0;
    
}

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

const int MAX = 110000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> nums(N);
    for (int i = 0; i < N; i++)
    {
        ll A;
        cin >> A;
        nums.at(i) = A;
    }
    COMinit();
    sort(nums.begin(), nums.end());
    if(nums.at(0) < 0){
        ll firstNum = nums.at(0);
        for(int i = 0; i < N; i++){
            nums.at(i) += firstNum;
        }
    }
    ll answer = 0;
    for (int i = K - 1; i < N; i++)
    {
        answer = (answer + COM(i, K - 1) * nums.at(i)) % MOD;
    }
    ll min = 0;
    for (int i = 0; i < N - K + 1; i++)
    {
        min = min + ((COM(N - i - 1, K - 1) * nums.at(i)) % MOD);
    }
    answer = (answer - min + MOD) % MOD;
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
const ll fact_table = 800008;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[550010];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
//ll mod = 998244353;
ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k;
ll ans;
ll x[200005], y[500005], z[200005];
bool used[500005];
char s[500005];
ll query;

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

    cin >> a >> b;
    Yes(a * 500 >= b);


    return 0;
}











Measured memory_bytes: 13824
INF = float('inf')
N, M, L = map(int, input().split())
dist = [[INF]*N for _ in range(N)]
for i in range(N):
  dist[i][i] = 0
for _ in range(M):
  a, b, c = map(int, input().split())
  dist[a-1][b-1] = dist[b-1][a-1] = c

# ワーシャルフロイド
for k in range(N):
  for i in range(N-1):
    for j in range(i+1, N):
      t = dist[i][k] + dist[k][j]
      if dist[i][j] > t:
        dist[i][j] = dist[j][i] = t

# 満タンから補給なしで行けるところに辺を張る
dist2 = [[INF]*N for _ in range(N)]
for i in range(N-1):
  for j in range(i, N):
    if dist[i][j] <= L:
      dist2[i][j] = dist2[j][i] = 1

# ワーシャルフロイド
for k in range(N):
  for i in range(N-1):
    for j in range(i+1, N):
      t = dist2[i][k] + dist2[k][j]
      if dist2[i][j] > t:
        dist2[i][j] = dist2[j][i] = t

Q = int(input())
for _ in range(Q):
  f, t = map(int, input().split())
  if dist2[f-1][t-1] == INF:
    print(-1)
  else:
    print(dist2[f-1][t-1]-1)

Measured memory_bytes: 71256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans ,a[220000], b[220000],dp[200][110000];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
//注意:配列を1から始めること
class BIT {
public:
	vector<LL> Bit;
	LL M;
	BIT(LL M) :
		Bit(vector<LL>(M + 1, 0)), M(M) {
		LL n = 1;
		while (M > n)n <<= 1;
		M = n;
	}
	LL sum(LL i) {
		LL s = 0;
		while (i>0) {
			s += Bit[i];
			i -= (i&(-i));
		}
		return s;
	}
	LL sum(LL i, LL j) {
		return sum(j) - sum(i - 1);
	}
	//1-index
	void add(LL i, LL x) {
		while (i <= M) {
			Bit[i] += x;
			i += (i&(-i));
		}
	}
	void update(LL i,LL x) {
		x = x - (sum(i) - sum(i - 1));
		add(i, x);
	}
	//初めてk以上になる、index
	int lower_bound(LL k) {
		int l = -1, r = n + 1, m;
		while (r - l>1) {
			m = (l + r) / 2;
			if (sum(m) >= k)
				r = m;
			else l = m;
		}
		return (r == n + 1 ? -1 : r);
	}
	//初めてkより大きくなる、index
	int upper_bound(LL k) {
		int l = -1, r = M + 1, m;
		while (r - l > 1) {
			m = (l + r) / 2;
			if (sum(m) > k)
				r = m;
			else l = m;
		}
		return (r == M + 1 ? M + 1 : r);
	}
};
BIT bit(200000);
int main() {
	cin >> n>>k;
	rep(i, n) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	bit.add(1, 1);
	for(int i=1;i<=n;i++) {
		rep(j, k+1) {
			dp[i][j] = bit.sum(max(j - a[i-1],(LL)0)+1,j+1);
			dp[i][j] %= MOD;
		}
		rep(j, k + 1) {
			bit.update(j+1, dp[i][j]);
		}
	}
	cout << dp[n][k] << endl;
	return 0;
}


Measured memory_bytes: 93952
import collections

N = int(input()) # N
V = list(map(int, input().split()))
Ve = V[0::2]
Vo = V[1::2]

Ve_ = collections.Counter(Ve)
Vo_ = collections.Counter(Vo)

Ve_1st = max(Ve_.items(), key=(lambda v:v[1]))
Vo_1st = max(Vo_.items(), key=(lambda v:v[1]))
Ve_.pop(Ve_1st[0])
Vo_.pop(Vo_1st[0])
if len(Ve_) == 0: Ve_ = {'-1':0}
if len(Vo_) == 0: Vo_ = {'-1':0}
Ve_2nd = max(Ve_.items(), key=(lambda v:v[1]))
Vo_2nd = max(Vo_.items(), key=(lambda v:v[1]))

if Ve_1st[0] != Vo_1st[0]:
    M = N - Ve_1st[1] - Vo_1st[1]
else:
    M = min(N - Ve_1st[1] - Vo_2nd[1], N - Ve_2nd[1] - Vo_1st[1])
print(M)


Measured memory_bytes: 19040
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n, a;
  cin >> n >> a;
  int x[n+1], m = 0;
  x[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    m = max(m, x[i]);
    x[i] -= a;
  }
  if (a > m) {
    cout << 0 << endl;
    return 0;
  }
  
  long long dp[n+1][2*n*m+1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= 2*n*m; j++) {
      if (!i)
        dp[i][j] = (j == n*m) ? 1 : 0;
      else if (j-x[i] < 0 || j-x[i] > 2*n*m)
        dp[i][j] = dp[i-1][j];
      else
        dp[i][j] = dp[i-1][j] + dp[i-1][j-x[i]];
    }
  }
  cout << dp[n][n*m]-1 << endl;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int a = 0;
		int w = 0;
		int t = 0;
		int r = 0;
		for (int i = 0; i < N; i++) {
			String S = scanner.next();
			if (S.equals("AC")) {
				a += 1;
			} else if (S.equals("WA")) {
				w += 1;
			} else if (S.equals("TLE")) {
				t += 1;
			} else {
				r += 1;
			}
		}
		System.out.println("AC x " + a);
		System.out.println("WA x " + w);
		System.out.println("TLE x " + t);
		System.out.println("RE x " + r);
	}
}

Measured memory_bytes: 58568
/**
 * Areas on the Cross-Section Diagram
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_D&lang=ja
 * 参考：Areas on the Cross-Section Diagram 解き方メモ
 * https://mtdtx9.hatenablog.com/entry/2017/04/24/230941
 */

#include<iostream>
#include<vector>
#include<stack>
using namespace std;

struct WaterArea {
  // 水たまりの左端の場所
  int leftIndex;
  // 水たまりの大きさ
  int areaSize;
};

WaterArea mkWaterArea(int leftIndex, int areaSize) {
  WaterArea area = WaterArea();
  area.leftIndex = leftIndex;
  area.areaSize = areaSize;
  return area;
}

/**
 * それぞれの水たまりの大きさを出力する
 */
void trace(stack <WaterArea>A) {
  vector <int>areaSizes(A.size());
  while (A.size() > 0) {
    // stackはLIFOなので、一度取り出して整頓する
    WaterArea area = A.top();
    A.pop();
    areaSizes.at(A.size()) = area.areaSize;
  }

  // 水たまりのサイズを出力
  for (int i = 0; i < areaSizes.size(); i++) {
    cout << ' ' << areaSizes.at(i);
  }
}

int areaTotalSize(stack <WaterArea>A) {
  int total = 0;
  while (A.size() > 0) {
    WaterArea area = A.top();
    A.pop();
    total += area.areaSize;
  }

  return total;
}

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

  stack <WaterArea>areaStack;
  stack <int>slopeIndexStack;

  char slope;
  int currentIndex = -1;
  while (++currentIndex <= 20000) {
    cin >> slope;
    if (cin.eof()) {
      break;
    } else if (slope == '\\') {
      slopeIndexStack.push(currentIndex);
    } else if (slope == '/') {
      if (slopeIndexStack.empty()) {
        continue;
      }

      int slopeIndex = slopeIndexStack.top();
      slopeIndexStack.pop();
      WaterArea area = mkWaterArea(slopeIndex, currentIndex - slopeIndex);
      while (areaStack.size() > 0) {
        WaterArea areaTop = areaStack.top();
        // cout << "area top index " << areaTop.size << " " << areaTop.index <<  endl;
        if (areaTop.leftIndex > area.leftIndex) {
          areaStack.pop();
          area.areaSize += areaTop.areaSize;
        } else {
          break;
        }
      }
      areaStack.push(area);
    }
  }

  // 水たまりの総サイズ
  cout << areaTotalSize(areaStack) << endl;
  // 水たまりの数
  cout << areaStack.size();
  // それぞれの水たまりのサイズ
  trace(areaStack);
  cout << endl;

  return 0;
}



Measured memory_bytes: 3236
N, M = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(N)]

a = 0

for xs in (1, -1):
  for ys in (1, -1):
    for zs in (1, -1):
      l_s = [x*xs + y*ys + z*zs for x, y, z in l]
      l_s.sort(reverse=True)
      a = max(sum(l_s[:M]), a)

print(a)

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n,k; cin >> n >> k;
    int now = k;
    int ans = 1;
    while(now<=n){
        now*=k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int a[2000010];

int main(){
	int l=100000,r=0;
	int n,k;
	cin>>n>>k;
	int d;
	for(int i=1;i<=n;i++)
	{
		cin>>d;
		a[d]++;
		l=min(l,d);
		r=max(r,d);
	}
	
	if(r-l+1<=k) {
		cout<<0;
		return 0;
	}
	sort(a+l,a+r+1);
	
	int ans=0;
	while(r-l+1>k)
	{
		ans+=a[l];
		l++;
	}
	cout<<ans;
	return 0;
}

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

int main() {
    string S; cin >> S;
    if (S == "ABC")cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

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

int main (){
    long long int N;
    cin >> N;
    long long int A[N];

    for(long long int i=1; i<N; i++){
        cin >> A[i];
    }

    long long int B[N];

    for(long long int i=0; i<N; i++){
        B[i] = 0;
    }

    long long int v;

    for(long long int i=1; i<N; i++){
        v = A[i];
        B[v-1] = B[v-1] + 1;
    }

    for(long long int i=0; i<N; i++){
        cout << B[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 6744
M=998244353
def extended_gcd(a, b)
  last_remainder, remainder = a.abs, b.abs
  x, last_x, y, last_y = 0, 1, 1, 0
  while remainder != 0
    last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)
    x, last_x = last_x - quotient*x, x
    y, last_y = last_y - quotient*y, y
  end
  return last_remainder, last_x * (a < 0 ? -1 : 1)
end

def invmod(e)
  g, x = extended_gcd(e, M)
  x % M
end

def powmod(a,r)
  s,t=1,a
  while r>0
    s=s*t%M if r.odd?
    r/=2
    t=t*t%M
  end
  s
end

n,m,k=gets.split.map &:to_i
if m==1
  puts k==n-1 ? 1 : 0
else
  c,b=1,m*powmod(m-1,n-1)%M
  minv=invmod(m-1)
  s=c*b%M
  1.upto(k){|i|
    c=c*(n-i)*invmod(i)%M
    b=b*minv%M
    s=(s+b*c)%M
  }
  puts s
end

Measured memory_bytes: 14372
from functools import lru_cache
for _ in range(int(input())):
    n,a,b,c,d=map(int,input().split())
    @lru_cache(None)
    def f(k):
        if k==0:return 0
        if k==1:return d
        return min(k*d,f(k//5)+c+k%5*d,f(k//3)+b+k%3*d,f(k//2)+a+k%2*d,f((k+4)//5)+c+-k%5*d,f((k+2)//3)+b+-k%3*d,f((k+1)//2)+a+-k%2*d)
    print(f(n))

Measured memory_bytes: 11336
n, q = map(int,input().split())
S = input()
count = [0]*n
for i in range(1,n):
  count[i] += count[i-1]
  if S[i-1:i+1] == "AC":
    count[i] += 1
for i in range(q):
  l, r = map(int,input().split())
  print(count[r-1]-count[l-1])


Measured memory_bytes: 7700
# coding: utf-8
n = int(input())
ll = []
d = {}
in_k = []
for i in range(n):
    s, p = map(str, input().split())
    if not s in d:
        d[s] = [[int(p), i+1]]
    else:
        d[s].append([int(p), i+1])
    if not s in in_k:
        in_k.append(s)
tmp = 1
num = 1
keys = sorted(d.keys())
for k in keys:
    d[k].sort(key=lambda x: x[0], reverse=True)
    for i in range(len(d[k])):
        d[k][i].append(num)
        num += 1
    d[k].sort(key=lambda x: x[1])
for k in d.keys():
    for j in range(len(d[k])):
        ll.append(d[k][j][1:])
ll.sort(key=lambda x: x[1])
for l in ll:
        print(l[0])

Measured memory_bytes: 3064
<?php
 fscanf(STDIN,"%s",$s);
 $front = substr($s,0,2);
 $back = substr($s,-2,2);
 
 if((($front>=1 && $front<=12) && ($back>=0 && $back<=99)) &&
    (($back>=1 && $back<=12) && ($front>=0 && $front<=99))){
   	echo "AMBIGUOUS";
 }elseif(($front>=1 && $front<=12) && ($back>=0 && $back<=99)){
   	echo "MMYY";
 }elseif(($back>=1 && $back<=12) && ($front>=0 && $front<=99)){
   	echo "YYMM";
 }else{
   	echo "NA";
 }
 

Measured memory_bytes: 16168
data = input().split()

N = int(data[0])
M = int(data[1])
C = int(data[2])

B =[int(s) for s in input().split()]

i = 0
j = 0
count = 0
while i < N:
    A = [int(k) for k in input().split()]
    
    sc = []
    while j < M:
        sc.append(A[j] * B[j])
        j += 1
        
    if sum(sc)+ C > 0:
        count += 1
    
    j = 0
    i += 1

print(count)

    
    


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

using namespace std;
int main() {
  int n;
  cin >> n;
  int weight[n];
  for (int i = 0; i < n; i++) {
    cin >> weight[i];
  }

  int s1 = weight[0];
  int s2 = weight[n - 1];
  int j = n - 2;
  for (int i = 1; i <= j;) {
    if (s1 <= s2) {
      s1 += weight[i];
      i++;
    } else {
      s2 += weight[j];
      j--;
    }
  }
  cout << abs(s1 - s2) << endl;
  return 0;
}

Measured memory_bytes: 256
W,H,N=map(int,input().split())
l=[]
x=W
y=H
max1=0
max2=0
max3=W
max4=H
for i in range(N):
     x1,y1,z=map(int,input().split())
     ls=[]
     ls.append(x1)
     ls.append(y1)
     ls.append(z)
     l.append(ls)
for i in l:
     if i[2]==1:
          c=i[0]
          if c>max1:
               x-=c-max1
               max1=c
     elif i[2]==2:
          a=i[0]
          if a<max3:
               x-=max3-a
               max3=a
     elif i[2]==3:
          b=i[1]
          if b>max2:
               y-=b-max2
               max2=b
     elif i[2]==4:
          d=i[1]
          if d<max4:
               y-=max4-d
               max4=d
if y<=0 or x<=0:
     print('0')
else:
     print(x*y)

Measured memory_bytes: 3064
#include <stdio.h>
int main(){

    int N;
    scanf("%d", &N);
    int a1[N];
    int a2[N];

    int i;
    int j;
    int down_num; // 1 <= down_num <= N

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


    int max, sum;

    for(down_num=1; down_num<=N; down_num++){
        sum = 0;
        for(i=0; i<down_num; i++){
            sum += a1[i];
        }
        for(j=i-1; j<N; j++){
            sum += a2[j];
        }
        if(sum > max) max = sum;
    }
    printf("%d\n", max);


    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll L[N]; rep(i,N) cin >> L[i];

  ll result = 0;
  rep(i,N) repr(j,i+1,N) repr(k,j+1,N) {
    result += L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i] && max(L[i],max(L[j],L[k]))*2<L[i]+L[j]+L[k];
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
  int flag,a,b;
  char s[101];
  while(1){
    flag = 0;
    a = 0;
    b = 0;
    cin >> s;
    if(s[0] == '0'){
      break;
    }
    for(int i=1;s[i]!='\0';i++){
      if(s[i] == 'A'){
	a++;
      }
      else if(s[i] == 'B'){
	b++;
      }
    }
    if(a < b){
      b++;
    }
    else if(a > b){
      a++;
    }
    cout << a << " " << b << endl;
  }
}

Measured memory_bytes: 1140
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int cnt = 0, k = i;
    while (k % 2 == 0 && k > 0) {
      cnt++;
      k /= 2;
    }
    ans = max(ans, cnt);
  }
  
  cout << pow(2, ans) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int a;
    cin>>a;
    int b=a%10,c=(a/10)%10,d=(a/100)%10,e=a/1000;
    if((b==c&&c==d)||(c==d&&d==e))cout<<"Yes\n";
    else cout<<"No\n";
}


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

typedef pair<ll, ll> pii;

bool comp(pii p1, pii p2) {
    if (p1.first < p2.first) return true;
    else if (p1.first > p2.first) return false;
    else return (p1.second > p2.second);
}

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

    int n, w;
    cin >> n >> w;

    vector<pii> items(n);

    for (int i = 0; i < n; i++) {
        ll weight, v;
        cin >> weight >> v;
        items[i] = {weight, v};
    }

    sort(items.begin(), items.end(), comp);

    ll dp[n][w + 1];

    // initialize top row
    for (int i = 0; i <= w; i++) {
        if (i - items[0].first < 0) dp[0][i] = 0;
        else dp[0][i] = items[0].second;
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= w; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j - items[i].first >= 0) {
                dp[i][j] = max(dp[i][j],
                        items[i].second + dp[i - 1][j - items[i].first]);
            }
        }
    }

    cout << dp[n - 1][w];

}

Measured memory_bytes: 78336
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>

using namespace std;

#define ll long long
#define f0(i,n)for(i=0;i<n;i++)
#define f1(i,n)for(i=1;i<=n;i++)
#define fc(i,c,n)for(i=c;i<=n;i++)
#define f0r(i,n)for(i=n-1;i>=0;i--)
#define f1r(i,n)for(i=n;i>0;i--)
#define fcr(i,c,n)for(i=c;i<=n;i++)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

ll i, j, q;
ll n, m, p, k, t;
ll a, b, c, d;
ll x, y, z, l, r;
ll one = 1, zero = 0, ans = 0;
ll mod = 1000000007;
ll a1, a2, a3, a4, a5, a6;
string st1, st2, st3;
char ch1, ch2, ch3;

int main() {
	IO;
	ifstream fin("Text.txt");

	cin >> n;
	a1 = 0; a2 = 0; a3 = 0;
	a4 = 0; a5 = 0; a6 = 0;
	f0(i, n) {
		cin >> a4 >> a5>>a6;
		d = abs(a2 - a5) + abs(a3 - a6);
		c = a4 - a1;
		if (c < d) {
			cout << "No" << endl;
			return 0;
		}
		c -= d;
		if (c & 1) {
			cout << "No" << endl;
			return 0;
		}
		a1 = a4; a2 = a5; a3 = a6;
	}

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

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    n, m = map(int, input().split())
    c = list(map(int, input().split()))

    # dp[i]: i円を払う最小枚数
    dp = [float('inf')]*(n+1)
    dp[0] = 0

    for i in range(1, n+1):
        for j in range(m):
            if i>=c[j]:
                dp[i] = min(dp[i-c[j]]+1, dp[i])

    print(dp[n])

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 7268
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  int a;
  ll cond = 1, pow3 = 1;
  rep(i,N) {
    cin >> a;
    if (a%2==0) cond *= 2;
    pow3 *= 3;
  }
  cout << pow3 - cond << endl;
  
  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
int a, b, c;
cin>>a>>b>>c;
if(a+b==c||b+c==a||c+a==b)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


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


int main() {

  int n;
  cin>>n;

  vector<int64_t> A(n);
  for(int i=0;i<n;i++){
    cin>>A.at(i);
  }
//最初全部の経路を足す
//ポイントiを飛ばす。
//ポイントi-1～ポイントiとポイントi～ポイントi+1の距離を削る。
//ポイントi-1～i+1の距離を足す。
  int64_t sum=0;
  for(int i=0;i<n;i++){
    if(i==0)
      sum+=abs(A.at(i));
    else if(i==n-1)
      sum+=abs(A.at(i)-A.at(i-1))+abs(A.at(i));
    else
      sum+=abs(A.at(i)-A.at(i-1));
  }


  for(int i=0;i<n;i++){
    if(i==0){
        cout<<sum-(abs(A.at(i))+abs(A.at(i+1)-A.at(i)))+abs(A.at(i+1))<<endl;
    }
    else if(i==n-1){
        cout<<sum-(abs(A.at(i)-A.at(i-1))+abs(A.at(i)))+abs(A.at(i-1))<<endl;
    }
    else{
        cout<<sum-(abs(A.at(i)-A.at(i-1))+abs(A.at(i+1)-A.at(i)))+abs(A.at(i+1)-A.at(i-1))<<endl;
    }
  }

    return 0;
}




Measured memory_bytes: 2048