akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

const int MAX_N = 100;
const int INFINITY = 2000 + 1;

enum
{
  WHITE,
  GRAY,
  BLACK
};

int color[MAX_N];
int M[MAX_N][MAX_N];
int d[MAX_N];
int p[MAX_N];
int n;

void prim()
{
  for (int i = 0; i < n; ++i)
  {
    color[i] = WHITE;
    d[i] = INFINITY;
    p[i] = -1;
  }

  d[0] = 0;

  while (true)
  {
    int mincost = INFINITY;
    int u = -1;

    for (int i = 0; i < n; ++i)
    {
      if (color[i] != BLACK && mincost > d[i])
      {
        mincost = d[i];
        u = i;
      }
    }

    if (u == -1)
      break;

    color[u] = BLACK;

    for (int v = 0; v < n; ++v)
    {
      if (color[v] != BLACK && M[u][v] != INFINITY)
      {
        if (d[v] > M[u][v])
        {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
}

int main()
{
  scanf("%d", &n);

  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      int m;
      scanf("%d", &m);
      M[i][j] = (m == -1) ? INFINITY : m;
    }
  }

  prim();

  int count = 0;
  for (int i = 0; i < n; ++i)
  {
    if (p[i] != -1)
      count += M[i][p[i]];
  }

  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2700
import java.util.Scanner;

public class Main
{
	static final Scanner s = new Scanner(System.in);
	static final String line = System.getProperty("line.separator");

	public static void main(String... args)
	{
		while(s.hasNextInt())
		{
			int n = s.nextInt();
			int i = 1;
			while(n != 0)
			{
				if((n & 1) != 0)
				{
					System.out.print(i + (n == 1 ? line : " "));
				}
				i <<= 1;
				n >>= 1;
			}
		}
	}
}

Measured memory_bytes: 17216
(let ((s (read-line))
      (ans1 0)
      (ans2 0))
     (dotimes (i (length s))
       (cond ((and (oddp i) (= (- (char-int (char s i)) 48) 1)) (incf ans1))
             ((and (oddp i) (incf ans2)))
             ((and (evenp i) (= (- (char-int (char s i)) 48) 1)) (incf ans2))
             (t (incf ans1))))
     (princ (min ans1 ans2)))

Measured memory_bytes: 13668
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

int N, K;

#define INF 11451419
#define MAX_V 1010

int cost[MAX_V][MAX_V];
int V;

//int d[MAX_V];
// bool used[MAX_V];
vector<int> dijkstra(int s) {
  //fill(d, d+V, INF);
  //fill(used, used+V, false);
  vector<bool> used(V, false);
  vector<int> d(V, INF);
  d[s] = 0;

  while (true) {
    int v = -1;
    for (int u=0; u<V; u++) {
       if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
    }
    if (v == -1) break;
    used[v] = true;

    for (int u=0; u<V; u++) {
       d[u] = min(d[u], d[v] + cost[v][u]);
    }
  }
  return d;
}

int main() {
  while (true) {
  cin >> N >> K;
  if (N == 0 && K == 0) break;
  V = N;
  rep(u, MAX_V) rep(v, MAX_V) cost[v][u] = INF;
  rep(i, K) {
    int op;
    cin >> op;
    if (op == 0) {
      int a, b;
      cin >> a >> b;
      auto d = dijkstra(a-1);

      int x = d[b-1];
      cout << (x==INF? -1 : x) << "\n";
    }
    else {
      int c, d, e;
      cin >> c >> d >> e;
      cost[c-1][d-1] = min(cost[c-1][d-1], e);
      cost[d-1][c-1] = min(cost[d-1][c-1], e);
    }
  }
  }
  return 0;
}

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

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
  if (!b) {
    x = 1, y = 0;
  } else {
    exgcd(b, a % b, y, x);
    y -= (a / b) * x;
  }
}

int inv(int a, int n) {
  int x, y;
  exgcd(a, n, x, y);
  return (x < 0) ? (x + n) : (x);
}

const int Mod = 1e9 + 7;

template <const int Mod = :: Mod>
class Z {
  public:
    int v;

    Z() : v(0) {	}
    Z(int x) : v(x){	}
    Z(ll x) : v(x % Mod) {	}

    friend Z operator + (const Z& a, const Z& b) {
      int x;
      return Z(((x = a.v + b.v) >= Mod) ? (x - Mod) : (x));
    }
    friend Z operator - (const Z& a, const Z& b) {
      int x;
      return Z(((x = a.v - b.v) < 0) ? (x + Mod) : (x));
    }
    friend Z operator * (const Z& a, const Z& b) {
      return Z(a.v * 1ll * b.v);
    }
    friend Z operator ~(const Z& a) {
      return inv(a.v, Mod);
    }
    friend Z operator - (const Z& a) {
      return Z(0) - a;
    }
    Z& operator += (Z b) {
      return *this = *this + b;
    }
    Z& operator -= (Z b) {
      return *this = *this - b;
    }
    Z& operator *= (Z b) {
      return *this = *this * b;
    }
};

Z<> qpow(Z<> a, int p) {
  Z<> rt = Z<>(1), pa = a;
  for ( ; p; p >>= 1, pa = pa * pa) {
    if (p & 1) {
      rt = rt * pa;
    }
  }
  return rt;
}

typedef Z<> Zi;

const int N = 1e7 + 5, M = 5005;

vector<Zi> fac, _fac;
Zi comb[M][M];

void init_fac(int n) {
  fac.resize(n + 1);
  _fac.resize(n + 1);
  fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i;
  }
  _fac[n] = ~fac[n];
  for (int i = n; i; i--) {
    _fac[i - 1] = _fac[i] * i;
  }
}
void init(int n) {
  comb[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    comb[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
    }
  }
}

int n, m;
Zi f[M][M], g[M][M], t[M];

int main() {
  scanf("%d%d", &n, &m);
  init_fac(n);
  init(m);

  for (int i = 0; i < m; i++) {
    t[i] = fac[n - 1 - i] * _fac[m - 1 - i];
  }
  for (int d = 1; d <= m; d++) {
    g[d][0] = t[m - d + 1];
    if (d == 1) {
      for (int j = 1; d + j <= m; j++) {
        g[d][j] = g[d][j - 1];
      }
    } else {
      for (int j = 1; d + j <= m; j++) {
        g[d][j] = g[d][j - 1] + fac[d + j - 2] * _fac[d - 2] * _fac[j] * t[m - d + 1 - j];
      }
    }
    for (int j = 1; d + j <= m; j++) {
      g[d][j] *= fac[j];
    }
  }
  f[0][0] = 1;
  Zi ans = 0;
  for (int i = 1; i <= m; i++) {
    f[i][0] = f[i - 1][0] * i;
    for (int j = 1; j <= i; j++) {
      f[i][j] = f[i - 1][j] * (i - j) - f[i - 1][j - 1];
    }
    for (int j = 0; j < i; j++) {
      ans += f[i - 1][j] * g[i - j][m - i];
    }
  }
  for (int i = 0; i < m; i++) {
    ans += f[m][i] * t[i];
  }
  printf("%d\n", ans.v);
  return 0;
}


Measured memory_bytes: 374932
#include <iostream>

using namespace std;

int main()
{

    int length;     cin >> length;

    int tot = 0;
    int brick[1000000];   int sen = 1;
    for (int i = 0; i < length; i++){
        cin >> brick[i];
        if (brick[i] != sen){
            tot++;
        }
        else{
            sen++;
        }
    }

    if (sen == 1){tot = -1;}
    cout << tot << endl;

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()


int dp[3003][3003];
int INF = 5000;
int slen;
int tlen;
string s, t;

string ans;

int fun(int a, int b){

    if(a < 0 or b < 0) return 0;
    if(dp[a][b] == -1){
        if(s[a] == t[b]){
            dp[a][b] = fun(a-1, b-1) + 1;
        }
        else dp[a][b] = max(fun(a, b-1), fun(a-1, b));
    }
    return dp[a][b];
}

void fun1(int a, int b){
    // loop(tab) printf("    "); deb2(a, b);
    if(a < 0 or b < 0) return;
    if(s[a] == t[b]) {
        ans += s[a];
        fun1(a-1, b-1);
    }
    else if(fun(a-1, b) > fun(a, b-1)) fun1(a-1, b);
    else fun1(a, b-1);
    
}

int32_t main(){
    
    memset(dp, -1, sizeof(dp));
    cin >> s;
    cin >> t;
    tlen = t.length();
    slen = s.length();
    fun1(slen-1, tlen-1); 
    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}

Measured memory_bytes: 74368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  string s;
  cin >> n >> s;
  ll r = 0;
  rep(i, n) if(s[i] == 'R') r++;
  ll nr = 0;
  rep(i, r) if(s[i] == 'R') nr++;
  ll ans = min(r, r - nr);
  if(r == n) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 3748
n, a, b = [int(number) for number in input().split()]


def sum_of_figure(number):
  n_str = str(number)
  return sum([int(c) for c in n_str])


def in_range(number, minimum, maximum):
  sum_figure = sum_of_figure(number)
  if minimum <= sum_figure and sum_figure <= maximum:
    return True
  else:
    return False

result = 0

for target in range(n + 1):
  if in_range(target, a, b):
    result += target

print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+9;
const long double pi = acos(-1);

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	string s;
	cin >> s;
	map <int, int> m;
	int x = 0, tmp = 1;
	ll ans = 0;
	for(int i=s.size()-1;i>=0;i--){
		x += (s[i]-'0')*tmp;
		x %= 2019;
		tmp = (tmp*10)%2019;
		// cout << x << " ";
		if(x==0) ans++;
		if(m.find(x)!=m.end()) ans += m[x];
		m[x]++;
	}
	cout << ans;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
   
    int n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    vi ans(n);
    rep(i,n){
        ans[a[i]]=i+1;
    }

    rep(i,n)cout << ans[i] << " ";
    
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	int N;
	cin>>N;
	int x=0,ans=0;
	REP(i,N){
		int y;
		cin>>y;
		ans+=y;
		x=max(x,y);
	}
	cout<<ans-x/2<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	private static final int[] D = { 1, 0, -1, 0 };
	
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		for (;;)
		{
			int N = sc.nextInt();
			if (N==0)break;
			
			boolean[][] map = new boolean[21][21];
			for (int i = 0; i < N; i++)
			{
				map[sc.nextInt()][sc.nextInt()] = true;
			}
			
			int M = sc.nextInt(), x = 10, y = 10;
			for (int i = 0; i < M; i++)
			{
				int j = "ESWN".indexOf(sc.next().charAt(0));
				int d = sc.nextInt();
				for (int k = 0; k < d; k++)
				{
					x += D[j];
					y += D[(j+1)%4];
					if (map[x][y])
					{
						N--;
						map[x][y] = false;
					}
				}
			}
			System.out.println(N == 0 ? "Yes" : "No");
		}
	}
}

