akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> C(N-1), S(N-1), F(N-1);
    for(int i = 0; i < N; i++) cin >> C[i] >> S[i] >> F[i];

    for(int j = 0; j < N-1; j++) {
        int ans = S[j] + C[j];
        for(int i = j+1; i < N-1; i++) {
            if(ans < S[i]) ans = S[i];
            if(ans % F[i] != 0) ans += (F[i] - ans % F[i]);
            ans += C[i];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
N = [int(e) for e in input().split()]
if(N[2]%N[1] !=0):
    ans = (N[2]//N[1])+1
else:
    ans = N[2]//N[1] 
for i in range(1,ans):
    N[0] -= N[3]
    if(N[0] <= 0):
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 61816
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;



int main() {
    int d,i,j,k;
    int c[26];
    int s[365][26];
    cin >> d;
    for(i = 0; i < 26; ++i) cin >> c[i];
    for(i = 0; i < d; ++i) for(j = 0; j < 26; ++j) cin >> s[i][j];

    int arr[365] = {};

    int t1,t2,s1,s2, diff, count;
    count = 0;
    int max, loc;
    int a[26] = {};
    int b[26] = {};
    for(i = 0; i < 365; ++i) {
        for(j = 0; j < 26; ++j) {
            b[j] = s[i][j];
            a[j]++;
        }
        max = *max_element(b,b+26);
        loc = find(b,b+26,max)-b;
        arr[i] = loc;
        a[loc] = 0;
    }
    
    
    while(true) {
        label1:
        for(i = 0; i < d; ++i) {
            for(j = 0; j < 26; ++j) {
                if(arr[i]==j) continue;
                if(count>20000000) goto label2;
                ++count;
                for(s1 = i+1; s1 < d; ++s1) {
                    if(arr[s1]==arr[i]) break;
                }
                for(t1 = i-1; t1 >= 0; --t1) {
                    if(arr[t1]==arr[i]) break;
                }
                for(s2 = i+1; s2 < d; ++s2) {
                    if(arr[s2]==j) break;
                }
                for(t2 = i-1; t2 >= 0; --t2) {
                    if(arr[t2]==j) break;
                }
                diff = s[i][j]-s[i][arr[i]]+(((s1-i)*(s1-i-1))/2+((i-t1)*(i-t1-1))/2-((s1-t1)*(s1-t1-1))/2)*c[arr[i]] + (-((s2-i)*(s2-i-1))/2-((i-t2)*(i-t2-1))/2+((s2-t2)*(s2-t2-1))/2)*c[j];
                if(diff>0) {
                    arr[i] = j;
                    goto label1;
                }
            }
        }
    }
    label2:
    for(i = 0; i < d; ++i) {
        cout<<(arr[i]+1)<<"\n";
    }


    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int vx[] = {1, -1, 0, 0};
int vy[] = {0, 0, 1, -1};

vector<vector<lld>> b;
vector<vector<bool>> z;

void sub(lld x, lld y) {
  queue<tuple<lld, lld, lld>> qu;
  for (lld i = 0; i < 4; i++) {
    qu.push(make_tuple(x + vx[i], y + vy[i], b[x][y]));
  }

  while (!qu.empty()) {
    lld hx, hy, c;
    tie(hx, hy, c) = qu.front();
    qu.pop();

    if (b[hx][hy] > c + 1 || (b[hx][hy] > c && !z[hx][hy])) {
      b[hx][hy] = z[hx][hy] ? c + 1 : c;
      for (lld i = 0; i < 4; i++) {
        qu.push(make_tuple(hx + vx[i], hy + vy[i], z[hx][hy] ? c + 1 : c));
      }
    }
  }
}

int main(void) {
  lld n;
  cin >> n;
  b.resize(n + 2);
  z.resize(n + 2);
  for (lld i = 0; i < n + 2; i++) {
    b[i].resize(n + 2);
    z[i].resize(n + 2);
    for (lld j = 0; j < n + 2; j++) {
      b[i][j] = min({i - 1, j - 1, n - i, n - j});
      z[i][j] = i != 0 && i != n + 1 && j != 0 && j != n + 1;
    }
  }
  lld q = n * n, p, s = 0;
  for (lld i = 0; i < q; i++) {
    cin >> p;
    lld hx = (p - 1) / n + 1, hy = (p - 1) % n + 1;
    s += b[hx][hy];
    // cout << hx << "," << hy << b[hx][hy] << "\n";
    b[hx][hy] = min({b[hx][hy - 1], b[hx][hy + 1], b[hx - 1][hy], b[hx + 1][hy]});
    z[hx][hy] = false;
    sub(hx, hy);
    /* for (lld i = 0; i < n + 2; i++) {
      for (lld j = 0; j < n + 2; j++) {
        cout << (b[i][j] < 0 ? "" : " ") << b[i][j] << (z[i][j] ? "*" : " ") << " ";
      }
      cout << "\n";
    } */
  }
  cout << s << "\n";
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class C4Adjacent {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;
        in>>n;
        ll cnt=0;
        ll evn=0;
        rep(i,n){
            ll tmp;
            in>>tmp;
            if(tmp>=4 && tmp%4==0) ++cnt;
            else if(tmp>=2 && tmp%2==0) ++evn;
        }
        if(evn>1) {
            n-=evn;
            ++n;
        }
        if(n/2<=cnt) out<<"Yes"<<endl;
        else out<<"No"<<endl;
	}
};


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int dp[4000][4000];
P pre[4000][4000];

void update(int a,int b,int c,int d,int e){
	if(dp[a][b]<dp[c][d]+e){
		dp[a][b]=dp[c][d]+e;
		pre[a][b]=P(c,d);
	}
}
int main(){
	string s,t;cin>>s>>t;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	rep(i,s.size()+1)rep(j,t.size()+1){
		if(i<s.size())update(i+1,j,i,j,0);
		if(j<t.size())update(i,j+1,i,j,0);
		if(i<s.size()&&j<t.size()&&s[i]==t[j]){
			update(i+1,j+1,i,j,1);
		}
	}
	string ans;
	P p(s.size(),t.size());
	while(p.first||p.second){
		P x=pre[p.first][p.second];
		if(x.first!=p.first&&x.second!=p.second){
			ans+=s[x.first];
		}
		p=x;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

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

int main() {
    int X, Y;
    cin >> X >> Y;

    int ans = 0;

    if (X == 1) ans += 300000;
    if (X == 2) ans += 200000;
    if (X == 3) ans += 100000;
    if (Y == 1) ans += 300000;
    if (Y == 2) ans += 200000;
    if (Y == 3) ans += 100000;
    if (X == 1 && Y == 1) ans += 400000;

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

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

using namespace std;
const int B = 18;
const int N = 1 << B;

int parity(int x)
{
    int cnt = 0;
    while (x)
        x -= (x & -x), cnt++;
    return cnt & 1;
}
int isBitOn(int x, int k)
{
    return (x & (1 << k)) > 0;
}
int remBit(int x, int k)
{
    if (k == 0)
        return x >> 1;
    int kones = (1 << k) - 1;
    int kzeros = ~kones;
    int rem = x & kones;
    x >>= 1;
    x &= kzeros;
    x |= rem;
    return x;
}
int insertBit(int x, int k, int bit)
{
    if (k == 0)
    {
        x <<= 1;
        x |= bit;
        return x;
    }

    int kones = (1 << k) - 1;
    int kzeros = ~kones;
    int rem = x & kones;
    x &= kzeros;
    x <<= 1;
    x |= rem;
    if (bit)
        x |= (1 << k);
    return x;
}
vector<int> hamiltonian(int n, int a, int b)
{
    if (n == 1)
        return {a, b};

    int k = 0;
    while (isBitOn(a, k) == isBitOn(b, k))
        k++;
    int na = remBit(a, k), nb = remBit(b, k);
    int c = na ^ 1;
    vector<int> lpath = hamiltonian(n - 1, na, c);

    vector<int> rpath = hamiltonian(n - 1, c, nb);
    for (int &x : lpath)
        x = insertBit(x, k, isBitOn(a, k));
    for (int x : rpath)
        x = insertBit(x, k, isBitOn(b, k)), lpath.push_back(x);
    return lpath;
}

int main()
{
    int i, n, a, b;
    cin >> n >> a >> b;

    if (parity(a) == parity(b))
        cout << "NO\n";
    else
    {
        cout << "YES\n";

        for (int x : hamiltonian(n, a, b))
            cout << x << " ";
    }

    return 0;
}

Measured memory_bytes: 1648
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
int main() {
    string s,t;
    int mn=INT_MAX,cnt;
    cin>>s;
    cin>>t;
    int l1=s.size(),l2=t.size();
    for(int i=0;i<=l1-l2;i++)
    {
        cnt=0;
        for(int j=0;j<l2;j++) if(s[i+j]!=t[j]) cnt++;
        mn=min(mn,cnt);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  ll p[m],y[m];
  vector<int>g[n+1];
  rep(i,m){
    cin>>p[i]>>y[i];
    g[p[i]].push_back(y[i]);
  }
  
  rep(i,n){
    sort(been(g[i+1]));
  }
  rep(i,m){
    int p_ans = p[i];
    int y_ans = lower_bound(been(g[p[i]]),y[i])-g[p[i]].begin();
    cout<<setfill('0')<<setw(6)<<p_ans<<setfill('0')<<setw(6)<<y_ans+1<<endl;
  }

}

Measured memory_bytes: 8576
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c, x = sc.nextInt

    println(
      (for (i <- 0 to a; j <- 0 to b; k <- 0 to c; if 500*i + 100*j + 50*k == x) yield ())
      .length
    )
  }
}


Measured memory_bytes: 27724
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 3 "/workspaces/compro/lib/union_find.hpp"
#ifndef UNION_FIND
#define UNION_FIND
class UnionFind {
private:
  std::vector<int> parent;
  std::vector<int> _size;

public:
  UnionFind(const int s) {
    parent = std::vector<int>(s, -1);
    _size = std::vector<int>(s, 1);
  }

  void merge(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry)
      return;
    if (_size[rx] < _size[ry])
      std::swap(rx, ry);
    parent[ry] = rx;
    _size[rx] += _size[ry];
    _size[ry] = _size[rx];
  }

  int size(int x) { return _size[x]; }

  int root(int x) {
    if (parent[x] == -1)
      return x;
    return parent[x] = root(parent[x]);
  }

  bool isSame(int x, int y) { return root(x) == root(y); }
};
#endif
#line 3 "main.cpp"

long long solve(long long N, int M, const std::vector<long long> &A, const std::vector<long long> &B) {
  UnionFind uf(N);
  REP(i, M) { uf.merge(A[i], B[i]); }

  int ans = 0;
  REP(i, N) { chmax(ans, uf.size(i)); }
  return ans;
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  int N;
  int M;
  std::cin >> N >> M;
  std::vector<long long> A(M), B(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  auto ans = solve(N, M, A, B);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 7924
#include <iostream>


int main() {
    std::string s;
    std::cin >> s;
    int n = s.size();
    int ans = (n + 1) / 2;
    int l, r;
    int v = s[ans - 1];
    if (n % 2 == 0) {
        l = ans - 1;
        r = ans;
    } else {
        l = ans - 2;
        r = ans;
    }
    while (l >= 0) {
        if (s[l] == v && s[r] == v) {
            ans += 1;
            --l;
            ++r;
        } else {
            break;
        }
    }
    std::cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
/*	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);*/
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
	}
	int count=0;
	sort(arr.begin(),arr.end());
	for(int i=0; i<n; i++)
	{
		if(i<n-1)
		{
			if(arr[i]==arr[i+1]){
			 count++;
		//	 cout<<arr[i]<<" ";
			 continue;
		    }
		}
		if(i>0)
		{
			for(int x=1; x*x<=arr[i]; x++){
				if(arr[i]%x==0)
				{
					if(binary_search(arr.begin(),arr.begin()+i,x) || binary_search(arr.begin(),arr.begin()+i,arr[i]/x)){
						count++;
					//	cout<<arr[i]<<" ";
						break;
					}
				}
			}
		}
	}
//	cout<<"\n";
	cout<<n-count;
	return 0;
}

Measured memory_bytes: 4032
n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
def comb(n, r, mod):
    k = min(n - r, r)
    res = 1
    for i in range(k):
        res = (res * (n - i) * pow(i + 1, mod - 2, mod)) % mod
    return res

print((pow(2, n, MOD) - 1- comb(n, a, MOD) - comb(n, b, MOD))%MOD)

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

int main() {
    int N, x[102];
    scanf("%d", &N);
    int MAX = -1;
    for (int i = 0; i < N; i++) {
        scanf("%d", &x[i]);
        MAX = max(MAX, x[i]);
    }
    long long ans = 0x3f3f3f;
    for (int i = 1; i <= MAX; i++) {
        long long sum = 0;
            for (int j = 0; j < N; j++) {
            sum += pow(x[j] - i, 2);
        }
        ans = min (ans, sum);
    }
    printf("%lld\n", ans);
}




Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();

		String ans = "No";
		for(int i = 1 ; i <= 9 ; i++) {
			for(int j = 1 ; j <= 9 ; j++) {
				if(n == i * j) {
					ans = "Yes";
				}
			}
		}

		System.out.println(ans);

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

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

}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  ll N;
  cin >> N;
  vector<int> A(N + 1);
  for (int i = 1; i <= N / i; i++) {
    for (int j = i; j <= N / i; j++) {
      A[i * j] += 2;
      if (i == j) A[i * j]--;
    }
  }
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    ans += i * A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 42260
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

n=int(input())
xs=[]
ys=[]
for _ in range(n):
    x,y=map(int,input().split())
    tx,ty=x+y,x-y
    xs.append(tx)
    ys.append(ty)
xs=sorted(xs)
ys=sorted(ys)
ans=max(abs(xs[-1]-xs[0]),abs(ys[-1]-ys[0]))
print(ans)

Measured memory_bytes: 95600
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vector< ll >A(n+1),B(n);
	for(ll i=0;i<(n+1);i++ )
		cin>>A[i];
	for(ll j=0;j<n;j++)
		cin>>B[j];
	ll ans=0;
	for(ll j=0;j<n;j++)
	{
		ll val=min(B[j],A[j]);
		ans+=val;
		A[j]-=val;
		B[j]-=val;
		val=min(B[j],A[j+1]);
		ans+=val;
		A[j+1]-=val;
		B[j]-=val;
	}
	cout<<ans;
    return 0;
}


//252908XL

Measured memory_bytes: 1792
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 100;
const ll MAX_W = 1E+05;

int N;
ll W;
ll dp[MAX_N][MAX_W + 1];

ll w[MAX_N], v[MAX_N];

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

    cin >> N >> W;

    ll vsum = 0;
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
        vsum += v[i];
    }

    fill(dp[0], dp[N], INF);

    dp[0][v[0]] = w[0];
    dp[0][0] = 0;

    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= vsum; j++) {
            if (j >= v[i]) {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }

    ll ans = 0;
    for (int j = vsum; j >= 0; j--) {
        if (dp[N - 1][j] <= W) {
            ans = j;
            break;
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 81680
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    D = set(LSS())

    for i in range(N, N * 10 + 1):
        if [(j in D) for j in str(i)].count(True) == 0:
            print(i)
            break

if __name__ == '__main__':
    resolve()


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

int main(){
    int n;
    string s;
    cin>>n>> s;
    if(n%2){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n/2+i]||n%2){
            cout<<"No";
            return 0;
        }
    }

    cout<<"Yes";
}


Measured memory_bytes: 256
import sys
INF=float('inf')
def Bellmanford(n,edges,r):
  d=[INF]*n
  d[r]=0
  for i in range(n):
    for u,v,c in edges:
      if d[u]!=INF and d[v]>d[u]+c:
        d[v]=d[u]+c
        if i==n-1 and v==n-1:
          return 'inf'
  return (-1)*d[n-1]
n,m=map(int,input().split())
edges=[0]*m
for i in range(m):
  a,b,c=map(int,input().split())
  edges[i]=(a-1,b-1,-c)
ans=Bellmanford(n,edges,0)
print(ans)

Measured memory_bytes: 3368
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int t = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        while (t-- > 0) {
            double x = Double.valueOf(sc.nextInt());
            double y = Double.valueOf(sc.nextInt());
            double res = Math.sqrt(x * x + y * y);
            if (res <= d) ans++;
        }
        System.out.println(ans);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        
        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine()  {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }

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

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

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

    }
}

Measured memory_bytes: 56736
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;
 	
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	string a;
	cin>>a;

	deque<int>q;

	for(auto c : a)q.pb(c);
	int qq;
	cin>>qq; 	
	bool rev = false;
	while(qq--){
		int t;
		cin>>t;
		if(t==1){
			rev^=1;
		}
		else{	
			int f;
			char c;
			cin>>f>>c;
			if(rev){
				if(f==1)f=2;
				else	f=1;
			}
			if(f==1){
				q.push_front(c);
			}
			else{
				q.push_back(c);
			}
		}
	}

	string ans;

	while(sz(q))ans.pb(q.front()),q.pop_front();

	if(rev)reverse(all(ans));

	cout<<ans<<endl;
}		


