akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
set<char> acgt = {'A','C','G','T'};
bool f(char c){
	return acgt.count(c);
}
int32_t main(){
	char s[20];cin>>s;
	int ans = 0,n=strlen(s);
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			if(all_of(s+i,s+j+1,f)) ans = max(ans,j-i+1);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{

    IOS
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    map<char,int> mp;
    REP(i,s.size()) {
        int tmp = 1;
        mp[s[i]]++;
        for(auto p:mp){
            if (p.first == s[i]) continue;
            tmp = modm(tmp,p.second+1);
        }
        ans = mod(ans+tmp);
    }

    OUT(ans)

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#include <queue>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int A[N]; rep(i, N) cin >> A[i];
  sort(A,A+N);
  priority_queue<int> m, z;
  priority_queue<int, vector<int>, greater<int>> p;

  int result = 0;
  vector<vector<int>> op;
  if (N!=2){
    rep(i, N) { 
      if (A[i]>0) p.push(A[i]);
      else if (A[i]==0) z.push(A[i]);
      else m.push(A[i]);
    }
    if (p.empty()) {
      if (!z.empty()) {
        while(!z.empty()) { p.push(z.top()); z.pop(); }
      }
      else {
        int x; x = m.top(); m.pop();
        int y; y = m.top(); m.pop();
        op.push_back({x, y});
        p.push(x-y);
      }
    }
    else if (m.empty()) {
      if (!z.empty()) {
        while(!z.empty()) { m.push(z.top()); z.pop(); }
      }
      else {
        int x; x = p.top(); p.pop();
        int y; y = p.top(); p.pop();
        op.push_back({x, y});
        m.push(x-y);
      }
    }
    else while(!z.empty()) { p.push(z.top()); z.pop(); }

    int rp = p.top(); p.pop();
    int rm = m.top(); m.pop();
    while(!p.empty()) {
      op.push_back({rm, p.top()});
      rm -= p.top();
      p.pop();
    }
    while(!m.empty()) {
      op.push_back({rp, m.top()});
      rp -= m.top();
      m.pop();
    }
    result = rp - rm;
    op.push_back({rp, rm});
  }
  else {
    result = max(A[0],A[1]) - min(A[0], A[1]);
    op.push_back({max(A[0],A[1]), min(A[0], A[1])});
  }

  cout << result << endl;
  for (auto x: op) cout << x[0] << " " << x[1] << endl;
  return 0;
}

Measured memory_bytes: 8428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int[] array1  = new int[a];
        int[] array2 = new int[a];
        int[] array3 = new int[a-1];
        int sum = 0;

        for(int i = 0; i < a; i++){
            array1[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            array2[i] = sc.nextInt();
        }
        for(int i = 0; i < a - 1; i++){
            array3[i] = sc.nextInt();
        }
        for(int i = 0; i < a; i++){
            sum += array2[array1[i] - 1];
            if(i == (a - 1)){
                break;
            }
            if(array1[i] == (array1[i + 1] - 1)){
                sum += array3[array1[i] - 1];
            }
        }
        System.out.println(sum);
    }
}

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

int main() {
	int n,i;
	cin>>n;
	int t[n];

	for(i=0;i<n;i++){
	    cin>>t[i];
	}
	
	int m;
	cin>>m;
	while(m--){
	    int now,ne,s=0;
	    cin>>now>>ne;
	    
	    for(i=0;i<n;i++){
	        if(i+1==now){
	            s+=ne;
	        }
	       else s+=t[i];
	    }
	    cout<<s<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,A,B,C,D; cin >> N >> A >> B >> C >> D;
    --A; --B; --C; --D;
    string S; cin >> S;

    auto check=[&](int s, int t) {
        for (int i = s; i < t; i++) {
            if (S[i]=='#' and S[i+1]=='#') return false;
        }
        return true;
    };

    if (!(check(A,C) and check(B,D))) {
        cout << "No" << ln;
        return 0;
    }
    if (C < D) {
        cout << "Yes" << ln;
        return 0;
    }

    bool ok = false;
    for (int i = B; i <= D; i++) {
        if (S[i-1]=='.' and S[i]=='.' and S[i+1]=='.') ok = true;
    }
    cout << (ok ? "Yes" : "No") << ln;
}


Measured memory_bytes: 592
#include <iostream>
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)
#define M 998244353
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define fori(i, a, b) for(i=a; i<b; i++)
#define ford(i, a, b) for(i=a; i>b; i--)
using namespace std;
const ll N = 500043;
ll fact[N];
ll add(ll x, ll y)
{
	x += y;
	while(x >= MOD) x -= MOD;
	while(x < 0) x += MOD;
	return x;
}
ll mul(ll x, ll y)
{
	return (x * 1ll * y) % MOD;
}
ll mulmod(ll a, ll b)
{
    ll res = 0;
    a = a % MOD;
    while (b>0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
        a = (a * 2) % MOD;
        b /= 2;
    }
    return res % MOD; 
}
ll binpow(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = mul(z, x);
		x = mul(x, x);
		y /= 2;
	}
	return z;
}
ll inv(ll x)
{
	return binpow(x, MOD - 2);
}
ll divide(ll x, ll y)
{
	return mul(x, inv(y));
}
void precalc()
{
	fact[0] = 1;
	ll i;
	fori(i, 1, N)
		fact[i] = mul(i, fact[i - 1]);
}
ll C(ll n, ll k)
{
	if(k > n)
	    return 0;
	return divide(fact[n], mul(fact[n-k], fact[k]));
}