Measured memory_bytes: 12000
#2d plane 2n points
n=int(input())
cnt=0
red=[]
blue=[]
for _ in range(n):
    x,y=map(int,input().split())
    red.append((x,y))
for _ in range(n):
    x,y=map(int,input().split())
    blue.append((x,y))
red=sorted(red,key=lambda x:x[0])
blue=sorted(blue,key=lambda x:x[0])
blue=blue[::-1]
for i in range(n-1,-1,-1):
    x,y=red[i][0],red[i][1]
    d=[]
    for some in blue:
        X,Y=some[0],some[1]
        if X>x:
            d.append((X,Y))
    if d:
        d=sorted(d,key=lambda x:x[1])
        node=0
        for some in d:
            if some[1]>y:
                node=some
                cnt+=1
                break
        if node!=0:
            blue.remove(node)
print(cnt)

                
            
        
    

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int[] darumas;
	static int[][] memo;
	static int max(int i, int j) {
		if(memo[i][j] == -1) {
			int n = j - i;
			if(n == 1) memo[i][j] = 0;
			else if(n == 2) {
				assert(j-1 == i+1);
				memo[i][j] = (Math.abs(darumas[i]-darumas[i+1]) <= 1) ? 2 : 0;
			}
			else {
				int lmax = 0;
				if(n >= 4) {
					lmax = max(i+1, j-1);
					lmax += (lmax == n-2) ? (Math.abs(darumas[i]-darumas[j-1]) <= 1 ? 2 : 0) : 0;
				}
				for(int k=i+1; k+1<j; k++) {
					int top = max(i, k);
					int bot = max(k, j);
					if(lmax < top+bot) {
						lmax = top + bot;
					}
				}
				memo[i][j] = lmax;
			}
		}
		return memo[i][j];
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(sc.hasNext()) {
				int n = sc.nextInt();
				if(n == 0) break;
				
				darumas = new int[n];
				memo = new int[n][n+1];
				for(int i=0; i<n; i++) {
					darumas[i] = sc.nextInt();
					Arrays.fill(memo[i], -1);
				}
				System.out.println(max(0, n));
			}
		}
	}
}