Measured memory_bytes: 2264
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iostream>
#include <vector>

int main(int argc, char* argv[]) {
  int64_t N;
  std::cin >> N;
  std::vector<int> a(N + 1);
  std::vector<int> b(N + 1);
  std::vector<int> c(N + 1);
  for (int64_t i = 1; i <= N; ++i) {
    std::cin >> a[i] >> b[i] >> c[i];
  }

  std::vector<int64_t> dp_a(N + 1);
  std::vector<int64_t> dp_b(N + 1);
  std::vector<int64_t> dp_c(N + 1);
  dp_a[0] = dp_b[0] = dp_c[0] = 0;
  for (size_t i = 1; i <= N; ++i) {
    const auto j{i - 1};
    dp_a[i] = std::max({dp_b[j], dp_c[j]}) + a[i];
    dp_b[i] = std::max({dp_c[j], dp_a[j]}) + b[i];
    dp_c[i] = std::max({dp_a[j], dp_b[j]}) + c[i];
  }
  std::cout << std::max({dp_a[N], dp_b[N], dp_c[N]}) << std::endl;
  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long n;
	cin >> n;
	string arr="";
	while(n>0){
		n--;
		arr += (char)(97+n%26);
		n/=26; 
	}
	reverse(arr.begin(),arr.end());
	cout<<arr;
}

