akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    while (true) {
        val (n, x) = readLine()!!.split(" ").map(String::toInt)

        if ((n == 0) and (x == 0)) {
            break
        }

        var combinationNum = 0

        for (a in (1..n)) {
            for (b in (1 until a)) {
                if (x <= a + b) {break}
                val c = x - (a + b)
                if (c < b) {
                    combinationNum += 1
                } else {
                    continue
                }
            }
        }

        println("$combinationNum")
    }
}



Measured memory_bytes: 31800
#include<stdio.h>
void int_swap(int *a, int *b){
    int temp;
    temp=*b;
    *b=*a;
    *a=temp;
}
int gcd(int a, int b){
    int c;
    c=a%b;
    if(c==0) return b;
    if(c==1) return 1;
    gcd(b,c);
}

main(){
    int i,j,k;
    scanf("%d %d",&i,&j);
    if(i<j) int_swap(&i,&j);
    printf("%d\n",gcd(i,j));
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, K;
    cin >> N >> K;
    if(K == 1) cout << 0 << endl;
    else cout << N-K << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int isprime(int n){
	for(int i = 2;i * i <= n;i++){
		if(n % i == 0) return 0;
	}
	return 1;
}

int main(){
	int n, q1;
	while(scanf("%d", &n) != EOF){
		if(n == 0) break;
		for(int i = n;i >= 2;i--){
			if(isprime(i) == 1 && isprime(i-2) == 1){
				q1 = i;
				break;
			}
		}
		printf("%d %d\n", q1 - 2, q1);
	}
	return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;

vector<int> G[201010];
vector<bool> seen;

vector<int> add;
vector<int> cost;

void dfs(int v) {
    seen[v] = true;
    for(auto nv: G[v]) {
        if(seen[nv]) continue;
        cost[nv] = cost[v] + add[nv];
        dfs(nv);
    }
}


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

int N,Q; cin >> N >> Q;
rep(i,N-1) {
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
}

add.assign(N,0);
rep(i,Q) {
    int p,x; cin >> p >> x;
    p--;
    add[p] += x;
}

cost.assign(N,0);
cost[0] = add[0];

seen.assign(N, false);
dfs(0);

rep(i,N) cout << cost[i] << ' ';
cout << endl;

return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int A, B, C, x, y;
  cin >> A >> B >> C >> x >> y;

  int last = 2 * max(x, y);
  int ans = 1001001001;
  for (int c = 0; c <= last; c += 2) {
    int a = max(0, x - c / 2);
    int b = max(0, y - c / 2);
    ans = min(ans, a * A + b * B + c * C);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int N;

    cin >> N;

    bool f = false;

    for(int i = 0; i < N; i++){
        char s;
        cin >> s;
        if(s == 'Y'){
            f = true;
        }
    }

    if(f){
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }

    return 0;
}

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

using namespace std;

#define INF 210000000
#define int long long

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		int n = a * b;
		int m = c * d;
		if(n > m) cout << n << endl;
		else cout << m << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    a = x - a;
    b = x - b;
    cout << (abs(a) < abs(b) ? "A" : "B");
    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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;
  ll a[n];
  ll len = 0;

  REP(i,n){
    cin>>a[i];
    len += a[i];
  }

  ll now = 0;
  ll ans = pow(10,11);
  REP(i,n){
    now += a[i];
    ll amari = len - now;
    ans = min(ans,abs(now-amari));
  }
  cout<<ans<<endl;

 

  return 0;
}

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

int main(){
    int n, f;
    cin >> n >> f;

    map<string, map<string, int>> shop;
    
    for(int i = 0; i < n; i++){
        int m;
        cin >> m;

        string x[m];
        for(int i = 0; i < m; i++)  cin >> x[i];

        for(int i = 0; i < m; i++){
            for(int j = 0; j < m; j++){
                if(i == j)  continue;
                shop[x[i]][x[j]]++;
            }
        }
    }

    set<pair<string,string>> ans;

    for(auto x : shop){
        for(auto y : x.second){
            if(y.second >= f){
                string s = x.first;
                string t = y.first;
                if(s > t)   swap(s,t);
                ans.insert({s, t});
            }
        }
    }

    cout << ans.size() << endl;

    for(auto x : ans){
        cout << x.first << " " << x.second << endl;
    }

    return 0;
}


Measured memory_bytes: 4072
import java.util.*;

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

    int start = 1;
    HashSet<Long> a = new HashSet<Long>();
    int[] b = new int[]{0,1,2,3,4,5,6,7,8,9};
    while (a.size() < k){
      a = find(a,b,start,0);
      start += 1;
    }

    ArrayList<Long> c = new ArrayList<Long>(a);
    Collections.sort(c);
    System.out.println(c.get(k-1));

  }

  static HashSet<Long> find(HashSet<Long> a, int[] b, int n, long now){
    String check = now+"";
    if ((now != 0) && (check.length() >= n)){
      a.add(now);
      return a;
    }

    int which = (int) now%10;

    now = now*10;

    for (int i=0;i<10;i++){
      long g = 0;
      if (now != 0){
        if (Math.abs(which - b[i]) > 1){
          continue;
        }
        g = now + b[i];
      }
      else{
        g = b[i];
      }

      if (g == 0){
        g = 1;
      }
      a = find(a,b,n,g);
    }

    return a;

  }

}