Measured memory_bytes: 58500
#include<stdio.h>

int n, A[50];

int solve(int i, int m){
  if (m == 0) return 1;
  if (i >= n) return 0;
  int res = solve(i+1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main(){
  int q, M, i;

  scanf("%d", &n);
  for (i=0;i<n;i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for (i=0;i<q;i++){
    scanf("%d",&M);
    if (solve(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
const int maxn = 1000007;
int a[maxn];
int n,m,h;
int main()
{
    cin>>n>>m>>h;
    int sum = 0;
    cin>>sum;
    sum/=50;
    int ans = 0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            for(int k=0;k<=h;k++)
            {
                int now = i*10+j*2+k;
                if(now==sum)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int redCounter = 0;
		int blueCounter = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '0') {
				redCounter++;
			} else {
				blueCounter++;
			}
		}
		System.out.println(Math.min(redCounter, blueCounter)*2);
    }
  
}


Measured memory_bytes: 26000
#include <iostream>
    #include <string>
    using namespace std;
     
    int main() {
    	string s;
    	int ans = 0;
    	cin >> s;
    	if (s[0] == '1') {
    		ans++;
    	}
        if (s[1] == '1') {
    		ans++;
    	}
        if (s[2] == '1') {
    		ans++;
    	}
    	cout << ans <<endl;
    	return 0;
    }    	


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int f = (s[0]-'0')*10 + (s[1]-'0');
    int b = (s[2]-'0')*10 + (s[3]-'0');
    if ((f==0||f>12)&&(b==0||b>12)){
        cout<<"NA\n";
    }else if(f==0||f>12){
        cout<<"YYMM\n";
    }else if(b==0||b>12){
        cout<<"MMYY\n";
    }else{
        cout<<"AMBIGUOUS\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a,b,c,i,j=0;
  scanf("%d",&a);
    scanf("%d",&b);
      scanf("%d",&c);
for(i=a;i<=b;i++)
  {
  if(c%i==0){
    j++;
      }
  }
 printf("%d\n",j);
    return 0;
}

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

int main(){
  int n,tmp,miman =0,ans =0;
  scanf("%d",&n);
  int d[n];
  for(int i=0;i<n;i++) scanf("%d",&d[i]);
  sort(d,d+n);
  int size = sizeof d / sizeof d[0];
  if(n %2 == 0){
    printf("%d",d[(size-1)/2+1]-d[(size-1)/2]);
  }else {
    printf("0");
  }
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    String t = sc.next();
    int count = 0;

    //List<Character> list1 = new ArrayList<>();
    //List<Character> list2 = new ArrayList<>();

    for(int i = 0; i < s.length(); i++){
        if(s.charAt(i)==t.charAt(i)){

        }else{
            count++;
        }
    }

    //System.out.println(list1);
    //System.out.println(list2);


    //for(int i = 0; i < list1.size(); i++){
        //if(list1.get(i).equals(list2.get(i))){
        //}else{
           // count++;
        //}
    //}

    System.out.println(count);

    
    

    


    
    


    


    
    


    
	}
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B>C+D){
    cout<<"Left"<<endl;
  }
  else if (A+B==C+D) {
    cout<<"Balanced"<<endl;
  }
  else {
    cout<<"Right"<<endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#define endl '\n'
#define ll long long
#define NCONS 100001

using namespace std;

int f[NCONS];
int ret;

int main(void)
{
        cin.tie(NULL); ios_base::sync_with_stdio(false);
        int N; cin >> N;
        for(int i = 0; i < N; i++)
        {
                int temp; cin >> temp;
                if(temp >= NCONS)
                {
                        ret += 1;
                        continue;
                }
                f[temp] += 1;
        }


        for(int i = 0; i < NCONS; i++)
        {
                if(f[i] == 0) continue;
                if(f[i] > i) ret += f[i] - i;
                if(f[i] < i) ret += f[i];
        }
        cout << ret << endl;

        return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

struct Program {
  int s, t, c;
  bool operator<(const Program& rhs) const { return s < rhs.s; }
};

int main() {
  int N, C;
  while (cin >> N >> C) {
    vector<Program> programs;
    for (int i = 0; i < N; i++) {
      int s, t, c;
      cin >> s >> t >> c;
      programs.push_back({s, t, c});
    }
    sort(programs.begin(), programs.end());
    for (int c = 1; c <= C; c++) {
      vector<int> recorder(c, -1);
      bool ok = true;
      for (int i = 0; i < N; i++) {
        auto p = programs[i];
        int k = -1;
        for (int j = 0; j < c; j++) {
          if (recorder[j] == -1) {
            k = j;
            continue;
          }
          auto q = programs[recorder[j]];
          if (q.c == p.c) {
            if (q.t <= p.s) {
              k = j;
              break;
            }
          } else {
            if (q.t < p.s) {
              k = j;
            }
          }
        }
        if (k == -1) {
          ok = false;
          break;
        }
        recorder[k] = i;
      }
      if (ok) {
        cout << c << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1912
import java.util.*;
public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 0;
        for(int i=0;i<6;i++){
            if(s.charAt(i)=='1'){
                ans++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



void add(ll &a, ll b) { a += b; }



ll dp[25][15][200];     // index, number, sum
int n, k, s;

int main() {
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    
    for (int i = 0; i <= 20; ++i) {
        for (int k = 0; k < 15; ++k) {
            for (int s = 0; s < 200; ++s) {
                //if (dp[i][k][s]) cout << i << ", " << k << ", " << s << " : " << dp[i][k][s] << endl;
                add(dp[i+1][k][s], dp[i][k][s]);
                if (s + (i+1) < 200) add(dp[i+1][k+1][s + (i+1)], dp[i][k][s]);
            }
        }
    }
    
    while (cin >> n >> k >> s) {
        if (n == 0) break;
        cout << dp[n][k][s] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1748
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<cmath>
#include<iomanip>
#define ll long long
using namespace std;
const int N=5e5+5;

const ll Max=1e18+1000;
const double PI=acos(-1);
int x[N];
int y[N];
int z[N];

int main()
{
	int a,b,h,m;
	while(cin>>a>>b>>h>>m)
	{
		double s=abs(h*30+m*0.5-m*6);
		if(s>180)
		s=360-s; 
		double ans=sqrt(a*a+b*b-2*a*b*cos(s*PI/180));
		cout<<fixed<<setprecision(20)<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long k, ans = 0;
    cin >> k;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                int g = __gcd(i, j);
                g = __gcd(g, l);
                ans = ans + g;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int phi(int n)
{
    int ans = n;
    for (int i = 2; i *i <= n; i++) {
        if (n % i == 0) {
            ans = ans / i * (i - 1);
            while (n % i == 0) {
                n /= i;
            }
        }
    }

    if (n > 1) {
        ans = ans / n * (n - 1);
    }
    return ans;
}

int main()
{
    int n;
    int cnt = 0;

    cin >> n;
    cout << phi(n) << endl;

    return 0;
}

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

int main(){
    int a, b;
  	cin >> a >> b;
  	
  if ( (a + b) % 2 != 0){
    int avg = (a + b) / 2 + 1;
    cout << avg << endl;
  }else{
    int avg = (a + b) / 2;
    cout << avg << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 3616
N = int(input())

result = 0

for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        result += i

print(result)


Measured memory_bytes: 64940
#include<iostream>
#include<algorithm>
#include<vector>
int main() {
	int N;
	std::cin >> N;
	std::vector<int>sum(N), sort(N);
	for (int i = 0; i < (N - 1)*N / 2; i += 1) {
		int a, b, c, d;
		std::cin >> a >> b >> c >> d;
		if (c > d) {
			sum[a - 1] += 3;
		}
		else if (d > c) {
			sum[b - 1] += 3;
		}
		else {
			sum[a - 1] += 1;
			sum[b - 1] += 1;
		}
	}
	for (int i = 0; i < N; i += 1)
		sort[i] = sum[i];
	std::sort(sort.begin(), sort.end());
	for (int i = 0; i < N; i += 1)
		for (int j = N-1; j >= 0; j -= 1) {
			if (sum[i] == sort[j]) {
				std::cout << N-j << std::endl;
				break;
			}
		}
	return 0;
}

Measured memory_bytes: 3160
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

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

inline ll lobit(ll x) {
  return x & -x;
}

inline int check(ll L, ll R) {
  return L > R - lobit(R);
}

map <pii, ll> memo;

ll f(ll L, ll R) {
  ll &ref = memo[pii(L, R)];
  if (ref)
    return ref;
  if (L > R)
    return ref = 0;
  if (L == R)
    return ref = 1;
  return ref = f((L + 1) / 2, R / 2) + f(L / 2, R / 2) - (!(R % 2) && check(L / 2, R / 2));  
}

int main() {
  ll A, B;
  scanf("%lld%lld", &A, &B);
  printf("%lld\n", f(A, B));
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
 
template<ll MOD>
class rolloing_hash {
public:
    int n;
    ll b;
    vector<ll> pow, hash;
 
    rolloing_hash() {}
 
    rolloing_hash(const string &s, ll b_ = 10007) { set(s, b_); }
 
    void set(const string &s, ll b_ = 10007) {
        n = s.size();
        b = b_;
        calc(s.c_str());
    }
 
    ll get() const { return get(n); }
 
    ll get(int i) const { return hash[i]; }
 
    ll get(int i, int j) const {
        return (get(j) - get(i) * pow[j - i] % MOD + MOD) % MOD;
    }
 
private:
    void calc(const char *s) {
        pow.resize(n + 1); pow[0] = 1;
        hash.resize(n + 1); hash[0] = 0;
        for (int i = 0; i < n; ++i) {
            pow[i + 1] = pow[i] * b % MOD;
            hash[i + 1] = (s[i] + hash[i] * b) % MOD;
        }
    }
};
 
// 1000000007, 1000000009, 1000000021, ...
using RH1 = rolloing_hash<1000000007>;
using RH2 = rolloing_hash<1000000021>;
 
string s;
string x[200010], y[200010];
ll hx[200010], hy[200010];
unordered_map<ll, int> shx, shy;
unordered_set<int> sx, sy;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
 
    cin >> s;
    int n;
    cin >> n;
    RH1 rh1;
    RH2 rh2;
 
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
 
        rh1.set(x[i]);
        rh2.set(x[i]);
        ll h = rh1.get() << 32 | rh2.get();
        hx[i] = h;
        shx[h] = -1;
        sx.insert(x[i].size());
 
        rh1.set(y[i]);
        rh2.set(y[i]);
        h = rh1.get() << 32 | rh2.get();
        hy[i] = h;
        shy[h] = -1;
        sy.insert(y[i].size());
    }
     
    rh1.set(s);
    rh2.set(s);
    for (auto &e : sx) {
        for (int i = 0; i + e <= (int)s.size(); ++i) {
            ll h = rh1.get(i, i + e) << 32 | rh2.get(i, i + e);
            auto it = shx.find(h);
            if (it != shx.end() && it->second == -1) it->second = i;
        }
    }
    for (auto &e : sy) {
        for (int i = (int)s.size() - e; i >= 0; --i) {
            ll h = rh1.get(i, i + e) << 32 | rh2.get(i, i + e);
            auto it = shy.find(h);
            if (it != shy.end() && it->second == -1) it->second = i;
        }
    }
 
    for (int i = 0; i < n; i++) {
        int l = shx[hx[i]];
        int r = shy[hy[i]];
        if (l != -1 && r != -1 && l <= r && l + x[i].size() <= r + y[i].size()) {
            cout << r - l + (int)y[i].size();
        } else {
            cout << 0;
        }
        cout << '\n';
    }
}

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

int main() {
  int n;
  int num = 0;
  int w = 0;
  while(cin >> n && n) {
    for(int i = 0; i < n*(n-1)/2; i++) {
      cin >> num;
      w += num;
    }
    cout << w /(n-1) << endl;
    num = 0;
    w = 0;
  }

  return 0;
}

Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
	int n; cin >> n; 
	ll sum = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 == 0 || i % 5 == 0)continue;
		sum += i;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 3628
//07, 07, 2018, 09:01:14 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b;

    cin >> a >> b;

    if(a * b == 15){
        cout << "*" << endl;
    }else if(a + b == 15){
        cout << "+" << endl;
    }else{
        cout << "x" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<ll> s(n+1);
  rep(i, n) s[i+1] = s[i]+a[i];
  ll ans = 1e18;
  for (int i = 1; i < n; i++)
    chmin(ans, abs(s[n]-s[i]*2));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
n=int(input())
p=list(map(int,input().split()))
count=[0]*n
for i in range(1,n+1):
    if p[i-1]==i:
        count[i-1]+=1
ans=0
j=0
while j<=n-1:
    temp=1
    k=0
    if count[j]==1:
        while j+k+1<=n-1 and count[j+k]==count[j+k+1]==1:
    
            temp+=1
            k+=1
        if temp%2==0:
            ans+=(temp//2)
        else:
            ans+=((temp//2)+1)
    j+=(k+1)
print(ans)

Measured memory_bytes: 20464
#include <stdio.h>
#include <string.h>

int main(void)
{
	char in, stack[10] = {};
	for (;;) {
		scanf("%d", &in);
		if (in)
			stack[strlen(stack)] = in;
		else {
			if (!stack[0])
				return 0;
			else {
				printf("%d\n", stack[strlen(stack) - 1]);
				stack[strlen(stack) - 1] = 0;
			}
		}
	}
}

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	w := SScan(n)
	d := make(map[string]struct{})
	ans := "Yes"
	for i := 0; i < n-1; i++ {
		if w[i][len(w[i])-1] != w[i+1][0] {
			ans = "No"
		}
		d[w[i]] = struct{}{}
	}
	d[w[n-1]] = struct{}{}
	if len(d) != n {
		ans = "No"
	}
	fmt.Println(ans)
}


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

typedef long long ll;
typedef vector<int> vec;

int main() {
    ll L, R;
    cin >> L >> R;
    
    //R-Lが2019以上なら自明に0
    if (R-L >= 2019) {
        cout << 0 << endl;
        return 0;
    }
    //2018以下ならループ回せる
    vec A(R-L+1);
    for (ll i=L; i<=R; i++) {
        A[i-L] = i%2019;
    }
    
    int ans = 2019;
    
    for (ll i=L; i<=R-1; i++) {
        for (ll j=i+1; j<=R; j++) {
            ans = min(ans, (A[i-L]*A[j-L])%2019);
        }
    }
    
    cout << ans << endl;
}

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

int dp[105][4][2];

int main() {
    string s;
    int t;
    cin >> s >> t;
    int n = s.size();
    dp[0][0][0] = 1;
    rep(i,n)rep(j,4)rep(k,2) {
        int nd = s[i] - '0';
        rep(d,10) {
            int ni = i+1, nj = j, nk = k;
            if (d != 0) nj++;
            if (nj > t) continue;
            if (k == 0) {
                if (d > nd) continue;
                if (d < nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    int ans = dp[n][t][0] + dp[n][t][1];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	if (a==b) {cout<<"Draw"<<endl;return 0;}
	if (a==1) {cout<<"Alice"<<endl;return 0;}
	if (b==1) {cout<<"Bob"<<endl;return 0;}
	if (a>b) {cout<<"Alice"<<endl;return 0;}else
	  {cout<<"Bob"<<endl;return 0;}
	return 0;
}


Measured memory_bytes: 256
def solve(S):
    for i in range(1, len(S)+1):
        c = S[i-1]
        if i % 2 == 1 and c not in "RUD":
            return "No"
        if i % 2 == 0 and c not in "LUD":
            return "No"
    return "Yes"
                

def main():
    S = input().strip()
    print(solve(S))

main()



Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>

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

using namespace std;

const int N = 600;

int col[N];
char s[N][N];

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

  int h;
  cin >> h;
  int w = h;

  rep(i,h)
    cin >> s[i];

  //真っ白かどうか確認;
  bool flg = false;
  rep(i,h)
    rep(j,w)
      flg |= ('#' == s[i][j]);

  if(!flg) {
    cout << -1 << endl;
    return 0;
  }

  rep(i,h){
    rep(j,w){
      if('#' == s[i][j]){
        col[j]++;
      }
    }
  }
  
  int ans = (int) 1e9;
  rep(i,h){
    int cur=0;
    if(0 == col[i]){
      cur++;
    }
    rep(j,w){
      if('.' == s[i][j]){
        cur++;
      }
    }
    rep(j,w){
      if(col[j] < h){
        cur++;
      }
    }
    ans = min(ans, cur);
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(){
long n;
int i, min;
cin >> n;
min = (int)log10((long)n) +1;
for(i=1; i <= (long)sqrt((long)n); i++){
    if(n%i==0){
        min = fmin(min, fmax((int)log10((double)i)+1,(int)log10((long double)n/i)+1));
    }
}
cout << min << endl;
return 0;
}


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

int main() {
  int A, B, C, count5, count7;
  cin >> A >> B >> C;
  count5 = 0;
  count7 = 0;
  if (A==5){
    count5++;
  }
  if (B==5){
    count5++;
  }
  if (C==5){
    count5++;
  }
  if (A==7){
    count7++;
  }
  if (B==7){
    count7++;
  }
  if (C==7){
    count7++;
  }
  if (count5==2&&count7==1){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int n, ans=0; cin >> n;
  v<int> s(n);
  rep(i,n) cin >> s[i];
  sort(s.begin(),s.end());
  int q; cin >> q;
  rep(i,q){
    int t; cin >> t;
    if(binary_search(s.begin(),s.end(),t)) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3472
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}
ll f[210000];
void cominit() {
	f[0] = 1;
	REP(i, 200000)f[i + 1] = f[i] * (i + 1) % MOD;
}

ll com(ll n, ll r) {
	return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll perm(ll n, ll r) {
	return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}
ll ans = 0;
int main() {
	cominit();
	ll n, k;
	cin >> n >> k;
	REP(i, min(n, k + 1)) {
		ans += com(n, i) * com(n - 1, n - i - 1);
		ans %= MOD;
	}
	cout << ans << endl;
}



Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        for(int x = 1; x<10000;x++){

            if((int) (x*0.08)==N && (int) (x*0.1)==M){
                System.out.println(x);
                return;
            }
        }
        System.out.println(-1);



    }

}


Measured memory_bytes: 21972
N, W = map(int, input().split())

MAX_V = 10**5
dp = [[10**(18)]*(MAX_V+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(1, N+1):
  w, v = map(int, input().split())
  for j in range(MAX_V+1):
    dp[i][j] = dp[i-1][j]
    if j >= v:
      dp[i][j] = min(dp[i][j], dp[i-1][j-v]+w)

ans = 0
for j in range(MAX_V+1):
  if dp[N][j] <= W and dp[N][j] != 10**(18):
    ans = max(ans, j)
print(ans)

Measured memory_bytes: 119788
fun main(args: Array<String>) {
    val  inLyric = readLine()?.split(" ").orEmpty()
    var inList = mutableListOf<Int>()
    var collectList = mutableListOf(5, 7, 5)

    inLyric.forEach{
        inList.add(it.toInt())
    }
    inList.sort()
    collectList.sort()

    if(inList == collectList){
        println("YES")
    }else{
        println("NO")
    }

}

Measured memory_bytes: 35820
# 動的計画法による解法

s = int(input())
mod = pow(10, 9) + 7

A = [0] * (s + 1)

if s >= 3:
    A[3] = 1

for i in range(4, s + 1):
    A[i] = (A[i - 3] + A[i - 1]) % mod

print(A[s])

Measured memory_bytes: 9180
import numpy as np

W, H, N = map(int, input().split())
grid = np.ones((H, W), np.int64)

for _ in range(N):
  x, y, a = map(int, input().split())
  x -= 1
  y -= 1
  if a == 1:
    grid[:, :x+1] = 0
  if a == 2:
    grid[:, x+1:] = 0
  if a == 3:
    grid[-y-1:, :] = 0
  if a == 4:
    grid[:-y-1, :] = 0

print(np.sum(grid))    

Measured memory_bytes: 12536
#include <bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    if (a>b) swap(a,b);
    if (a%2==b%2)
    {
        printf("%lld\n",(b-a)/2);
        return 0;
    }
    long long ans=min((a+b-1)/2,(n-a+n-b+1)/2);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
   int A, B, C;
   scanf("%d %d %d", &A, &B, &C);

   if(A >= B && A >= C) {
      printf("%d\n",A*10 + B + C);
   }  else if(B >= A && B >= C) {
      printf("%d\n",B*10 + A + C);
   }   else if(C >= B && C >= A) {
      printf("%d\n",C*10 + A + B);
   }

   return 0;
}


Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
int main()
{	
	int c=0,b=0,n,m,x,i;
	int a[120];
	cin >> n >> m >> x;
	for(i=0;i<m;i++){
		cin >> a[i];
	}
	for(int j=x-1;j>=0;j--){
		for(int k=0;k<m;k++){
			if(a[k]==j){
				c++;
			}
		}
	}
	for(int l=x+1;l<=n;l++){
		for(int o=0;o<m;o++){
			if(a[o]==l){
				b++;
			}
		}
	}
	if(b<c){
		cout << b << endl;
	}
	else{
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//package compilers;

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int [][]arr=new int[n][3];
		int [][]dp= new int[n][3];
		for(int i=0;i<n;i++) {
			for(int j=0;j<3;j++) {
				arr[i][j]=in.nextInt();
			}
		}
		dp[0][0]=arr[0][0];
		dp[0][1]=arr[0][1];
		dp[0][2]=arr[0][2];
		for(int i=1;i<n;i++) {
			dp[i][0]=arr[i][0]+Math.max(dp[i-1][1], dp[i-1][2]);
			dp[i][1]=arr[i][1]+Math.max(dp[i-1][0], dp[i-1][2]);
			dp[i][2]=arr[i][2]+Math.max(dp[i-1][1], dp[i-1][0]);
			//System.out.println(dp[i][0] + " "+ dp[i][1] + " "+dp[i][2] + " ");
		}
		
		System.out.println(Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
	}

}


Measured memory_bytes: 103156
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

int main(){
    ll X; cin>>X;
    if(X>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int d[100001];
long long k[100001],a[100001];
int main(void)
{
	int n,q,i,cnt,x,j,flg;
	long long MAX,MAX2,t,aa;
	scanf("%d %lld %d",&n,&t,&q);
	cnt=0;
	flg=0;
	for(i=1;i<=n;i++){
		scanf("%lld %d",&a[i],&d[i]);
		if(d[i]==1){
			MAX=a[i];
			flg=1;
		}
		if(flg==1&&d[i]==2&&(a[i]-MAX)/2<t){
			k[cnt]=(long long)(MAX+a[i])/2;
			flg=0;
			cnt++;
		}
	}
	for(i=0;i<q;i++){
		scanf("%d",&x);
		if(d[x]==1){
				aa=a[x]+t;
			}
		if(d[x]==2){
			aa=a[x]-t;
		}
		for(j=0;j<cnt;j++){
			if(aa>k[j]&&d[x]==1&&a[x]<k[j]){
				aa=k[j];
			}
			if(aa<k[j]&&d[x]==2&&a[x]>k[j]){
				aa=k[j];
			}
		}
		printf("%lld\n",aa);
	}	
	return 0;
}


Measured memory_bytes: 4048
import java.util.*;
public class Main {
	
	static int len;
	static int num[] = {3,5,7};
	static int cnt;
	static int N;
	static String S;
	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		sc.close();
		
		S = Integer.toString(N);
		len = S.length();
		cnt = 0;	
		dfs(0);
		System.out.println(cnt);
	}
		
	static void dfs(int x) {
		String res = Integer.toString(x);
		
		boolean is357 = true;
		if(x>N){
				is357 = false;
				return;
		}
		for(int i=0;i<3;i++) {
			int n = num[i];
			if(res.indexOf((char)(n+'0'))==-1) {
				is357 =false;
			}
		}
		if(is357)cnt++;
		
		if(res.length()>=len) return;
		
		for(int i=0;i<3;i++) {
			int n = num[i];
			dfs(x*10+n);
		}
	}
	
}

Measured memory_bytes: 24276
#include<stdio.h>

char s[7];

int n, a, b;

int main()
{
	int ans=0;
	scanf("%d%d%d", &n, &a, &b);
	for(int i=1; i<=n; i++)
	{
		int tmp=0;
		sprintf(s, "%d", i);
		for(int j=0; s[j]; j++)
		{
			 tmp+=s[j]-'0';
		}
		if(a<=tmp&&tmp<=b) ans+=i;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
n, m=(int(x) for x in input().split())
matrix=[[int(x) for x in input().split()] for i in range(n)]
vector=[int(input()) for i in range(m)]
result=[0]*n
for i in range(n):
    for j in range(m):
        result[i]=result[i]+(matrix[i][j]*vector[j])
for v in result:
    print(v)


Measured memory_bytes: 6024