Measured memory_bytes: 3124
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
int main(){
	int N,M,K;
	//stack<int> s;   
    queue<int> que;
    std::cin >> N;
    //std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    string s;
    cin>>s;
 	int cnt;
 	int cnt1;
 	cnt=0;
 	cnt1=0;
 	for(int i=0;i<(int)N;i++){
   	 if(s[i]=='R'){
		cnt++;
   	
   	
  	}
  	else{
		cnt1++;
	}
	}
	if(cnt>cnt1){
    printf("Yes");
    }
    else{
		printf("No");
	}
    //printf("%d",N*M);
	return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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



class DWaterBottle {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};

	void solve(std::istream& in, std::ostream& out) {
        double a, b, x;
        in >> a >> b >> x;
        double size = a*a*b;
        if (x <= size / 2) {
            double c = 2 * x / (a*b);
            double d = sqrt(b*b + c*c);
            double sinTheta = c / d;
            out << fixed << setprecision(10) << 90 - asin(sinTheta) * 180 / M_PI << endl;
        } else {
            double c = (2*x - a*a*b) / (a*a);
            double d = b - c;
            double e = sqrt(d*d + a*a);
            double sinTheta = a / e;
            out << fixed << setprecision(10) << 90 - asin(sinTheta) * 180 / M_PI << endl;
        }
	}
};