Measured memory_bytes: 72072
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;
const int N=16;
const int mod=(int)1e9+7;

int a[N],g[1<<N],f[N][1<<N],n,m;
ll fac[1<<N],inv[1<<N];

il void inc(int &x,const int &y){
	if((x+=y)>=mod) x-=mod;
}

il void dec(int &x,const int &y){
	if((x-=y)<0) x+=mod;
}

il ll qpow(ll x,int y){
	ll ans=1;
	while(y){
		if(y&1) ans=ans*x%mod;
		x=x*x%mod;
		y>>=1;
	}
	return ans;
}

il ll C(const int &n,const int &k){
	if(k>n) return 0;
	return fac[n]*inv[k]%mod*inv[n-k]%mod;
}

int main(){
//	fileio("test");
	fac[0]=1,inv[0]=1;
	rep(i,1,(1<<N)-1){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=qpow(fac[i],mod-2);
	}
	scanf("%d%d",&n,&m);
	int all=(1<<n)-1;
	rep0(i,m) scanf("%d",a+i);
	f[m][0]=1;
	per0(i,m){
		rep0(comb,1<<n){
			int &cur=f[i][comb];
			cur=f[i+1][comb];
			rep0(j,n) if(comb>>j&1){
				inc(cur,C((1<<n)-a[i]-comb+(1<<j),(1<<j)-1)*f[i+1][comb^(1<<j)]%mod);
			}
		}
	}
	rep0(comb,1<<n){
		int rest=all^comb;
		ll dt=1;
		rep0(i,n) if(rest>>i&1){
			dt=dt*C(rest,1<<i)%mod;
			rest^=1<<i;
		}
		g[comb]=dt*f[0][comb]%mod;
	//	cerr<<comb<<" : "<<f[0][comb]<<" "<<g[comb]<<endl;
	}
	int ans=0;
	rep0(i,1<<n){
		if(__builtin_popcount(i)&1) dec(ans,g[i]);
		else inc(ans,g[i]);
	}
	ll dt=1<<n;
	rep0(i,n) dt=dt*fac[1<<i]%mod;
	printf("%d\n",dt*ans%mod);
	return 0;
}


Measured memory_bytes: 5632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<pair<ll, ll>> A;
    rep(i,N) {
        ll t,d; cin >> t >> d;
        A.emplace_back(d,t);
    }

    sort(all(A)); reverse(all(A));

    set<int> dic;
    vector<ll> AA,B,C;
    rep(i,N) {
        ll t,d;
        tie(d,t) = A[i];
        if (i < K) {
            if (!dic.count(t)) {
                AA.emplace_back(d);
                dic.emplace(t);
            } else B.emplace_back(d);
        } else {
            if (!dic.count(t)) {
                C.emplace_back(d);
                dic.emplace(t);
            }
        }
    }
    ll M = B.size();
    ll L = C.size();
    vector<ll> BB(M+1),CC(L+1);
    ll ans = 0;
    rep(i,M) BB[i+1] = BB[i]+B[i];
    rep(i,L) CC[i+1] = CC[i]+C[i];
    for (ll i = 0; i < min(L+1LL,M+1LL); i++) {
        ll l = CC[i] + BB[M-i] + (K-M+i)*(K-M+i);
        chmax(ans,l);
    }
    ans += accumulate(all(AA),0LL);

    cout << ans << endl;
}

Measured memory_bytes: 7664
boundance,goal=map(int,input().split())
length = list(map(int,input().split()))
place=0
cnt=1