void constructXOR(ll a[], ll n) 
{ 
    ll XOR = 0; 
    for (ll i=0; i<n; i++) 
        XOR ^= a[i]; 
    for (ll i=0; i<n; i++) 
        a[i] = XOR^a[i]; 
}

void solve()
{
    ll n;
    cin >> n;
    ll i;
    ll a[n];
    fori(i, 0, n)
        cin >> a[i];
    constructXOR(a, n); 
    for (int i = 0; i < n; i++) 
        cout << a[i] << " ";
    cout << endl;
}
signed main()
{
    io
    int t;
    t=1;
    // cin >> t;
    while(t--)
        // cout << solve() << endl;
        solve();
    return 0;
}

Measured memory_bytes: 5108
#include<stdio.h>

int main(void)
{
    int a, b, c, d;

    scanf("%d%d%d%d", &a, &b, &c, &d);

    if ((a+b) > (c+d)) {
        printf("Left\n");
    }
    else if ((a+b) < (c+d)) {
        printf("Right\n");
    }
    else {
        printf("Balanced\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<' ';
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s; cin>>s;
    vll cl(s.size()+1,0);
    vll cr(s.size()+1,0);

    cl[0] = 0;
    rep(i,s.size()){
        if(s[i] == '<')cl[i+1] = cl[i]+1;
    }
    cr[s.size()] = 0;
    for(int i = s.size()-1; i>=0; --i){
        if(s[i] == '>')cr[i] = cr[i+1]+1;
    }
    ll ans = 0;
    rep(i,s.size()+1){
        ans += max(cl[i],cr[i]);
    }
    cout<<ans<<endl; return 0;
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;


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


    int n,m;
    int a,b,c;
    cin >> a >> b >> c;
    m = b;
    b = a;
    a = c;
    c = m;

    cout << a << " " << b << " " << c << endl;
    return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


int main(){
  ll k, x;
  cin >> k >> x;

  ll i = max(x-k+1, -1000000ll);

  string pt = "";
  for(; i <= 1000000; i++){
    if(i <= x+k-1){
      cout << pt << i;
      pt = " ";
      continue;
    }
    break;
  }

  cout << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> R, B;
  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    R.push_back(make_pair(a, b));
  }
  REP(i, N) {
    ll c, d;
    cin >> c >> d;
    B.push_back(make_pair(c, d));
  }
  sort(R.begin(), R.end());
  sort(B.begin(), B.end());

  set<ll> st;
  ll cnt = 0;
  REP(i, N) {
    bool ok = false;
    ll max = -1, max_i;
    REP(j, N) {
      ll a, b;
      ll c, d;
      tie(c, d) = B[i];
      tie(a, b) = R[j];
      if (!st.count(j)) {
        if (c - a > 0 && d - b > 0 && b > max) {
          max = b;
          max_i = j;
          ok = true;
        }
      }
    }
    if (ok) {
      st.insert(max_i);
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

string s;
int main() {
    int N,D;
    cin>>N;
    cin>>s;
    cin>>D;
    int idx=0;
    while(D&&idx<N) {
        if(s[idx]=='0') {
            s[idx]='*';
            D--;
        }
        idx++;
    }
    while(D) {
        if(s[idx]=='1') {
            s[idx]='0';
            D--;
        }
        idx--;
    }
    rep(i,N) if(s[i]=='*') s[i]='1';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 1204
N, M = map(int, input().split())

to = [[] for i in range(100010)]

for i in range(M):
    a, b = map(int, input().split())
    to[a].append(b)
    to[b].append(a)

dist = [0] * (N+1)
q = [1]
dist[0] = -1
#print(to[:4])

dist = [0] * N
pre = [0] * N

while len(q) != 0:
    a = q.pop(0)
    for i in to[a]:
        if dist[i-1] == 0:
            dist[i-1] = dist[a-1] + 1
            pre[i-1] = a
            q.append(i)
    #print(q)

print("Yes")
for i in range(1, N):
    print(pre[i])


Measured memory_bytes: 34504
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a;
	if(a<1000)cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
	
	
	
	
	return 0;
}

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

int main()
{
  int n,h,w;
  cin >> n >> h >> w;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  for(i = 0;i < n;++i){
    cin >> a.at(i) >> b.at(i);
  }
  int ans = 0;
  for(i = 0;i < n;++i){
    if(a.at(i) >= h && b.at(i) >= w){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int a[3][3];
	int b[10], n;
	bool ans = false;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	cin >> n;
	for (int i = 0; i < n; i++ ) {
		cin >> b[i];
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < n; k++) {
				if (a[i][j] == b[k]) {
					a[i][j] = 0;
				}
			}
		}
	}
	if (a[0][0] == 0 && a[1][1] == 0 && a[2][2]==0) {
		ans = true;
	}
	if (a[0][2] == 0 && a[1][1] == 0 && a[2][0]==0) {
		ans = true;
	}
	for (int i = 0; i < 3; i++) {
		if (a[i][0] == 0 && a[i][1] == 0 && a[i][2]==0) {
			ans = true;
		}
		if (a[0][i] == 0 && a[1][i] == 0 && a[2][i]==0) {
			ans = true;
		}
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int f[100010][5],val[100010][5],n;
int fuck(int i,int j)
{
    if(f[i][j]==-1)
    {
        if(i==n-1)
        return f[i][j]=fmax(val[i][(j+1)%3],val[i][(j+2)%3]);
        else
        return f[i][j]=fmax(val[i][j]+fuck(i+1,(j+1)%3),val[i][j]+fuck(i+1,(j+2)%3));
    }
    else
    return f[i][j];
}
int main()
{
    int n,i,ans;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d%d%d",&val[i][0],&val[i][1],&val[i][2]);
        f[i][0]=-1;
        f[i][1]=-1;
        f[i][2]=-1;
    }
    ans=fmax(val[0][0]+fuck(1,1),fmax(val[0][0]+fuck(1,2),fmax(val[0][1]+fuck(1,0),fmax(val[0][1]+fuck(1,2),fmax(val[0][2]+fuck(1,0),val[0][2]+fuck(1,1))))));
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define ppb pop_back
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n,a,b,c;
	cin>>n;
	int dp[3][100005];
	dp[1][0]=dp[2][0]=dp[0][0]=0;
	for (int i=1;i<=n;i++) 
	{
		cin>>a>>b>>c;
		dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a;
		dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b;
		dp[2][i]=max(dp[1][i-1],dp[0][i-1])+c;
	}
	cout<<max(dp[0][n],max(dp[1][n],dp[2][n]));
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
/*using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       long double p;
       vector<long double> dp(n+1);
       dp[0] = 1.00;
       //dp[i][j] probability of getting j heads in i tosses
       for(int i=1;i<=n;++i)
       {
           cin>>p;
           for(int j=i;j>=0;--j)
           {
               if(j==0)
               {
                   dp[j] = dp[j]*(1-p);
               }
               else
                dp[j]= p*dp[j-1] + (1-p)*dp[j];
           }
       }
       int x = (n+1)/2;
       p = 0;
       for(int i=x;i<=n;++i)
        p+= dp[i];
       cout<<fixed<<setprecision(15)<<p<<el;
    }
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.ArrayDeque
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, m) = readIntegerList()
    val s = br.readLine()!!
    val t = br.readLine()!!

    val l = lcm(n.toLong(), m.toLong())
    val g = gcd(n.toLong(), m.toLong()).toInt()
    for (i in 0 until g) {
        if (s[i * n / g] != t[i * m / g]) {
            out.println(-1)
            return
        }
    }

    out.println(l)
}

/** O(log(n)): n = min(a, b) */
tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

/** O(log(n)): n = min(a, b) */
fun lcm(a: Long, b: Long)= a / gcd(a, b) * b

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 39820
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(a, b) for(a = 0; a < b; a++)


int sum(vector<int> _A){
  
  int _Sum = 0, i;
  
  rep(i, _A.size()){
    
    _Sum += _A.at(i);
  }
  
  return _Sum;
}

int main() {
   
  int N, M, i, Sum;
  cin >> N >> M;
  vector<int> A(N);
  
  rep(i, N){
    
    cin >> A.at(i);
  }
  Sum = sum(A); 
  sort(all(A));
  
  double shi =  (double) Sum / ((double) (4 * M));
  
  /*cout << A.at(0) << A.at(1) << A.at(2) << endl;
  cout << shi << endl;
  cout << Sum << endl;*/
  
  int NumNi = 0;
  rep(i, N){
    
    if(shi <= A.at(i)){
      NumNi = A.size() - i;
      break;
    }
  }
  
  if (M <= NumNi){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i, 0, m) cin >> b[i];
    int ans = 0;
    rep(i, 0, n){
        vector<int> a(m);
        rep(j, 0, m) cin >> a[j];
        int sum = 0;
        rep(j, 0, m) sum += a[j] * b[j];
        sum += c;
        if(sum > 0) ans++; 
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (c <= b&&a<=d) {
		cout << min(b, d) - max(a, c) << "\n";
	}
	else cout << 0 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int d[100];
    int a[100][100];
    vector<bool> flg(n+1,false);
    for(int i=0; i<k; i++){
        cin >> d[i];
        for(int j=0; j<d[i]; j++){
            cin >> a[i][j];
            flg[a[i][j]] = true;
        }
    }
    int cnt=0;
    for(int i=0; i<n+1; i++){
        if(flg[i]==true){
            cnt++;
        }
    }
    cout << n-cnt << endl;
}




Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(a,j,n) for(ll i=a;i<j;i=i+n )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 1000000009;
ll i;


int main(){
    V v={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll K;
    cin>>K;
    cout<<v.at(K-1)<<endl;
}



Measured memory_bytes: 256
//header file---{{{
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
//end.header file---}}}
using namespace std;


//template---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); i > (a); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(), (i).end();
//end.template ---}}}

int main() {

    int A, B, C, X, Y;

    cin >> A >> B >> C >> X >> Y;

    int AB_piza_X = 0;
    int AB_piza_Y = 0;

    if (X > Y) {
        AB_piza_Y = Y;
    }
    else {
        AB_piza_X = X;
    }

    if (AB_piza_X != 0) {
        int formula[3];
        formula[0] = (A * X) + (B * Y);
        formula[1] = (AB_piza_X * 2 * C) + (Y - X) * B;
        formula[2] = Y * C * 2;

        sort(formula, formula + 3);

        cout << formula[0] << endl;

        return (0);
    }

    else if (AB_piza_Y != 0) {
        int formula[3];
        formula[0] = (A * X) + (B * Y);
        formula[1] = (AB_piza_Y * 2 * C) + (X - Y) * A;
        formula[2] = X * C * 2;

        sort(formula, formula + 3);

        cout << formula[0] << endl;
        return (0);
    }
/*
    if (AB_piza_X != 0) {
        if ((AB_piza_X * 2 * C) + (Y - X) * B < A * X + B * Y) {
            cout << (AB_piza_X * 2 * C) + (Y - X) * B << endl;
        }
        else {
        cout << A * X + B * Y << endl;
        }
    }
    else if (AB_piza_Y != 0) {
        if ((AB_piza_Y * 2 * C) + (X - Y) * A < A * X + B * Y) {
            cout << (AB_piza_Y * 2 * C) + (X - Y) * A << endl;
        }
        else {
            cout << A * X + B * Y << endl;
        }
    }
*/
}





Measured memory_bytes: 256
ac,tle,re,wa=0,0,0,0
for _ in range(int(input())):

    s=(input())
    if s=='AC':
        ac+=1
    if s=='TLE':
        tle+=1
    if s=='RE':
        re+=1
    if s=='WA':
        wa+=1
print('AC x '+str(ac))

print('WA x '+str(wa))

print('TLE x '+str(tle))

print('RE x '+str(re))

Measured memory_bytes: 69864
#include <cstdio>
typedef long long int64;
static const int MAXN = 2003;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS
 
int binom[MAXN * 2][MAXN * 2] = {{ 0 }};
inline void preprocess_binomials()
{
    binom[0][0] = 1;
    for (int i = 1; i < MAXN * 2; ++i) {
        binom[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            binom[i][j] = (binom[i - 1][j - 1] + binom[i - 1][j])_;
    }
}
inline int fpow(int64 base, int exp)
{
    int64 ans = 1;
    for (; exp; exp >>= 1, (base *= base)__) if (exp & 1) (ans *= base)__;
    return ans;
}
inline int catalan(int n) { return (int64)binom[2 * n][n] * fpow(n + 1, MODULUS - 2)_; }
 
int n, k;
// f[# of total elements][# of red elements] - nnumber of ways to distribute to two sides
int f[MAXN * 2][MAXN * 2] = {{ 0 }};
 
inline void preprocess_transitions()
{
    f[0][0] = 1;
    for (int i = 0; i < MAXN * 2 - 1; ++i) {
        f[i + 1][0] = f[i][0];
        for (int j = 1; j <= i + 1; ++j)
            f[i + 1][j] = (f[i + 1][j - 1] + f[i][j])_;
    }
}
 
int main()
{
    preprocess_binomials();
    scanf("%d%d", &n, &k);
    if (n == k) { printf("%d\n", catalan(n - 1)); return 0; }
 
    preprocess_transitions();
    int64 ans = 0;
    for (int m = n - k + 1; m <= n; ++m) {
        int akai = n - m, aoi = m - 1 - (n - k);
        int64 inc = f[akai + aoi][akai];
        (inc *= binom[m - 2][n - k - 1])__;
        (inc *= fpow(2, n - k - 1))__;
        ans += inc;
    }
    printf("%lld\n", ans _);
 
    return 0;
}


Measured memory_bytes: 124032
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
	return (a<b)?a:b;
}
int max(int a,int b){
	return (a>b)?a:b;
}



signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n;
 cin>>n;
 map<string,int> mp;
 vector<string> v={"AC", "WA", "TLE", "RE"};
 while(n--)
 {
 	string s;
 	cin>>s;
 	mp[s]++;
 }
 for(auto i:v)
 {
 	cout<<i<<" x "<<mp[i]<<endl;
 }

}


Measured memory_bytes: 3672
#include<stdio.h>

int main()
{
	int a[100], n, i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", a + i);
	for (i = n - 1; i > 0; i--)
		printf("%d ", a[i]);
	printf("%d\n", a[0]);

	return 0;
}


Measured memory_bytes: 2048
#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(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e10+1
#define d(x) cerr<<#x<<"="<<x<<endl;

#define MAX 1000001

string a,b;
int dp[3001][3001],tr[3001][3001],maxv;

bool score(int i, int j){
    return a[i]==b[j];
}

int main(void){
    cin>>a>>b;
    repi(i,1,a.size()+1)repi(j,1,b.size()+1){
        maxv=max(dp[i-1][j-1]+score(i-1,j-1),max(dp[i-1][j],dp[i][j-1]));
        if (maxv==dp[i][j-1]){dp[i][j]=maxv; tr[i][j]=1;}
        else if(maxv==dp[i-1][j]){dp[i][j]=maxv; tr[i][j]=-1;}
        else {dp[i][j]=maxv;tr[i][j]=0;}
    }
    int i=a.size(),j=b.size();
    string ans="";
    while(i+j){
        if(i<=0 || j<=0)break;
        if(tr[i][j]==0){ans+=a[i-1]; i--; j--;}
        else if (tr[i][j]==1) j--;
        else i--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int N,a;
  cin >> N;
  stack<int> rev;
  for(int i=0;i<N;i++){
    cin >> a;
    rev.push(a);
  }
  for(int j=0;j<N;j++){
    cout << rev.top();
    rev.pop();
    if(j<N-1){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}


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

int main(){
  int N, M;
  cin >> N;
  vector<string> kuroji(N+100, "0");
  for(int i=0;i<N;i++){
    cin >> kuroji.at(i);
  }
  
  cin >> M;
  vector<string> akaji(M+100, "0");
  for(int i=0;i<M;i++){
    cin >> akaji.at(i);
  }
  
  if(N < M){
    N = M;
  }
  int kuroji_count = 0, kuroji_max = 0;
  for(int i=0;i<N;i++){
    if(kuroji.at(i) == "0"){
      break;
    }
    for(int j=0;j<N;j++){
      if(kuroji.at(i) == kuroji.at(j)){
        kuroji_count += 1;
      }
      if(kuroji.at(i) == akaji.at(j)){
        kuroji_count -= 1;
      }
    }
    if(kuroji_count > kuroji_max){
      kuroji_max = kuroji_count;
    }
    
    kuroji_count = 0;
  }
  
  cout << kuroji_max << endl;
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

c = [10 ** 18] * n
c[0] = 0

for i in range(n):
    for j in range(i, min(n, i + k + 1)):
        c[j] = min(c[j], c[i] + abs(h[i] - h[j]))
print(c[-1])


Measured memory_bytes: 54472
import java.util.*;


public class Main {
    public static void main(String[] args){

        Scanner s = new Scanner(System.in);

      	String sc = s.next();
        HashMap<String, String> wether = new HashMap<String, String>();
      
        wether.put("Sunny", "Cloudy");
        wether.put("Cloudy", "Rainy");
        wether.put("Rainy", "Sunny");
       
        System.out.println(wether.get(sc));
    }
}

Measured memory_bytes: 21204
def query_prod(n)
  $stdout.puts "? #{n}"
  $stdout.flush
  gets.chomp == "Y"
end


def answer_prod(n)
  $stdout.puts "! #{n}"
  $stdout.flush
end

def query(n)
  query_prod(n)
end

def answer(n)
  answer_prod(n)
end

if (0..9).all?{ |i| query(10**i) }
  answer( 10 ** (0..9).find{ |i| query(10**i + 1) } )  
else
  y = (0..9).find{ |y| query(10**y) && !query(10**(y+1)) }
  m = (10**(y+1) ... 10**(y+2)).bsearch{ |i| query(i) }
  answer(m/10)
end


Measured memory_bytes: 2128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl
 
#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;

string s;
int now;
int tt;
int main()
{
  cin>>s;
  now=0;
  int t=s.size();
  tt=t+30;
  s+="dreamdreamdreamdreamdreamdream";
  while(1)
    {
      if(now>=t+15)
	{
	  cout<<"YES"<<endl;
	  return 0;
	}
      if(s.substr(now,7)=="dreamer")
	{
	  if(s.substr(now,10)=="dreamerase")
	    {
	      now+=5;
	    }
	  else now+=7;
	}
      else if(s.substr(now,5)=="dream")
	{
	  now+=5;
	}
      else if(s.substr(now,6)=="eraser")
	{
	  now+=6;
	}
      else if(s.substr(now,5)=="erase")
	{
	  now+=5;
	}
      else break;
    }
  cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, X;
  cin>>N>>X;
  ll a[N];
  for(int i=0;i<N;++i) cin>>a[i];
  ll ans = 0;
  ll zero = 0;
  for(int i=0;i<N-1;++i) {
    if(a[i]+a[i+1]>X) {
      if(a[i]>X) {
        ans += a[i+1];
        a[i+1] = 0;
        ans += a[i] - X;
        a[i] = X;
      }
      else {
        ans += a[i]+a[i+1]-X;
        a[i+1] -= a[i]+a[i+1]-X;
      }
    }
  }
  cout<<ans<<endl;
}



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    vector<int> acc(N + 1);
    acc[0] = 0;
    REP(i, N) {
        cin >> V[i];
        acc[i + 1] = acc[i] + V[i];
    }

    int result = 0;
    REP(left, N + 1) {
        REP(right, N + 1) {
            int m = left + right;
            if (m > min(N, K)) {
                break;
            }
            vector<int> a;
            REP(i, left) {
                a.pb(V[i]);
            }
            REP(i, right) {
                a.pb(V[N - 1 - i]);
            }
            sort(all(a));
            int sum = accumulate(all(a), 0);
            int ops = K - m;
            REP(i, min(ops, m)) {
                if (a[i] < 0) {
                    sum -= a[i];
                } else {
                    break;
                }
            }
            amax(result, sum);
        }
    }
    cout << result << endl;
    return 0;
}



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

int a,b,i;
int A[]={0,1,2,3};

int main(){
	
	cin>>a>>b;
	for(i=1;i<=3;i++){
		if(A[i]==a)
			A[i]=0;
		if(A[i]==b)
			A[i]=0;
	}
	for(i=1;i<=3;i++)
		if(A[i]==i)
			cout<<i<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n;
    cin >> n;

    Int ans = 1;
    for (Int i = 1; i <= n; i++) {
        ans *= i;
        if (MOD < ans) {
            ans %= MOD;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
if A>=B and C>=D:
    print(B+D)
elif A<B and C>=D:
    print(A+D)
elif A>=B and C<D:
    print(B+C)
else:
    print(A+C)

Measured memory_bytes: 3060
#ifdef Rahul
#include "RAHUL.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

#include "atcoder/maxflow"

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int n, m; cin >> n >> m;
  vector<string> a(n);
  for (auto &s : a) cin >> s;
  atcoder::mf_graph<int> g(n * m + 2);
  int src = n * m, snk = n * m + 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) if (a[i][j] != '#') {
      int u = i * m + j;
      if ((i + j) & 1) {
        g.add_edge(u, snk, 1);
        if (i < n - 1 && a[i + 1][j] != '#') {
          g.add_edge(u + m, u, 1);
        }
        if (j < m - 1 && a[i][j + 1] != '#') {
          g.add_edge(u + 1, u, 1);
        }
      } else {
        g.add_edge(src, u, 1);
        if (i < n - 1 && a[i + 1][j] != '#') {
          g.add_edge(u, u + m, 1);
        }
        if (j < m - 1 && a[i][j + 1] != '#') {
          g.add_edge(u, u + 1, 1);
        }
      }
    }
  }
  cout << g.flow(src, snk) << '\n';
  for (auto e : g.edges()) {
    if (e.from == src || e.to == snk) continue;
    if (e.flow == 1) {
      auto [x1, y1] = array{e.from / m, e.from % m};
      auto [x2, y2] = array{e.to / m, e.to % m};
      if (x1 == x2) {
        if (y2 < y1) swap(y1, y2);
        a[x1][y1] = '>';
        a[x2][y2] = '<';
      } else {
        if (x2 < x1) swap(x1, x2);
        a[x1][y1] = 'v';
        a[x2][y2] = '^';
      }
    }
  }
  for (auto &s : a) cout << s << '\n';
}


Measured memory_bytes: 5496
using System;
using System.Linq;

namespace ABC110_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var X = nm[2];
            var Y = nm[3];
            var x = Console.ReadLine().Split().Select(int.Parse).ToList();
            var y = Console.ReadLine().Split().Select(int.Parse).ToList();
            var w = false;

            x.Add(X);
            y.Add(Y);

            if (x.Max() >= y.Min()) w = true;

            Console.WriteLine(w ? "War" : "No War");
        }
    }
}


Measured memory_bytes: 13396
import sys
input = sys.stdin.readline

dic = {}
count_dic = {}
n = int(input())

for i in range(n):
    x = input().rstrip('\n')
    text = ''.join(sorted(list(x)))
    if text not in dic:
        dic[text] = 0
        count_dic[text] = 1
    else:
        dic[text] += count_dic[text]
        count_dic[text] += 1

ans = sum(list(dic.values()))
print(ans)

Measured memory_bytes: 24212
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        int count = Integer.MAX_VALUE;
       
        Parent: for(int i = 0; i < n; i++) {
          int value = sc.nextInt();
          String[] bin = Integer.toBinaryString(value).split("");
          Child: for(int index = 0; index < bin.length; index++) {
            if (bin[bin.length - 1 - index].equals("1")) {
              if (index < count) {
                count = index;
              }
              break Child;
            }
          }
        }
		System.out.println(count);
	}
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans=0;
  for(int i=0; i<=K; i++) {
    for(int j=0; j<=K; j++) {
      if (0 <=S-i-j && S-i-j <= K) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 764
N,M = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(M)]

se1 = set()
se2 = set()

for a,b in AB:
  if a == 1:
    se1.add(b)
  if b == N:
    se2.add(a)
    
se = se1 & se2
if se:
  ans = 'POSSIBLE'
else:
  ans = 'IMPOSSIBLE'
print(ans)


Measured memory_bytes: 46480
#include<iostream>
#include<algorithm>
#define INF (1e9)
#define N c[n-1]*2
using namespace std;
int main(){
  int n,c[50],k=0;
  while(cin>>n&&n){
    k++;
    for(int i=0;i<n;i++)cin>>c[i];
    cout<<"Case #"<<k<<": ";
    if(c[0]==1){
      int dp[2001]={};
      for(int i=1;i<=N;i++)dp[i]=INF;
      for(int i=0;i<n;i++)
	for(int j=c[i];j<=N;j++)
	  dp[j]=min(dp[j],dp[j-c[i]]+1);
      int f=0;
      for(int i=1;i<=N;i++){
	int a=0,s=i;
	for(int j=n-1;s!=0;j--){
	  a+=s/c[j];
	  s%=c[j];
	}
	if(a!=dp[i]){f=1;break;}
      }
      if(f)cout<<"Cannot use greedy algorithm"<<endl;
      else cout<<"OK"<<endl;
    }
    
    else cout<<"Cannot pay some amount"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    vector<bool> ABC(3, false);
    rep (i, 0, 2) {
        int in; cin >> in;
        if (in == 1)
            ABC[0] = true;
        else if(in == 2)
            ABC[1] = true;
        else if (in == 3)
            ABC[2] = true;
    }

    rep (i, 0, ABC.size()) {
        if (ABC[i] == false) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
S = input()
T = list(input())
l = len(S) - len(T) + 1
ans = len(T)
for i in range(l):
  s = list(S[i:i+len(T)])
  ans = min(ans, len([0 for i in range(len(T)) if T[i] != s[i]]))
print(ans)

Measured memory_bytes: 9112
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const long long inf = ((long long)1 << 63) - 6;
int main()
{
    long long n,mi = inf;
    cin >> n;
    for(int i = 1 ; i <= 5 ; i ++)
    {
        long long t;
        cin >> t;
        mi = min(t,mi);
    }
    long long ans = (n+mi-1)/mi - 1;
    cout << ans + 5 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<cctype>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	ll f=1,sum=0;char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();}
	while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}

int main()
{
	int a=read(),b=read();
	int a1=a+b,a2=a-b,a3=a*b;
	cout<<max(max(a1,a2),a3);
	return 0;
}


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

int main() {
	int A,B,C,K;
    cin >> A >> B >> C >> K;
    if(K<=A){
        cout << K << endl;
    }
    else if(K<=A+B){
        cout << A << endl;
    }
    else{
        cout << A-(K-A-B) << endl;
    }
}

Measured memory_bytes: 3520
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        Set<Integer> possibles = new HashSet<>();
        possibles.add(1);
        int[] counts = new int[n];
        for (int i = 0; i < n; i++) {
            counts[i] = 1;
        }
        for (int i = 0; i < m; i++) {
            int from = scanner.nextInt();
            int to = scanner.nextInt();
            if (possibles.contains(from)) {
                possibles.add(to);
            }
            counts[from - 1]--;
            counts[to - 1]++;
            if (counts[from - 1] == 0) {
                possibles.remove(from);
            }
        }
        System.out.println(possibles.size());
    }
}

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

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int N;
ll A[100010];

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

  int g;
  g = gcd(A[0], A[1]);
  rep(i, N-2) g = gcd(g, A[i+2]);

  cout << g << endl;
}


Measured memory_bytes: 4276
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    k = [i&-i for i in a]
    if len(set(k)) > 1 or all([i == 1 for i in k]):
        print(0)
        return
    a = [i>>1 for i in a]
    l = a[0]
    for i in a[1:]:
        g = gcd(l,i)
        l *= i//g
    print(m//l-m//(2*l))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 63332
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    ll N;
    cin >> N;
    vector<ll> H(N);
    rep(i,N) cin >> H[i];
    for(int i=N-1;i>0;i--){
        if(H[i-1]-H[i]>1){
            cout << "No" << endl;
            return 0;
        }else if(H[i-1]-H[i]==1){
            H[i-1]-=1;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))

p_mod = (10**9)+7

A_sum = [A[0]]
a_before = A_sum[0]
for a in A[1:]:
    A_sum.append(a+a_before)
    a_before = a+a_before

ans=0
for n in range(N-1):
    ans += (A[n]%p_mod)*((A_sum[-1]%p_mod)-(A_sum[n]%p_mod))%p_mod
#     print(ans)
print(ans%p_mod)

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

using namespace std;

bool check(int n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0) return false;
	}
	return true;
}

int main(){
	long long int x;
	cin >> x;
	for(int i=x;1;i++)
		if(check(i)) { cout << i << endl; return 0; }
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import defaultdict

n, m = map(int, input().split())
edges = defaultdict(lambda: defaultdict(lambda: float("inf")))
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1][b-1] = 1
    edges[b-1][a-1] = 1

def dijkstra(s, n, cost):
    d = [float("inf")] * n
    d[s] = 0
    que = [[0, s]]
    prev = {}
    heapify(que)
    while len(que) > 0:
        u_dist, u = heappop(que)
        #まだ使われてない頂点の中から最小の距離のものを探す
        for v in edges[u].keys():
            alt = d[u] + cost[u][v]
            if d[v] > alt:
                prev[v] = u
                d[v] = alt
                heappush(que, [alt, v])
    return d, prev

_, prev = dijkstra(0, n, edges)
ans = []
ans.append("Yes")
for i in range(1, n):
    ans.append(str(prev[i]+1))
print("\n".join(ans))

Measured memory_bytes: 170800
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();
int b = sc.nextInt();
int area = a*b;
int length =2*(a+b);
System.out.println(area + " " + length);
sc.close();
}
}


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

const ll mod = 1000000007;
string in;
ll n;
ll dp[5005][5005];

ll modexp(ll b, ll e, ll m){
    ll r = 1;
    while(e > 0){
        if((e & 1) == 1){
            r = (r * b) % m;
        }
        e = e / 2;
        b = (b * b) % m;
    }
    return r;
}

int main(){
    cin >> n >> in;
    int p = in.size();

    dp[0][0] = 1;
    for(int x = 1 ; x <= n; x++){
        for(int y = 0 ; y <= n; y++){
            if(y != 0) dp[x][y] += (dp[x - 1][y - 1] * 2) % mod;
            else dp[x][y] += dp[x - 1][y];
            dp[x][y] += dp[x - 1][y + 1];
            dp[x][y] %= mod;

            //printf("haha %d %d %lld\n",x,y,dp[x][y]);     
        }
    }
    ll ans = dp[n][p];
    ll now = modexp(2,mod - 2, mod);

    for(int x = 1; x <= p; x++){
        ans = (ans * now) % mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 195712
#include<stdio.h>
int main(){
  int n,i,count=1;
  scanf("%d",&n);
  char s[n+1];
  scanf("%*c%s",s);
  for(i=0;i<n-1;i++){
    if(s[i]!=s[i+1])
      count++;
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 384
# YouTube
from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)

def dfs(u):
    ok[u] = 1
    for v in to[u]:
        if ok[v]: continue
        dfs(v)

def rdfs(u):
    ok[u] += 2
    for v in fr[u]:
        if ok[v] > 1: continue
        rdfs(v)

inf = 10 ** 9
to = defaultdict(list)
fr = defaultdict(list)
abc = []
n, m, p = map(int, input().split())
ok = [0] * n
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    c = -(c - p)
    to[a].append(b)
    fr[b].append(a)
    abc.append([a, b, c])
dfs(0)
rdfs(n - 1)
score = [inf] * n
score[0] = 0
for i in range(n):
    stop = True
    for a, b, c in abc:
        if ok[a] < 3 or ok[b] < 3: continue
        tmp = score[a] + c
        if tmp < score[b]:
            score[b] = tmp
            stop = False
    if stop:
        print(max(0, -score[n - 1]))
        break
else:
    print(-1)


Measured memory_bytes: 66008