int main() {
    ios::sync_with_stdio(false);
	DWaterBottle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull N;
	cin >> N;
	
	ull ans = N - 1;
	for (ull i=2; i<=sqrt(N); i++) {
		if (N % i == 0) {
			ans = min(ans, i + N / i - 2);
		}
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
K,A,B = [int(i) for i in input().split()]
if A >= B - 1:
    print(K+1)
else:
    ans = 0
    count = (K+1-A)//2
    amari = (K+1-A)%2
    ans += count*(B-A)
    ans += amari
    ans += A
    print(ans)

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

int main() {
  string S;
  cin >> S;
  
  if ( S.at(0) == S.at(1) && S.at(0) == S.at(2) ) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>

using namespace std;

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

	int n;
	cin >> n;
	string str[n];
	unordered_map<string, int> strMap;
	for(int i = 0 ; i < n ; ++i) {
		cin >> str[i];
		sort(str[i].begin(), str[i].end());
		strMap[str[i]]++;
	}

	long long result = 0;

	for(unordered_map<string, int>::iterator it = strMap.begin() ; it != strMap.end() ; it++) {
		if(it->second == 1) {
			continue;
		}
		result += (long long)it->second * (it->second - 1) / 2;
	}

	cout << result << '\n';
	return 0;
}

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

int gcd(int x, int y){
    if(x == 0) return y;
    if(y == 0) return x;

    if(x%y == 0) return y;
    return gcd(y, x%y);
}

int main(){
    int n;
    cin >> n;
    vector<int> v(n), L(n+1), R(n+1);
    for(int i=0; i<n; i++) cin >> v[i];

    for(int i=0; i<n; i++){
        L[i+1] = gcd(L[i], v[i]);
    }

    reverse(v.begin(), v.end());
    for(int i=0; i<n; i++){
        R[i+1] = gcd(R[i], v[i]);
    }
    reverse(R.begin(), R.end());

    int ans = 0;
    for(int i=0; i<n; i++){
        ans = max(ans, gcd(L[i], R[i+1]));
    }

    cout << ans << endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x,y;
	x = a*b;
	y = c*d;
	if(x > y){
		printf("%d",x);
	}
	else{
		printf("%d",y);
	}
}

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

namespace C
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var tn = new int[n];
			var xn = new int[n];
			var yn = new int[n];
			for (var i = 0; i < n; i++)
			{
				var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
				tn[i] = line[0];
				xn[i] = line[1];
				yn[i] = line[2];
			}

			var dtn = new int[n];
			var dxn = new int[n];
			var dyn = new int[n];
			dtn[0] = tn[0];
			dxn[0] = xn[0];
			dyn[0] = yn[0];
			for (var i = 1; i < n; i++)
			{
				dtn[i] = tn[i] - tn[i - 1];
				dxn[i] = Math.Abs(xn[i] - xn[i - 1]);
				dyn[i] = Math.Abs(yn[i] - yn[i - 1]);
			}

			for (var i = 0; i < n; i++)
			{
				var tmp = dtn[i] - dxn[i] - dyn[i];
				if (tmp < 0 || tmp % 2 == 1)
				{
					Console.WriteLine("No");
					return;
				}
			}

			Console.WriteLine("Yes");
		}
	}
}

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