for x in range(len(length)):
    if place<goal:
        place+=length[x]
        if place<=goal:
            cnt+=1
        if place>goal:
            pass
    if place>=goal:
        pass
print(cnt)    


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

ll dp[110][10];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W, K;
    cin >> H >> W >> K;
    dp[0][0] = 1;
    rep(i, H) {
        rep(j, W) {
            rep(bit, 1 << (W-1)) {
                // 横線が隣り合っていたらcontinueする
                bool ok = true;
                rep(k, W-2) {
                    if (((bit >> k) & 1) && ((bit >> (k + 1) & 1))) {
                        ok = false;
                    }
                }
                if (!ok) continue;

                if (j >= 1 && ((bit >> (j - 1)) & 1)) {
                    dp[i+1][j-1] += dp[i][j];
                    dp[i+1][j-1] %= mod;
                }
                else if (j <= W - 2 && ((bit >> j) & 1)) {
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= mod;
                }
                else {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= mod;
                }
            }
        }
    }

    cout << dp[H][K-1] << endl;
    return 0;
}

Measured memory_bytes: 256
// betaだとScoresに反映されない？
#include <cstdio>

int main() {
  int N;
  scanf("%d", &N);
  
  int res=0;
  for (int i=0; i<N; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    res += r-l+1;
  }
  
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int main(){
	ll k;
	scanf("%lld",&k);
	puts("50");
	rep(i,0,50)printf("%lld%c",(49+k/50)+(i<k%50?51-k%50:-k%50),i==49?'\n':' ');
	return 0;
}
	

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
#include <list>
#include <algorithm>
using namespace std;

#define N 1046257

bool checkMax(int x, int w[], int n, int k)
{
    int sum = 0, c = 0;
    for (int i = 0; i < n; i++)
    {
        if (sum + w[i] > x)
        {
            sum = w[i];
            c++;
        }
        else
            sum += w[i];
    }
    if (c < k)
        return true;
    else
        return false;
}

int main()
{
    int n, k, mn = 0, mx = 1, mid;
    cin >> n >> k;
    int w[n];
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        mx += w[i];
        mn = max(mn, w[i]);
    }
    mn--;
    while (mx != mn + 1)
    {
        // cout << mx <<" " << mn << "\n";
        mid = (mx + mn) / 2;
        if (checkMax(mid, w, n, k))
            mx = mid;
        else
            mn = mid;
    }

    cout << mx << "\n";

    return 0;
}


Measured memory_bytes: 3452
let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun h -> h in
  Array.sort compare hs;
  Printf.printf "%d\n" @@
  Array.fold_left min max_int @@ 
  Array.init (n - k + 1) @@ fun i -> hs.(i + k - 1) - hs.(i)


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

