akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;

map<int, int> factorization(int n) {
    map<int, int> res;
    for(int i = 2; i <= sqrt(n) + 1; i++) {
        if(i > 3) i++;
        while(!(n%i)) res[i]++, n /= i;
    }
    if(n > 1) res[n]++;
    return res;
}

signed main() {
    int n;
    cin>>n;
    map<int, int> m = factorization(n);
    int ans = 0;
    for (auto p: m) {
        int cnt = 1;
        while (p.second >= cnt) {
            p.second -= cnt;
            cnt++;
            ans++;
        }
        cerr<<p.first<<' '<<p.second<<endl;
    }
    cout<<ans<<endl;
}


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

using i64 = int64_t;

int main(){
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for(int i=1;i<=m;++i){
        for(int j=1;j<=d;++j){
            if(j%10 < 2)continue;
            if(j/10 < 2)continue;
            if((j%10)*(j/10) == i)ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int bit_count(int n) {
	n=((n & 0x2AAAAAAA)>>1 )+(n & 0x55555555);
	n=((n & 0x4CCCCCCC)>>2 )+(n & 0x33333333);
	n=((n & 0x70F0F0F0)>>4 )+(n & 0x0F0F0F0F);
	n=((n & 0x7F00FF00)>>8 )+(n & 0x00FF00FF);
	n=((n & 0x7FFF0000)>>16)+(n & 0x0000FFFF);
	return n;
}

int main(void) {
	int input_a;
	int input_b;
	int a[12]={0};
	int b[12]={0};
	int borrow[12]={0};
	int c[12]={0};
	int k;
	int tansaku;
	int out_c;
	int i;
	int max=0;
	scanf("%d%d%d",&input_a,&input_b,&k);
	for(i=0;input_a>0;i++,input_a/=10)a[i]=input_a%10;
	for(i=0;input_b>0;i++,input_b/=10)b[i]=input_b%10;
	for(tansaku=0;tansaku<(1<<10);tansaku++) {
		if(bit_count(tansaku)>k)continue;
		for(i=0;i<11;i++) {
			if(tansaku & (1<<i))borrow[i]=0;
			if(a[i]-borrow[i]>=b[i]) {
				c[i]=a[i]-borrow[i]-b[i];
				borrow[i+1]=0;
			} else {
				c[i]=a[i]-borrow[i]+10-b[i];
				borrow[i+1]=1;
			}
		}
		out_c=0;
		for(i=11;i>=0;i--)out_c=out_c*10+c[i];
		if(out_c>max)max=out_c;
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct data{
  int T, S;
};
vector<data> lis[10000];

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    while(1){
      int n, m, r, q;
      cin >> n >> m; if(!(n | m))break;
      cin >> r;

      rep(i, r){
        int4(TT, NN, MM, SS);
        lis[MM - 1].pb((data){TT - 540, SS});
      }

      cin >> q;
      for(;q--;){
        int3(ts, te, M);
        M--;
        int use[720] = {0};
        rep(i, lis[M].size()){
          if(lis[M][i].S)use[lis[M][i].T]++;
          else use[lis[M][i].T]--;
        }
        rep1(i, 720)use[i] += use[i - 1];
        int res = 0;
        for(i = ts;i < te;++i)if(use[i - 540])++res;
        pri(res);
      }
      rep(i, 10000)lis[i].clear();
    }


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1596
#include<stdio.h>

int main(){
    int H,W,A,B;
    int i,j;

    scanf("%d %d %d %d",&H,&W,&A,&B);
    for( i = 1 ; i <= H ; i++){
        for( j = 1 ; j <= W ; j++){
            if((i <= B) != (j <= A )){
                printf("1");
            }else{
                printf("0");
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>

using namespace std;

#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 ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {};
	Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
	int n;
	bool directed;
	vector<vector<Edge<T>>> edges;
public:

	Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)) {};
	Graph() {};

	void add(int to, T cost) {
		emplace_back(to, cost);
	}

	int size() {
		return n;
	}
};


int main() {


	long long N, K;

	cin >> N >> K;

	N = N % K;

	while (1) {
		if (abs(N - K) < N) {
			N = abs(N - K);
		}
		else {
			break;
		}
	}

	cout << N << endl;

	return 0;
}

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    int num;
    cin >> num;
    v.at(i) = num;
    sum += num;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    if(4*m*v.at(i) >= sum) cnt++;
  }
  if(cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ull;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    ll N;
    cin >> N;
    ll a[N+1];
    REP(i,N+1){
        cin >> a[i];
    }
    ll low[N+1],high[N+1];
    low[N] = a[N];
    high[N] = a[N];
    for(int n=N-1;n>=0;n--){
        low[n] = (low[n+1]+1)/2 + a[n];
        high[n] = high[n+1] + a[n];
    }

    if(low[0]>1 || high[0]<1){
        cout << -1 << endl;
        return 0;
    }

    ll d[N+1];
    d[0] = 1;
    ll sum = 1;
    for(int n=1;n<=N;n++){
        d[n] = min(high[n],(d[n-1]-a[n-1])*2);
        sum += d[n];
    }
    cout << sum << endl;
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

map< long long int,  long long int> prime_factor(long long int n) {
  map< long long int, long long int > ret;
  for(long long int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main() {
    long long int ans = 0;
    int n;
    cin >> n;
    if(n == 1) {
        cout << 1 << '\n';
        return 0;
    }
    map<long long int, long long int> mp;
    for(int i = 1; i <= n; ++i) {
        auto prime_n = prime_factor(i);
        auto begin = prime_n.begin(), end = prime_n.end();
        for(auto iter = begin; iter != end; iter++) {
            mp[iter->first] += iter->second;
        }
    }

    auto begin = mp.begin(), end = mp.end();
    for(auto iter = begin; iter != end; iter++) iter->second++;
    ans = begin->second%MOD;
    begin++;
    for(auto iter = begin; iter != end; iter++) {
        ans *= iter->second%MOD;
        ans %= MOD;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

L = input()
n = len(L)
#0:kaku 1:mikaku
dp = [[0] * (n+1) for _ in range(2)]
dp[1][0] = 1
for i,x in enumerate(L):
    if x == '0':
        dp[0][i+1] = dp[0][i]*3
        dp[1][i+1] = dp[1][i]
    else:
        dp[0][i+1] = dp[0][i]*3 + dp[1][i]
        dp[1][i+1] = dp[1][i]*2
    dp[0][i+1] %= mod
    dp[1][i+1] %= mod
print((dp[0][-1] + dp[1][-1])%mod)


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

int main() {
  int N;
  cin >> N;
  vector<string> A(N);
  map<string, int> B;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (!(B.count(A.at(i)))) {
      B[A.at(i)] = i;
    }
  }
  cout << B.size() << endl;
}
  

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

using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int tc = 1;
    //cin >> tc;
    while(tc--) {
        ll n;
        cin >> n;
        ll res = 0;
        for(ll j = 2; j*j <= n; j++) {
            ll e = 0;
            while(n % j == 0) {
                n /= j;
                e++;
            }
            for(ll k = 1; e >= k; k++) {
                res++;
                e -= k;
            }
        }
        if(n > 1) res++;
        cout << res << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
#define ull unsigned long long  
using namespace std;
const int mod=1e9+7;
const int MAX=1e5+7;
ll a[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	int n,m;
 	cin>>n>>m;
 	ll sum=0;
 	for(int i=0;i<m;i++)
 	{
		 cin>>a[i];
 		sum+=a[i];
 	}
 	n=n-sum;
 	if(n>=0)cout<<n;
 	else cout<<-1;
}

Measured memory_bytes: 3688
import java.util.*;
import java.io.*;
import java.lang.*;

class Main{
	static int [][]dp;
	static int row, col;
	static String []grid;
	static int MOD = (int)1e9 + 7;
	static int back(int x, int y){
		if(x == row - 1 && y == col - 1)return 1;
		if(x >= row || y >= col || grid[x].charAt(y) == '#')return 0;
		if(dp[x][y] != -1)return dp[x][y];
		return dp[x][y] = ((back(x + 1, y) % MOD)  + (back(x, y + 1) % MOD)) % MOD;
	}
	static void add_self(int one, int two){
		one += two;
		if(one >= MOD){
			one -= MOD;
		}
	}
	public static void main(String[] args)throws IOException{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			 row = sc.nextInt();
			 col = sc.nextInt();
			 dp = new int[row + 1][col + 1];
			 grid = new String[row + 1];
			 grid[0] = sc.nextLine();
			 for(int i = 0; i < row; ++i){
			 	for(int j = 0; j < col; ++j){
			 		dp[i][j] = 0;
			 	}
			 }
			for(int i = 0; i < row; ++i){
				grid[i] = sc.nextLine();
			}
			dp[0][0] = 1;
			for(int i = 0; i < row; ++i){
				for(int j = 0; j < col; ++j){
					int r1 = i + 1, c1 = j;
					int r2 = i, c2 = j + 1;
					if(r1 < row && c1 < col && grid[r1].charAt(c1) == '.'){
						dp[r1][c1] += dp[i][j];
						dp[r1][c1] %= MOD;
					}
					if(r2 < row && c2 < col && grid[r2].charAt(c2) == '.'){
						dp[r2][c2] += dp[i][j];
						dp[r2][c2] %= MOD;
					}
				}
			}
			System.out.println(dp[row - 1][col - 1]);
		}		
	}
}


Measured memory_bytes: 37460
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

//rui[i][j]:=(0,0)～(i-1,j-1)の長方形内のロボットの数
short rui[101][101];

//(A-1,C-1)～(B-1,D-1)の長方形内のロボットの数を返す。
int get(int A, int B, int C, int D) {
	return rui[B][D] - rui[A - 1][D] - rui[B][C - 1] + rui[A - 1][C - 1];
}

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

	int H, W;
	cin >> H >> W;
	vector<vector<int>>a(H, vector<int>(W, 0));
	int ex, ey;
	rep(i, H) {
		string S;
		cin >> S;
		rep(j, W)switch (S[j]) {
		case 'o':a[i][j] = 1; break;
		case 'E':ey = i; ex = j; break;
		}
	}

	rep(i, H)rep(j, W) {
		rui[i + 1][j + 1] = rui[i + 1][j] + rui[i][j + 1] - rui[i][j] + a[i][j];
	}

	short dp[102][102][102][102] = { 0 };
	short maxi = 0;
	for (int i = 1; i <= H; i++)for (int j = H; j >= i - 1; j--)
	{
		for (int k = 1; k <= W; k++)for (int l = W; l >= k - 1; l--)
		{
			short t = dp[i][j][k][l];
			maxi = max(maxi, t);
			if (i>j || k>l)continue;
			int si = 1 + ey - (H - j);
			int sj = 1 + ey + (i - 1);
			int sk = 1 + ex - (W - l);
			int sl = 1 + ex + (k - 1);
			dp[i + 1][j][k][l] = max(dp[i + 1][j][k][l], t);
			dp[i][j - 1][k][l] = max(dp[i][j - 1][k][l], t);
			dp[i][j][k + 1][l] = max(dp[i][j][k + 1][l], t);
			dp[i][j][k][l - 1] = max(dp[i][j][k][l - 1], t);
			if (si <= i)dp[i + 1][j][k][l] = max(dp[i + 1][j][k][l], short(t + get(i, i, max(sk, k), min(sl, l))));
			if (sj >= j)dp[i][j - 1][k][l] = max(dp[i][j - 1][k][l], short(t + get(j, j, max(sk, k), min(sl, l))));
			if (sk <= k)dp[i][j][k + 1][l] = max(dp[i][j][k + 1][l], short(t + get(max(si, i), min(sj, j), k, k)));
			if (sl >= l)dp[i][j][k][l - 1] = max(dp[i][j][k][l - 1], short(t + get(max(si, i), min(sj, j), l, l)));
		}
	}
	cout << maxi << endl;
}

Measured memory_bytes: 211840
import java.util.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n==0) return ;
			int total = 0;
			boolean flag = false;
			for(int i=0; i<12; i++){
				int plus = in.nextInt(), minus = in.nextInt();
				total += plus - minus;
				if(total >= n && !flag){
					System.out.println(i+1);
					flag = true;
				}
			}
			if(!flag) System.out.println("NA");
		}
	}
}

Measured memory_bytes: 12000
N = int(input())
H = list(map(int, input().split()))

def f(H):
    if len(H) <= 1:
        return sum(H)
    v = min(H)
    i = H.index(v)
    X = [h - v for h in H]
    return f(X[:i]) + v + f(X[i+1:])

print(f(H))


Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int k = scan.nextInt();
        int a = scan.nextInt();
        int b = scan.nextInt();
        for(int i = a; i <= b; i++){
            if(i % k == 0) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
        scan.close();
    }
}

Measured memory_bytes: 27004
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <unistd.h>


#define ll long long
#define lst(x) x.size()-1
#define ld long double
#define pr pair<ll,ll>
#define loop(i,n) for(int i=0 ; i<n ; ++i)
#define rep(i,x,n) for(int i=x ; i<=n ; ++i)
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using os = tree<T, null_type, less_equal<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

const ll N=2e5+5,M=1e1+5,MOD=1e9+7,OO=1e13;
ll h;
int main(){
    cin.sync_with_stdio(false), cin.tie(0) , cout.tie(0);
#ifndef ONLINE_JUDGE
  //  freopen("in.txt", "rt" , stdin);
    // freopen("in.txt", "wt" , stdout);
#endif // ONLINE_JUDGE
    cin>>h;
    ll cur=1;
    rep(i,1,50){
        cur*=2;
        if(cur>h){
            cout<<cur-1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m, d;
int main(){
    cin>>m>>d;
    int ans = 0;
    for(int mon = 1;mon <= m; mon++){
        for(int i = 2;i <= 9; i++){
            for(int j = 2;j <= 9; j++){
                if(10 * i + j > d)continue;
                if(i * j == mon)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

var (
	a   []int
	ans = 0
)

func nextString() string {
	var s string
	fmt.Scan(&s)
	return s
}

func dfs(left, i, res int) {
	if left == 0 {
		ans += res
		return
	}
	for j := i; j < len(a); j++ {
		dfs(left-1, j+1, res*a[j])
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	dic := map[rune]int{}

	for range make([]struct{}, n) {
		c := nextString()[0]
		switch c {
		case 'M', 'A', 'R', 'C', 'H':
			dic[rune(c)]++
		}
	}

	for _, v := range dic {
		a = append(a, v)
	}

	dfs(3, 0, 1)
	fmt.Println(ans)
}


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

int main(){
  int N,a;
  a = 0;
  cin >> N;
  vector<int> vec(N);
  
  for(int i =0; i < N; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  if(N > 2){
    for(int i = 0; i < vec.size() - 2;i++){
      for(int j = i+1; j < vec.size() - 1;j++){
        for(int k = j+1; k< vec.size();k++){
          if(vec.at(i) + vec.at(j) > vec.at(k)&&vec.at(i)!=vec.at(j)&&vec.at(j)!=vec.at(k)){
          a = a + 1;
          }
        }
      }
    }
  }
  cout << a << endl;
  
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
long long n;
using ll = long long;
#define MAX 1009

ll N,X[MAX],Y[MAX],H[MAX];
vector<tuple<ll,ll,ll>> vec;

int main(){
    cin >> N;
    tuple<ll,ll,ll>G = make_tuple(-1,-1,-1);
    for(int i=1;i<=N;i++){
        cin >> X[i] >> Y[i] >> H[i];
        if(H[i] >= 1){
            G = make_tuple(X[i],Y[i],H[i]);
        }
    }

    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            ll V = get<2>(G)+abs(get<0>(G)-i)+abs(get<1>(G)-j);
            V = max(V,0ll);
            bool flag = true;
            for(int k=1;k<=N;k++){
                ll VV = V-abs(X[k]-i)-abs(Y[k]-j);
                VV = max(VV,0ll);
                if(H[k] != VV){
                    flag = false;
                }
            }
            if(flag == true){
                vec.push_back(make_tuple(i,j,V));
            }
        }
    }
    if(vec.size() == 1){
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
signed main(){
	int a,b;
	cin>>a>>b;
	cout<<max((int)0,a-b*2)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    ll sum = 0, x = 0, ans = INF;
    rep(i, N)
    {
        cin >> a[i];
        sum += a[i];
    }
    rep(i, N)
    {
        x += a[i];
        if (i < N - 1) {
            ans = min(ans, abs(sum - 2 * x));
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (auto& e : a) for (auto& f : e) cin >> f;

    vector<pair<int, int>> from, to;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x + 1 < w; x++) {
            if (a[y][x] % 2) {
                a[y][x]--, a[y][x+1]++;
                from.emplace_back(y+1, x+1);
                to.emplace_back(y+1, x+2);
            }
        }
    }

    for (int y = 0; y + 1 < h; y++) {
        if (a[y][w-1] % 2) {
            a[y][w-1]--;
            a[y+1][w-1]++;
            from.emplace_back(y+1, w);
            to.emplace_back(y+2, w);
        }
    }

    cout << from.size() << endl;
    for (int i = 0; i < from.size(); i++) {
        cout << from[i].first << " " << from[i].second << " " << to[i].first << " " << to[i].second << endl;
    }
}


Measured memory_bytes: 5228
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
l = [int(i) for i in input().split()]

target = 1
block = 0
sum = 0
for i in range(n):
    block += 1
    if l[i] == target:
        sum += block - 1
        block = 0
        target += 1
sum += block
if target == 1:
    print(-1)
else:
    print(sum)

Measured memory_bytes: 26012
h, w=map(int,input().split())
c=[list(map(int,input().split())) for i in range(10)]

def warshall_floyd(c):
    for i in range(10):
        for j in range(10):
            for k in range(10):
                c[j][k]=min(c[j][k], c[j][i]+c[i][k])

    mn_c=[c[s][1] for s in range(10)]
    return mn_c

mn_c=warshall_floyd(c)

sm=0
for i in range(h):
    a=list(map(int,input().split()))
    for k in a:
        if k>=0:
            sm+=mn_c[k]

print(sm)

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b == c || a + c == b || b + c == a) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve() {
  int n, x, t; cin >> n >> x >> t;
  cout << t * ((n + x - 1) / x);
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
    solve();
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
  int num;cin >> num;
  int a = num/100;
  int b = num - num/100*100;
  bool A,B;
  A = 0<a&&a<13;
  B = 0<b&&b<13;
  
  if(A&&B){
    cout << "AMBIGUOUS";
  }else if(A && !B){
    cout << "MMYY";
  }else if(!A && B){
    cout << "YYMM";
  }else{
    cout << "NA";
  }
  return 0;
}


Measured memory_bytes: 256
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		new CGL_3B().doIt();
	}

	class CGL_3B{

		double cross(Point2D p1,Point2D p2){
			return p1.getX()*p2.getY()-p1.getY()*p2.getX();
		}
		int CCW(Point2D a,Point2D b,Point2D target){ //a-bの直線はtargetの右か左か
			Point2D q = new Point2D.Double(b.getX()-a.getX(),b.getY()-a.getY());
			Point2D r = new Point2D.Double(target.getX()-a.getX(),target.getY()-a.getY());
			if(cross(q, r)>0)return -1;//左側
			else if(cross(q,r)<0)return 1;//右側
			else return 0;//重なっている
		}
		
		void doIt(){
			int n = in.nextInt();
			Point2D[] p = new Point2D[n];
			for(int i=0;i<n;i++)p[i] = new Point2D.Double(in.nextDouble(), in.nextDouble());
			boolean sw = true;
			for(int i=0;i<n;i++){
//				System.out.println(CCW(p[i%n],p[(i+1)%n],p[(i+2)%n]));
				if(CCW(p[i%n],p[(i+1)%n],p[(i+2)%n])!=CCW(p[(i+1)%n],p[(i+2)%n],p[(i+3)%n])
						&&CCW(p[i%n],p[(i+1)%n],p[(i+2)%n])!=0&&CCW(p[(i+1)%n],p[(i+2)%n],p[(i+3)%n])!=0){
					sw=false;
					break;
				}
			}
			if(sw)System.out.println("1");
			else System.out.println("0");
		}
		
	}


}

Measured memory_bytes: 20880
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

vector<int> min_factor, prime;

void sieve(int n){
    min_factor.resize(n+1, 0);
    For(i, 2, n+1){
        if(min_factor[i] == 0){
            min_factor[i] = i;
            prime.push_back(i);
        }
        for(int x: prime){
            if(x*i > n || x > i) break;
            min_factor[x*i] = x;
        }
    }
}

bool is_prime(int x){
    return x > 1 && min_factor[x] == x;
}

vector<pii> prime_f(int n){
    vector<pii> ret;
    while(n > 1){
        if(ret.empty() || ret.rbegin()->fi != min_factor[n]){
            ret.emplace_back(min_factor[n], 1);
        }
        else ++ret.rbegin()->se;
        n /= min_factor[n];
    }
    return ret;
}

int main(){
    lint L, R;
    scanf("%lld%lld", &L, &R);

    sieve(35000);
    int cnt[R-L+1], v[R-L+1];
    For(i, L, R+1){
        cnt[i-L] = 0;
        v[i-L] = i;
    }
    for(lint x: prime){
        for(lint j=div_ceil(L, x); j*x<=R; ++j){
            while(v[j*x-L] % x == 0){
                ++cnt[j*x-L];
                v[j*x-L] /= x;
            }
        }
    }

    int ans = 0;
    For(i, L, R+1){
        if(v[i-L] > 1) ans += is_prime(cnt[i-L] + 1);
        else ans += is_prime(cnt[i-L]);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 11092
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
s = input()
t = input()

if n>=len(s)+len(t):
  print(n)
  exit()

de = 0
for i in range(min(len(s),len(t))):
  if s[i*-1-1:]==t[:i+1]:
    de = i+1

print(len(s)+len(t)-de)

Measured memory_bytes: 9368
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

ll mod = 1000000007;

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

ll comb(ll n, ll k) {
    ll x = 1;
    for (ll i = n - k + 1; i <= n; i++) {
        x = (x * i) % mod; 
    }
    ll y = 1;
    for (ll i = 1; i <= k; i++) {
        y = (y * i) % mod;
    }
    y = modpow(y, mod - 2);
    return (x * y) % mod;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans= modpow(2, n) - 1;
    ans -= comb(n, a) + comb(n, b);
    while(ans < 0) {
        ans += mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void _yn(bool p) {
	p ? _y() : _n();
}

void _YN(bool p) {
	p ? _Y() : _N();
}


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vi a(x), b(y), c(z);
	f_vI(a, x); f_vI(b, y); f_vI(c, z);
	sort(all(a), greater<int>()); sort(all(b), greater<int>()); sort(all(c), greater<int>());
	vi ans;
	f(i, 0, x) {
		f(j, 0, y) {
			f(o, 0, z) {
				if ((i + 1)*(j + 1)*(o + 1) <= k) {
					ans.push_back(a[i] + b[j] + c[o]);
				}
			}
		}
	}
	sort(all(ans), greater<int>());
	f(i, 0, k) {
		cout << ans[i] << endl;
	}
	return 0;
}

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

double dp[105][101];
bool lose[101], back[101];
int main() {
	int n, t, l, b;
	while (scanf("%d%d%d%d", &n, &t, &l, &b), n) {
		memset(lose, 0, sizeof(lose));
		memset(back, 0, sizeof(back));
		memset(dp, 0, sizeof(dp));
		rep(i, l) {
			int a; scanf("%d", &a);
			lose[a] = true;
		}
		rep(i, b) {
			int a; scanf("%d", &a);
			back[a] = true;
		}
		dp[0][0] = 1;
		rep(i, t)rep(j, n)for (int k = 1; k <= 6; k++) {
			int nx;
			if (j + k > n)nx = n - (k - (n - j));
			else nx = j + k;
			if (lose[nx])dp[i + 2][nx] += dp[i][j] / 6;
			else if (back[nx])dp[i + 1][0] += dp[i][j] / 6;
			else dp[i + 1][nx] += dp[i][j] / 6;
		}
		double sum = 0;
		rep(i, t + 1)sum += dp[i][n];
		printf("%.12lf\n", sum);
	}
}

Measured memory_bytes: 3296
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int
main()
{
    int k;
    int n;
    vector<int> a;
    cin >> k;
    cin >> n;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        a.push_back(x);
    }

    vector<int> d(n);
    int y = 0;
    for(int i=0;i<n;i++){
        d[i] = a[i] - y;
        y =  a[i];
    }
    d[0] += k - a[n-1];

    int ans = 0;
    for(auto i : d){
        ans += i;
    }
    ans -= *max_element(d.begin(), d.end());
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1908
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

unordered_map<long long, int> A;
unordered_map<long long, int> B;

int main(int argc, char* argv[]){
	int N;

	cin >> N;
	for(long long i=1; i<=N; i++){
		long long a, b, c;
		cin >> c;
		a = i + c;
		b = i - c;
		if(A.count(a)==0){
			A[a] = 1;
		}
		else{
			int v = A[a];
			A[a] = v+1;
		}
		if(B.count(b)==0){
			B[b] = 1;
		}
		else{
			int v = B[b];
			B[b] = v+1;
		}
	}

	long long ans = 0;
	for(auto itr = A.begin(); itr != A.end(); ++itr){
		long long k = itr->first;
		long long v1 = (long long)itr->second;
		long long v2 = (long long)B[k];
		if(v2==0) continue;
		ans += v1*v2;
	}
	cout << ans << endl ;
	return 0;
}

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

const int MOD = 1e9 + 7;
const int SIZE = 1e5;
vector<long long> fac, finv, inv;

void init_nCk() {
    fac.resize(SIZE + 5);
    finv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long binom(int n, int k){
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int N, K;

    init_nCk();

    cin >> N >> K;

    vector<int> A(N);

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

    sort(A.begin(), A.end());

    long long s_max = 0;
    long long s_min = 0;
    long long r;
    for (int i = K - 1; i < N; i++){
        r = binom(i, K - 1);
        s_max += r * A[i];
        s_max %= MOD;
        s_min += r * A[N - i - 1];
        s_min %= MOD;
    }

    cout << (s_max - s_min) % MOD << endl;

    return 0;
}

Measured memory_bytes: 5900
#include <stdio.h>

int a[505][505];
long long qs[505][505];

int main(){
    int H, W, h, w;
    scanf("%d%d%d%d", &H, &W, &h, &w);
    if(h*w == 1){ printf("No"); return 0; }
    int k = ((1e9)-1)/(h*w-1);
    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++){
        if(i%h == 0 && j%w == 0) a[i][j] = -k*(h*w-1)-1;
        else a[i][j] = k;
        qs[i][j] = a[i][j]+qs[i-1][j]+qs[i][j-1]-qs[i-1][j-1];
    }
    for(int i=h; i<=H; i++) for(int j=w; j<=W; j++){
        if(qs[i][j]-qs[i-h][j]-qs[i][j-w]+qs[i-h][j-w] >= 0){ printf("No"); return 0; }
    }
    if(qs[H][W] <= 0){ printf("No"); return 0; }
    printf("Yes\n");
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++) printf("%d ", a[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans = max(ans, abs(A[i]-A[j]));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CS.Solve
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            List<int[]> x = new List<int[]>();
            foreach (var i in Enumerable.Range(0, NM[1]))
            {
                var tmp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                x.Add(new int[] { tmp[0], tmp[1], i, 0 });
            }
            var y = x.OrderBy(p => p[0]).ThenBy(p => p[1]).ToList();

            y[0][3] = 0;
            var pi = y[0][0];
            var junban = 0;

            foreach (var tmp in y.Skip(1))
            {
                if(tmp[0] == pi)
                {
                    junban++;
                    tmp[3] = junban;
                }
                else
                {
                    junban = 0;
                    tmp[3] = 0;
                    pi = tmp[0];
                }
            }
            foreach(var tmp in y.OrderBy(p => p[2]))
            {
                Console.WriteLine("{0:000000}{1:000000}", tmp[0], tmp[3]+1);
            }

        }
    }
}


Measured memory_bytes: 32928
n=int(input())
S=str(input())
s=list(S)
i=1
while True:
    if n ==1 or n==0:
        break
    if s[i-1]==s[i]:
        s.pop(i)
        n -= 1
    else:
        i +=1
    if i >= n:
        break
print(len(s))


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll A,B;
    string S;
    cin >> A >> B;
    cout << A*B << endl;
}


Measured memory_bytes: 3628
import math

N, M = map(int, input().split())

if abs(N- M) > 1:
    print(0)
    exit()

if N == M:
    p1 = math.factorial(N)
    p2 = math.factorial(M)
    print((p1 * p2 * 2) % (10 ** 9 + 7))
    exit()
else:
    p1 = math.factorial(N)
    p2 = math.factorial(M)
    print((p1 * p2) % (10 ** 9 + 7))
    exit()


Measured memory_bytes: 5176
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
  int n;cin>>n;
  string a, b, c;cin>>a>>b>>c;
  int ans=0;
  for(int i=0;i<n;i++){
    int num=0;
  	if(a[i]==b[i])num++;
    if(a[i]==c[i])num++;
    if(b[i]==c[i])num++;
    if(num==3)ans+=0;
    else if(num==1)ans+=1;
    else ans+=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
r=[False]*n
l=[1]*n
r[0]=True
for i in range(m):
  x,y=map(int,input().split())
  x-=1;y-=1
  if r[x]:
    r[y]=True
  l[x]-=1
  l[y]+=1
  if l[x]==0:
    r[x]=False
s=0
for i in range(n):
  if r[i]:
    if l[i]:
      s+=1
print(s)

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

float tem(int T0,int X0){

  return T0-X0*0.006;
}

float myabs(float a){
if(a<=0) return -a;
else return a;
  
}


int main(){
int mark=1;
int N;
float T;
float A;
cin>>N;
cin>>T>>A;
vector <float> H(N+1,0);
for (int input=1;input<=N;input++)
      {
        cin>>H[input];
      }

float gosamin=myabs(tem(T,H.at(1))-A);
for(int each=1;each<=N;each++){
      gosamin=min(gosamin,myabs(tem(T,H.at(each))-A));
      if(gosamin==myabs(tem(T,H.at(each))-A)) mark=each;
      
    }
    cout<<mark;
return 0;
}

Measured memory_bytes: 256
def main():
    H,N = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N)]
    maxA = max(A for A,B in AB)
    dp = [0]*(H+maxA)
    dp[0] = 0
    for i in range(1,H+maxA):
        dp[i] = min(dp[i-A]+B for A,B in AB)
    print(min(dp[H:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3668
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        int count = 0;
        
    	for(char c: str.toCharArray()){
	    	if(c == '1'){
		    	count++;
		    }
	    }
        
        System.out.println(count);
        scan.close();
    }
}


Measured memory_bytes: 21844
s = gets.chomp
K = gets.to_i
N = s.size

found = Hash.new(0)
('a' .. 'z').each do |c|
  N.times do |offset|
    if s[offset] == c
      (1 .. K).each do |k|
        if offset + k <= N
          w = s[offset,k]
          found[w] += 1
        end
      end
    end
  end
  break if found.size >= K
end
puts found.keys.sort[K-1]

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(ll i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 300030;
const ll MOD = 998244353LL;

ll N, A, B, K;

//階乗とその逆元
ll fac[MAX+1],facInv[MAX+1];

ll power(ll e, ll x){ //e^x % MOD
	if (x == 0) return 1LL;
	if (x % 2 != 0) return ((power(e, x-1) * e) % MOD);
	ll temp = power(e, x / 2);
	return (temp * temp) % MOD;
}

ll nck(ll n, ll k){
	if (!(n >= k && k >= 0)) return 0;
	ll temp = (fac[n] * facInv[n-k]) % MOD;
	return ((temp * facInv[k]) % MOD);
}

void fact(void){
	//階乗とその逆元
	fac[0] = facInv[0] = 1; //0! = 1
	//(x!)^(-1) ≡ (x!)^(p-2) (mod p)
	Rep(1, MAX, i) fac[i] = (fac[i-1] * i) % MOD;
	facInv[MAX] = power(fac[MAX], MOD-2);
	Rep(1, MAX-1, i) facInv[MAX-i] = (facInv[MAX-i+1] * (MAX-i+1)) % MOD;
}

void solve(void){

	cin >> N >> A >> B >> K;
	if (K == 0) {
		cout << 1 << endl;
		return;
	}
	fact();
	ll ans = 0;
	rep(N+1, n) {
		if ((K - (A * n)) % B) continue;
		ll m = (K - (A * n)) / B;
		if (0 > m || m > N) continue;
		ans += nck(N, n) * nck(N, m) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
using namespace std;
int main (void) {
    int A;
    int B;
    int C;
    int D;

    cin >> A >> B >> C >> D;

    if (B <= C || D <= A) cout << 0 << endl;
    else cout << min(B, D) - max(A, C) << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  
  for (int i=0; i<n; i++) {
    int l, r;
    cin >> l >> r;
    ans += r-l+1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3612
def General_Binary_Search(L,R,cond,Mode=True,Integer=True,ep=1/(1<<20)):
    """一般的な二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
    Mode:True->広義単調増加,False->広義単調減少
    Integer:解を整数に制限するか?
    ep:Integer=Falseのとき,解の許容する誤差
    """

    if Integer:
        R+=1
        while R-L>1:
            C=L+(R-L)//2
            if cond(C)^Mode:
                L=C
            else:
                R=C
        if Mode:
            return R
        else:
            return L
    else:
        C=(R-L)/2
        while (R-C)>ep:
            if cond(C)^(not Mode):
                L=C
            else:
                R=C
            C=L+(R-L)/2
        return C
#======================================
N,K=map(int,input().split())
A=list(map(int,input().split()))

def f(x):
    r=0
    for a in A:
        r+=(a+x-1)//x
    return r-N<=K

print(General_Binary_Search(0,max(A),f,Mode=True))

Measured memory_bytes: 104264
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,a,b; cin>>n>>a>>b;
	if (n*a<b) cout<<(n*a);
	else cout<<b;
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();
    
    int a, b; cin >> a >> b;
    eFOR(i, 1, 1000000) {
        if (int(i * 0.08) == a && int(i * 0.10) == b) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << "-1\n";
}

Measured memory_bytes: 256