int n,k;
int tot=0;
int pwr=1;
int main(){
	cin >> n >> k;
	while (pwr <= n){
		pwr *= k;
		tot ++;		
	}
	if (tot==0) tot++;
	cout << tot;
	return 0;
}

Measured memory_bytes: 256
max = 0
l = 0
gets.chomp.split("").map do |e|
	if e=="A" || e=="T" || e=="C" || e=="G" then
		l+=1
	else
		if l>max then max = l end
		l = 0
	end
end
if l>max then max = l end

p(max)

Measured memory_bytes: 1788
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  puts(a + b == c || b + c == a || c + a == b ? "Yes" : "No");
  return 0;
}					

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int x,a,b;
  cin >>x >> a >> b;
  cout <<(x-a)%b fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
h, w = map(int, input().split())
S = [list(str(input())) for _ in range(h)]

ans = [[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if S[i][j] == '#':
            ans[i][j] = '#'
        else:
            cnt = 0
            for di, dj in (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1):
                ni, nj = i+di, j+dj
                if 0 <= ni <= h-1 and 0 <= nj <= w-1:
                    if S[ni][nj] == '#':
                        cnt += 1
            ans[i][j] = str(cnt)
for i in range(h):
    print(''.join(ans[i]))


Measured memory_bytes: 39920
#include<iostream>
#include<string>

using namespace std;

int main(void){
	int a,b;
	string str1;
	string str2;
	while(1){
		cin >> str1 >> str2;
		if(str1=="0" && str2=="0")break;
		int h=0,bl=0;
		for(a=0;a<4;a++){
			for(b=0;b<4;b++){
				if(str1[a]==str2[b]){
					if(a==b)h++;
					else bl++;
				}
			}
		}
		cout << h << " " << bl << endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

int main(){
	dhoom;
	int cnt = 0;
	int n , k;
	cin >> n >> k;
	while(n != 0){
		cnt++;
		n /= k;
	}
	cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    ans += max(A, B);
    if (A >= B)
        A--;
    else
        B--;
    ans += max(A, B);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//Osenbei
#include <stdio.h>
#include <string.h>
int A[10001];

int main(){
  int C, R, tmp, mask, ans, a, b, i, j;
  while(1){
    scanf("%d %d", &C, &R);
    if((C | R) == 0){
      break;
    }
    memset(A, 0, sizeof(A));
    for(i = 0; i < C; ++i){
      for(j = 0; j < R; ++j){
        scanf("%d", &tmp);
        A[j] += tmp << i;
      }
    }
    ans = 0;
    for(mask = 0; mask < (1 << C); ++mask){
      //printf("mask = %d \n", mask);
      a = 0;
      for(i = 0; i < R; ++i){
        tmp = A[i] ^ mask;
        //printf("%d", tmp);
        b = 0;
        while(tmp != 0){
          if((tmp & 1) == 1){
            b++;
          }
          tmp = tmp >> 1;
        }
        a += b > C - b ? b : C - b;
      }
      //printf(" a = %d \n", a);
      if(ans < a){
        ans = a;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1056
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

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

void solve()
{
  int a,b;
  cin >> a >> b;
  char ans[100][100];
  memset(ans,0,sizeof(ans));

  for (int i = 0; i < 100; i++)
  {
    for (int j = 0; j < 100; j++)
    {
      if (i<50)
        ans[i][j] = '.';
      else
        ans[i][j] = '#';
    }
  }

  a--;
  b--;
  for (int i = 0; i < 50; i++)
  {
    for (int j = 0; j < 100; j++)
    {
      if (b==0)
        continue;
      bool ok = true;
      for (int k = 0; k < 8; k++)
      {
        int ni = i + dx[k];
        int nj = j + dy[k];

        if (ni < 0 || ni > 99 || nj < 0 || nj > 99)
        {
          continue;
        }

        if (ans[ni][nj]=='#')
          ok = false;
      }
      if (ok)
      {
        ans[i][j] = '#';
        b--;
      }
    }
  }

 for (int i = 50; i < 100; i++)
  {
    for (int j = 0; j < 100; j++)
    {
      if (a==0)
        continue;
      bool ok = true;
      for (int k = 0; k < 8; k++)
      {
        int ni = i + dx[k];
        int nj = j + dy[k];

        if (ni < 0 || ni > 99 || nj < 0 || nj > 99)
        {
          continue;
        }

        if (ans[ni][nj]=='.')
          ok = false;
      }
      if (ok)
      {
        ans[i][j] = '.';
        a--;
      }
    }
  }

cout << 100 << " " << 100 << endl;

 for (int i = 0; i < 100; i++)
 {
   repz(j,100)
     cout << ans[i][j];
   cout << endl;
 }



}

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

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



Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

void solve(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans=0;
  if(a+b>=2*c){
    ll s=min(x,y);
    ans+=s*2*c;
    x-=s;y-=s;
    ll t=x>0?a*x:b*y;
    ans+=min(t,2*c*max(x,y));
  }
  else {
    ll t=min(x,y);
    ans+=a*x+b*y;
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

// vi g[N];
// int a[N];

void solve() {
  int i, j, n, m, c;
  cin >> n >> m >> c;
  int arr[n][m];
  int ans = 0;
  int b[m];
  fo(i,m) cin >> b[i];
  fo(i,n) fo(j,m) cin >> arr[i][j];
  ll sum = 0;
  fo(i,n){
    fo(j,m){
      sum+=(arr[i][j]*b[j]);
    }
    if(sum+c > 0) ans++;
    sum = 0;
  }
  cout << ans;

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(a: int, b: int, c: int):
    ret = sum([a,b,c]) - max([a,b,c])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    solve(a, b, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e19;

//////////////////////////////////////////////////////////////////////
int num = 32;

int main() {
	int n; cin >> n;
	vi a(n); rep(n)cin >> a[i];
	
	for (int i = 0; i < 32; i++) {
		int c1=0, c2=0;
		for (int j = 0; j < n; j++) {
			if (((a[j]>>i)&1) == 0) c1++;
			else c2++;
		}
		if (!(c2 == 0 || c1 * 2 == c2)) { pno; fin; }
	}
	pyes; fin;
}

Measured memory_bytes: 1024
N, *A = map(int, open(0).read().split())
A = [0] + A + [0]
S = 0
for i in range(N+1):
  S += abs(A[i] - A[i+1])
for i in range(1, N+1):
  print(S - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]))

Measured memory_bytes: 13928
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, t, a, mi = 1000000000, ind;
	scanf("%d%d%d", &n, &t, &a);
	t *= 1000;
	a *= 1000;
	for(int i = 0, j; i < n; ++i)
	{
		scanf("%d", &j);
		if(mi > abs(t - j * 6 - a))
		{
			mi = abs(t - j * 6 - a);
			ind = i + 1;
		}
	}
	printf("%d\n", ind);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int p[200010];
int findset(int i){
    return p[i]==i?p[i]:p[i]=findset(p[i]);
}
int unionset(int i,int j){
    if (findset(i) == findset(j)) return 0;
    else{
        p[findset(i)] = findset(j);
        return 1;
    }
}
int main(){
    int n,k;
    cin >> n >> k;
    set<int> s;
    int arr[n];
    for (int i = 0; i < n; i++) {cin >> arr[i];p[i] = i;}
    int longest[n];
    longest[n-1] = 1;
    for (int i = n-2; i >= 0; i--) longest[i] = (arr[i]<arr[i+1])?longest[i+1]+1:1;
    int first = -1;
    int ans = n-k+1;
    for (int i = 0; i < n; i++){
        if (longest[i] >= k){
            first = (first==-1)?i:first;
            ans -= unionset(first,i);
        }
    }
    for (int i = 0; i < n; i++){
        //cout << longest[i] << "\n";
        if (i < k){
            s.insert(arr[i]);
        }
        else{
            s.insert(arr[i]);
            if (*s.begin() == arr[i-k] && *(--s.end()) == arr[i]) ans -= unionset(i-k,i-k+1);
            s.erase(s.find(arr[i-k]));
        }
    }
    cout<< ans;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

ll N, K;

int main(){
	cin >> N >> K;
	ll a = N%K;
	ll ans = min(a,K-a);
	cout << ans << endl;
}

Measured memory_bytes: 256