using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;

  char c;

  for(int i = 0;i<h+2;i++){
    for(int j = 0; j<w+2;j++){
      if(i==0 || i==h+1){
        cout << '#';
      }
      else{
        if(j==0||j==w+1) cout << '#';
        else{
          cin >> c;
          cout <<c;
        }
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(int argc, const char * argv[]) {
    
    int a;
    cin >> a;
    
    if(a==0) cout << 1 << endl;
    else cout << 0 << endl;
    
    return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int X, T, N;
  cin >> N >> X >> T;
  if(N % X == 0){
    cout << N / X * T <<endl;
  }else{
    cout << (N / X + 1) * T <<endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <map>

int rec_fibonacci(int n, std::map<int, int>* m) {
  if (n == 0 || n == 1)
    return 1;
  if (m->find(n) == m->end())
    (*m)[n] = rec_fibonacci(n-1, m) + rec_fibonacci(n-2, m);
  return (*m)[n];
}

int fibonacci(int n) {
  std::map<int, int> m;
  return rec_fibonacci(n, &m);
}

int main() {
  int n;
  std::cin >> n;
  std::cout << fibonacci(n) << std::endl;
}

Measured memory_bytes: 3100
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


ll gcd(ll a, ll b) {
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}


int main() {
	fastio;

	ll N;
	cin >> N;
	vll A(N);
	rep(i, N) cin >> A[i];
	sort(all(A));
	for (ll i = 0; i + 1 < N; i += 2) {
		if (A[i] <= 0 && A[i + 1] <= 0) {
			A[i] *= -1, A[i + 1] *= -1;
		}
		else if (A[i] <= 0 && 0 < A[i + 1]) {
			if (abs(A[i]) > abs(A[i + 1])) {
				A[i] *= -1, A[i + 1] *= -1;
			}
		}
		else break;
	}
	cout << accumulate(all(A), (ll)0) << endl;
}

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

using namespace std;


int main(){

    long long a, b, c; cin >> a >> b >> c;

     long long add = a%b;

    if(add == 0){
         if(add == c)
         cout<<"YES"<<endl;
         else cout<<"NO"<<endl;

        return 0;
    }

    for(long long i=add; i<=10000; i+=add)
    {
        if(i%b == c%b){
            cout<<"YES";
          return 0; }
    }


    cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 10

int main(void){
	char a[SIZE][SIZE+1]; int i, j;
	
	while(~scanf("%s",a[0])){
		for(i=0; i<SIZE; i++) a[0][i]-='0';
		
		for(i=1; i<SIZE; i++)
			for(j=0; j<SIZE-i; j++)
				a[i][j]=(a[i-1][j]+a[i-1][j+1])%10;
				
		printf("%d\n",a[SIZE-1][0]);
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int a[] = new int[N];
    for(int i=0;i<N;i++){
      a[i]=sc.nextInt();
    }
    int ans=0;
    for(int i=0;i<N;i++){
      if(a[a[i]-1]==i+1){
        ans++;
      }

    }
    System.out.println(ans/2);
  }
    


}


Measured memory_bytes: 49740
#include <stdio.h>

int main()
{
  int x, y, i=1, j, ans = 0;

  scanf("%d %d", &x, &y);

  while (ans == 0) {
    if (x % i == 0) {
      j = x / i;
      if (x % j == 0 && y % j == 0) ans = j;
    }
    i++;
  }
  printf("%d\n", ans);
}



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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll x = in(), y = in();

    ll sx = x;
    ll sy = y;
    while (x >= 2 || y >= 2)
    {
        ll yd2 = y / 2;
        ll xd2 = x / 2;
        sx += yd2;
        sy += xd2;
        x %= 2;
        y %= 2;
        x += yd2;
        y += xd2;
    }
    if (((sx / 2) ^ (sy / 2)) == 0)
        puts("Brown");
    else
        puts("Alice");
}

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAX = 202020;

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

inline void add(long long &x, long long y) {
  x += y;
  if(x >= mod) x -= mod;
}

inline void sub(long long &x, long long y) {
  x -= y;
  if(x < 0) x += mod;
}

inline long long mul(long long x, long long y) {
  return x % mod * y % mod;
}

inline long long inverse(long long x) {
  x = (x % mod + mod) % mod;
  long long y = mod, u = 1, v = 0;
  while(y) {
    long long t = x / y;
    x -= t * y; swap(x, y);
    u -= t * v; swap(u, v);
  }
  return (u % mod + mod) % mod;
}

inline long long power(long long x, long long y) {
  long long res = 1;
  while(y) {
    if(y & 1) res = mul(res, x);
    x = mul(x, x);
    y >>= 1;
  }
  return res;
}

inline void pre_mod_nCk() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = mul(fac[i - 1], i);
    inv[i] = mod - mul(inv[mod % i], mod / i);
    finv[i] = mul(finv[i - 1], inv[i]);
  }
}

inline long long nCk(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return mul(fac[n], mul(finv[k], finv[n - k]));
}
long long n, m, k;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n >> m >> k;
  cerr << n << " " <<  m << " " << k << endl;
  pre_mod_nCk();
  long long tate = 0;
  for (long long x = 1; x < n; x++) {
    add(tate, mul(x, n - x));
  }
  (tate *= (m * m % mod)) %= mod;
  cerr << tate << endl;
  long long yoko = 0;
  for (long long x = 1; x < m; x++) {
    add(yoko, mul(x, m - x));
  }
  (yoko *= (n * n % mod)) %= mod;
  //cerr << tate << " " << yoko << endl;
  long long ans = (tate + yoko) % mod;
  //cerr << ans << endl;
  cout << mul(ans, nCk((int) (n * m - 2), (int) (k -2))) << endl;
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	ll n;cin >> n;
	vector<pair<pair<ll, ll>, ll>> v;
	
	REP(i,n){
		ll a, b, c;
		cin >> a >> b >> c;
		v.PB(MP(MP(a, b), c));
	}
	
	if(n == 1){
		cout << v[0].FI.FI << ' ' << v[0].FI.SE << ' ' << v[0].SE << endl;
		return 0;
	}
	
	REP(i,101){
		REP(j,101){
			
			ll now;
			REP(k,n)if(v[k].SE != 0)now = v[k].SE + abs(j - v[k].FI.FI) + abs(i - v[k].FI.SE);
			bool flag = true;
			for(ll k = 0;k < n;k++){
				if(v[k].SE != max(now - abs(j - v[k].FI.FI) - abs(i - v[k].FI.SE), 0LL)){
					flag = false;
				}	
			}
			
			if(flag && now > 0){
				cout << j << ' ' << i << ' ' << now << endl;
				return 0;
			}
			
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

bool dp[80][80][16000];

class E {

public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int h, w; cin >> h >> w;
      vector<vector<int>> mat(h, vector<int>(w));
      rep(i, h) {
        rep(j, w) {
          int a; cin >> a;
          mat[i][j] = a;
        }
      }
      rep(i, h) {
        rep(j, w) {
          int b; cin >> b;
          mat[i][j] -= b;
          mat[i][j] = abs(mat[i][j]);
        }
      }



      rep(i, h) {
        rep(j, w) {
          rep(k, 16000) {
            dp[i][j][k] = false;
          }
        }
      }

      dp[0][0][8000+mat[0][0]] = true;
      dp[0][0][8000-mat[0][0]] = true;

      rep(i, h) {
        rep(j, w) {
          if (j+1<w) {
            rep(k, 16000) {
              if (dp[i][j][k] && k+mat[i][j+1]<16000) {
                dp[i][j+1][k+mat[i][j+1]] = true;
              }
              if (dp[i][j][k] && k-mat[i][j+1]>=0) {
                dp[i][j+1][k-mat[i][j+1]] = true;
              }
            }
          }

          if (i+1<h) {
            rep(k, 16000) {
              if (dp[i][j][k] && k+mat[i+1][j]<16000) {
                dp[i+1][j][k+mat[i+1][j]] = true;
              }
              if (dp[i][j][k] && k-mat[i+1][j]>=0) {
                dp[i+1][j][k-mat[i+1][j]] = true;
              }
            }
          }
        }
      }

      int ans = INT_MAX;
      rep(k, 16000) {
        if (dp[h-1][w-1][k]) {
          chmin(ans, abs(8000-k));
        }
      }
      cout << ans << endl;


    }
};

signed main() {
  E solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 100352
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main(){
    string s;
    cin >> s;
    map<char,int> count;
    for(char x : s){
        count[x]++;
    }
    bool flag = true;
    for(auto p : count){
        if(p.second != 2){
            flag = false;
        }
    }
    if(flag) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3560
let A = readLine()!
let B = readLine()!
if A.characters.count > B.characters.count {
    print("GREATER")
} else if A.characters.count < B.characters.count {
    print("LESS")
} else if A > B {
    print("GREATER")
} else if A < B {
    print("LESS")
} else {
    print("EQUAL")
}

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdio.h>
using namespace std;
#define ll long long
const int maxn = 100005;
bool isp[maxn];
int cnt[maxn];
void shai() {
    memset(cnt, 0, sizeof cnt);
    memset(isp, true, sizeof isp);
    for (ll i = 2; i < maxn; i++)
        if (isp[i])
            for (ll j = i*i; j < maxn; j+=i)
                isp[j] = false;
}
int main(int argc, char const *argv[])
{
    //freopen("/Users/huangjiaming/Documents/Algorithm/oj/data.in", "r", stdin);
    int n, l, r;
    shai();
    for (int i = 1; i < maxn; i++)
        if (isp[i] && isp[(i+1)/2]) cnt[i] = 1;
    cnt[2] = cnt[1] = 0;
    for (int i = 1; i < maxn; i++)
        cnt[i] += cnt[i-1];
    cin >> n;
    while (n--) {
        cin >> l >> r;
        printf("%d\n", cnt[r]-cnt[l-1]);
    }
    return 0;
}

Measured memory_bytes: 1784
(* O(2^|s|) *)
let s = read_line () in
let ds = Array.to_list @@ Array.init (String.length s) @@ fun i -> int_of_char s.[i] - 48 in
let rec calc sum n = function
| [] -> sum + n
| d :: ds2 -> calc (sum + n) d ds2 + calc sum (10 * n + d) ds2 in
calc 0 (List.hd ds) (List.tl ds) |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>
#include <stdbool.h>

int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(int a, int b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	int n, a[101], ans = 0;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1 && a[i] % 2 == 1)
			ans++;
	}
	printf("%d",ans);
	return 0;
}//pd pdp

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec h(n);
  for(ll i=0;i<n;i++) cin >> h[i];
  vec dp(n,inf);
  dp[0]=0;
  for(ll i=0;i<n;i++) {
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
    if(i<n-1) dp[i+2]=min(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,k;
    cin >> k >> n;
    vector <long long> a;
    for(int i = 0; i < n; i++){
        long long tmp = 0;
        cin >> tmp;
        a.push_back(tmp);
    }
    vector <long long> diff;
    for(int i = 0; i<= n; i++){
        if(i<(n-1)){
            diff.push_back(a[i+1]-a[i]);
            continue;
        }
        if(i==(n-1)){
            long long tmp=0;
            tmp+=a[0];
            tmp+=(k-a[n-1]);
            diff.push_back(tmp);
            continue;
        }
    }
    sort(diff.begin(),diff.end());
    cout << k-diff.back() << endl;
    return 0;
}

Measured memory_bytes: 4976
#include<stdio.h>

int main(void){

    int m[50],f[50],r[50],i=0;
    while(1){
        scanf("%d %d %d", &m[i], &f[i], &r[i]);
        if(m[i]==-1&&f[i]==-1&&r[i]==-1) break;
        i++;
    }
    int j=0,D;
    while(1){
        if(j==i) break;
        D=m[j]+f[j];
    if(m[j]==-1||f[j]==-1){
        printf("F\n");
    }else{
        if(D>=80){
            printf("A\n");
        }else if(65<=D&&D<80){
            printf("B\n");
        }else if(50<=D&&D<65){
            printf("C\n");
        }else if(30<=D&&D<50){
            if(r[j]>=50){
                 printf("C\n");
            }else{
                 printf("D\n");
            }
        }else{
            printf("F\n");
        }
    }

    j++;
    }
    return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
int n,m;
int A[2010][2010],B[2010][2010];
char s[2010][2010];
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n,m);
  for(int i=1;i<=n;++i) scanf("%s",s[i]+1);
  for(int i=1;i<=m;++i) {
    A[1][i]=1;
    for(int j=2;j<=n;++j) if(s[j][i]!='#') {
      if(s[j-1][i]!='#') A[j][i]=A[j-1][i];
      else A[j][i]=j;
    }
    B[n][i]=n;
    for(int j=n-1;j;--j) if(s[j][i]!='#') {
      if(s[j+1][i]!='#') B[j][i]=B[j+1][i];
      else B[j][i]=j;
    }
  }
  int res=0;
  for(int i=1;i<=n;++i) {
    for(int j=1;j<=m;++j) if(s[i][j]!='#') {
      int p=j; while(p!=m&&s[i][p+1]!='#') ++p;
      for(int k=j;k<=p;++k) {
        res=max(res,p-j+1+B[i][k]-A[i][k]);
      }
      j=p;
    }
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 35712
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

vector<vector<int>> g;
vector<ll> cnt;
vector<int> a;
vector<ll> ans;
int n;

ll dfs(int v, int p) {
    ll sz = 1;
    ll c = cnt[a[v]];
    if (v == 0) {
        for (int u : g[v]) {
            if (u == p) continue;
            ll q = cnt[a[v]];
            ll d = dfs(u, v);
            sz += d;
            ll k = d - cnt[a[v]] + q;
            ans[a[v]] -= k * (k + 1) / 2;
        }
        for (int i = 0; i < n; i++) {
            if (i == a[v]) continue;
            ll k = sz - cnt[i];
            ans[i] -= k * (k + 1) / 2;
        }
    }
    else {
        for (int u : g[v]) {
            if (u == p) continue;
            ll q = cnt[a[v]];
            ll d = dfs(u, v);
            sz += d;
            ll k = d - cnt[a[v]] + q;
            ans[a[v]] -= k * (k + 1) / 2;
        }
    }
    cnt[a[v]] = c + sz;
    return sz;
}

int main() {
    cin >> n;
    a.resize(n);
    cnt.resize(n, 0);
    ans.resize(n, (ll)n*(n + 1) / 2);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0, -1);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 33440
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int gcd(int A, int B) {
    if (A<B) return gcd(B,A);
    if (B==0) return A;
    else return gcd(B, A%B);
}

int main(void) {
    int N;
    vector<int> A;
    cin >> N;
    for (int i=0;i<N;i++) {
        int X;
        cin >> X;
        A.push_back(X);
    }
    vector<int> L(A.size()), R(A.size()), C(A.size());
    L[0] = A[0];
    for (int i=1;i<N;i++) {
        L[i] = gcd(L[i-1], A[i]);
    }
    R[N-1] = A[N-1];
    for (int i=N-2;i>=0;i--) {
        R[i] = gcd(R[i+1], A[i]);
    }
    C[0] = R[1];
    C[N-1] = L[N-2];
    for (int i=1;i<N-1;i++) {
        C[i] = gcd(L[i-1], R[i+1]);
    }
    cout << *max_element(C.begin(), C.end()) << endl;

    return 0;
}

Measured memory_bytes: 1912
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if(a!=1&&b!=1){
      System.out.println(1);
    }else if(a!=2&&b!=2){
      System.out.println(2);
    }else{
      System.out.println(3);
    }
    
    
  }
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;



void solve() {
	VI v(9);
	rep(i, 9) cin >> v[i];
	
	bool flag = true;
	rep(j, 2) {
		if (v[3 + j * 3] - v[j * 3] != v[4 + j * 3] - v[1 + j * 3] || v[4 + j * 3] - v[1 + j * 3] != v[5 + j * 3] - v[2 + j * 3]) {
			flag = false;
		}
	}
	rep(j, 2) {
		if (v[j + 1] - v[j] != v[j + 4] - v[j + 3] || v[j + 4] - v[j + 3] != v[j + 7] - v[j + 6]) {
			flag = false;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
}


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

	solve(); 
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma optimize("unroll-loops");
#pragma optimize("Ofast");
//#include "pch.h"    
using namespace std;
unordered_map<int, bool> here;
 
using ll = long long;
const int nax = 1e5 + 10;
vector<int> edges[nax];

int main() {
    int n, e;
    cin >> n >> e;
    vector<int> h(n + 1);
    for(int i = 1; i <= n; ++i) {
        cin >> h[i];
    }
    
    int ans = 0;
    while(e--) {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    
    
    for(int i = 1; i <= n; ++i) {
        if(edges[i].size() == 0) {
            ++ans;
        }else{
            bool ok = true;
            for(int x : edges[i]) {
                if(h[x] >= h[i]) {
                    ok = false;
                    break;
                }
            }
            if(ok) {
                ++ans;
            }
        }
    }
    
    cout << ans << "\n";
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n){
    cin>>v.at(i);
  }
  int ans = 0;
  rep(i, n) {
    while (v.at(i) > 0) {
      int cnt = i;
      while (cnt < n) {
        if (v.at(cnt) == 0){
          break;
        }
        --v.at(cnt);
        ++cnt;
      }
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    x=int(input())
    c.append(x)
    
dp=set()
dp.add(0)
for i in range(n):
    tmp=dp.copy()
    for v in tmp:
        dp.add(v+c[i])
#dp.sort()[::-1]
ans=0
for i in dp:
    if i%10!=0:
        ans=max(i,ans) 
print(ans)



Measured memory_bytes: 51948
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int a[3];a[0]=0,a[1]=0,a[2]=0;
  for(int i=0;i<3;i++){
    int d=s[i]-'a';
    a[d]++;
  }
  if(a[0]==1&&a[1]==1&&a[2]==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 

using namespace std;

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    string s;
    cin>>s;
    if(s=="RRR") cout<<"3";
    else
    {
        if(s[1]=='R')
        {
            if(s[0]=='R'||s[2]=='R') cout<<"2";
            else cout<<"1";
        }
        else 
        {
            if(s[0]=='R'||s[2]=='R') cout<<"1";
            else cout<<"0";
        }
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    double N;
    cin>>N;
    for(double h=1; h<=3500; ++h){
        for(double n=1; n<=3500; ++n){
            double w=(N*n*h)/(4*h*n-N*n-N*h);
            ll x=w;
            if(x==w&&w>0){cout<<h<<" "<<n<<" "<<(ll)w<<endl; return 0;}
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long int64;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    int mx = INT_MIN, ind;
    for (int i = 0; i < n; ++i) {
	cin >> v[i];
	if (v[i] > mx) {
	    mx = v[i];
	    ind = i;
	}
    }
    int mx2 = INT_MIN;
    for (int i = 0; i < n; ++i) {
	if (v[i] > mx2 && i != ind) {
	    mx2 = v[i];
	}
    }
    for (int i = 0; i < n; ++i) {
	if (i != ind) cout << mx << endl;
	else cout << mx2 << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int x, y;
		scanf("%d",&x);
		if(x != 2)
		{
			scanf("%d",&y);
			if(x == 0) v.push_back(y);
			else if(x == 1) printf("%d\n",v[y]);
		}
		else v.pop_back();
	}
	return 0;
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, Y, x, y, z, count;
  cin >> N >> Y;
  
  count = 0;
  
  for (x = 0; x <= N; x++) {
    for (y = 0; y <= (N-x); y++) {
      if (10000*x + 5000*y + 1000*(N-x-y) == Y) {
        printf("%d %d %d", x, y, N-x-y);
        return 0;
      }
    }
  }
          
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e7+5;
const int mod=1e9+7;
ll a,b,c;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,i,j,k;
  cin >> n;
  double p[n];
  for(i=0;i<n;i++)cin >> p[i];
  double dp[n+1][n+1];
  for(i=0;i<n+1;i++){
    for(j=0;j<=n;j++)dp[i][j]=0;
  }
  dp[0][0]=1.0;
  for(i=1;i<=n;i++){
    dp[i][0]=dp[i-1][0]*(1.0-p[i-1]);
    for(j=1;j<=i;j++)
      dp[i][j]=dp[i-1][j]*(1.0-p[i-1])+dp[i-1][j-1]*p[i-1];
  }
  double ret=0.0;
  for(i=n/2+n%2;i<=n;i++)ret+=dp[n][i];
  printf("%.12f\n",ret);
  return 0;
}


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

using ll=long long int;

constexpr int MAX_N=(1<<18),INF=2*(int)1e6;

using P=std::pair<int,int>;//max,min

int n,d;

std::map<int,P> mapX,mapY;

std::vector<P> maxmin;

std::vector<int> vec,res,ansX,ansY;

P calc(const P& lhs,const P& rhs){

    return P(std::max(lhs.first,rhs.first),std::min(lhs.second,rhs.second));
}

P seg[MAX_N*2-1];

void init(int _n) {

    n=1;

    while(n<_n)
        n*=2;

    for(int i=0;i<n*2-1;++i)
        seg[i]=P(0,INF);

    for(int i=0;i<_n;++i)
        seg[i+n-1]=maxmin[i];

    for(int i=n-2;i>=0;--i)
        seg[i]=calc(seg[i*2+1],seg[i*2+2]);
}

P query(int a,int b,int k,int l,int r){

    if(b<=l||r<=a)
        return P(0,INF);
    
    if(a<=l&&r<=b)
        return seg[k];
    
    return calc(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
}

std::vector<int> solve(std::map<int,P>& map){

    res.clear();
    maxmin.clear();
    vec.clear();

    for(auto&& s : map){
        vec.emplace_back(s.first);
        maxmin.emplace_back(s.second);
    }

    init(maxmin.size());

    for(int i=0;i<vec.size();++i){
        P p=query(i,std::upper_bound(vec.begin(),vec.end(),vec[i]+d)-vec.begin(),0,0,n);
        res.emplace_back(p.first-p.second);
    }

    return res;
}

int main() {

    std::cin>>n>>d;

    int x,y,b;

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

        std::cin>>x>>y>>b;

        if(!mapX.count(b)){
            mapX[b]=P(x,x);
            mapY[b]=P(y,y);
        }
        else{
            mapX[b]=P(std::max(mapX[b].first,x),std::min(mapX[b].second,x));
            mapY[b]=P(std::max(mapY[b].first,y),std::min(mapY[b].second,y));
        }
    }

    ansX=solve(mapX);

    ansY=solve(mapY);

    ll ans=0;

    for(int i=0;i<ansX.size();++i)
        ans=std::max(ans,ll(ansX[i])*ll(ansY[i]));

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 36892
#include <iostream>
#include<string>
#include<sstream>
#include<vector>

using namespace std;
int main()
{
    long long int r,d;
int   arr[2000];
    cin>>r>>d;
    int val,equ;
    cin>>val;
    int counter=0;
  arr[0]=val;
    for(int i=0 ;i<10; i++)
    {
            if(arr[i]<0){ break;}
      if(arr[i]>0){  counter++; arr[i+1] =(arr[i]*r)-d;}

    }
    for(int i=1 ; i<=counter; i++)
    {
        cout<<arr[i]<<endl;
    }





}

Measured memory_bytes: 256