akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

typedef long long LL;
typedef unsigned long UL;

using namespace std;

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

    int n;
    cin >> n;

    if (n < 105)
    {
        cout << 0 << endl;
    }
    else if (n >= 105 && n < 135)
    {
        cout << 1 << endl;
    }
    else if (n >= 135 && n < 165)
    {
        cout << 2 << endl;
    }
    else if (n >= 165 && n < 189)
    {
        cout << 3 << endl;
    }
    else if (n >= 189 && n < 195)
    {
        cout << 4 << endl;
    }
    else if (n >= 195)
    {
        cout << 5 << endl;
    }

    return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, d;
  cin >> n >> d;
  cout << (n + 2 * d) / (2 * d + 1) << 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);
    int N = sc.nextInt();
    int[] a = new int[N+1];
    for (int i=0; i<N; i++) {
      a[i+1] = sc.nextInt();
    }
    int point =1;
    int check =-1;
    for (int i=1; i<N+1; i++) {
      point = a[point];
      if (point == 2) {
        check =i;
        break;
      }
    }
    System.out.println(check);
  }
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  
  string s;
  cin >> s;

  vector<int> b(n, 0), w(n, 0);
  if ( s[0] == '.' ) w[0] = 1;
  for ( int i = 1; i < n; i++ ) {
    w[i] = w[i-1];
    if ( s[i] == '.' ) w[i]++;    
  }

  if ( s[0] == '#' ) b[0] = 1;
  for ( int i = 1; i < n; i++ ) {
    b[i] = b[i-1];
    if ( s[i] == '#' ) b[i]++;    
  }

  int B = 0, W = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( s[i] == '.' ) W++;
    else B++;
  }
  
  int ans = 1000000;  
  for ( int i = 1; i < n; i++ ) {
    ans = min(ans, b[i-1]+W-w[i-1]);    
  }

  cout << min(ans, min(B, W)) << endl;  
  
  return 0;
}


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

int main()
{
    int n, p1 = 0, p2 = 0;
    cin >> n;
    rep(i, n)
    {
        string taro, hanako;
        cin >> taro >> hanako;
        if (taro == hanako)
        {
            p1++;
            p2++;
        }
        else if (taro > hanako)
        {
            p1 += 3;
        }
        else
            p2 += 3;
    }
    cout << p1 << " " << p2 << endl;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 100005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,ar[51],A; ll dp[51][51][2501];
ll maxval(ll cur_i,ll cur_n,ll cur_sum){
	if(cur_i==n+1){
		if(cur_n*A==cur_sum&&cur_n>0) return 1;
		else return 0;
	}
	if(dp[cur_i][cur_n][cur_sum]!=-1){
		return dp[cur_i][cur_n][cur_sum];
	}

	ll a,b;
	a=maxval(cur_i+1,cur_n,cur_sum);
	b=maxval(cur_i+1,cur_n+1,cur_sum+ar[cur_i]);
	return dp[cur_i][cur_n][cur_sum]=a+b;
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n>>A;	
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	memset(dp,-1,sizeof(dp));
	ll an=maxval(1,0,0);
	cout<<an;
	return 0;	
}

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


using ll = long long;
const int Mod = 1e9+7;
int N;
vector<int> C;


ll powmod(ll a, ll b, ll m) {
    ll c = 1;
    for (; b; b >>= 1, a = (ll)a * a % m) {
        if (b & 1) c = c * a % m;
    }
    return c;
}


void solve()
{
    sort(C.begin(), C.end());    
    ll d = (N == 1) ? 0 : powmod(2, N - 2, Mod);
    ll w = (N == 1) ? 1 : (N + 1) * d % Mod;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans = (ans + C[i] * w) % Mod;
        w = (w - d + Mod) % Mod;
    }
    ans = ans * powmod(2, N, Mod) % Mod;
    cout << ans << endl;
}


int main()
{
    cin >> N;
    C.resize(N);
    for (int i = 0; i < N; i++) cin >> C[i];
    solve();
    return 0;
}


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

const int N=100005;

int n,cnt,a,b;
int f[N];

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&f[i]);
	sort(f+1,f+1+n);
	if (f[n]>f[1]+1){
		printf("No\n");
		return 0;
	}
	if (f[n]==f[1]){
		if (f[n]*2<=n||f[n]==n-1) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	for (i=1;i<=n;i++) if (f[i]==f[1]) a++;
	cnt=n-a; b=f[n]-a;
	if (b*2<=cnt&&b>0) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 768
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
long long lcm(long long a,long long b){
    return a*b/__gcd(a,b);
}
long long num(long long A,long long B,long long M){
     // Add 1 explicitly as A is divisible by M
    return (B / M) - ((A - 1) / M);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long nms=0;
    nms=num(a,b,c)+num(a,b,d)-num(a,b,lcm(c,d));
    cout << (b-a+1)-nms << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[][] A = new int[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                A[i][j] = scan.nextInt();
            }
        }
        int[] b = new int[m];
        for(int i = 0; i < m; i++){
            b[i] = scan.nextInt();
        }
        int[] c = new int[n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                c[i] += A[i][j] * b[j];
            }
            System.out.println(c[i]);
        }
        
    }
}

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

int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  for(int i = 0; i < 4; i++){
  	mp[s.at(i)]++;
  }
  
  bool ans = true;
  
  int count = 0;
  for(auto p : mp){
  	count++;
    if(p.second != 2){
    	ans = false;
    }
  }
  if(count != 2){
  	ans = false;
  }
  
  if(ans){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

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

const int N = 200005;
const int mo = 1e9 + 7;

int w, b;
int fac[N + 5], inv[N + 5];
int pre[N + 5], suf[N + 5], ans[N + 5];

int fpm(int x, int y) {
  int res = 1;
  for (; y > 0; y >>= 1) {
    if (y & 1)
      res = 1ll * res * x % mo;
    x = 1ll * x * x % mo;
  }
  return res;
}

void init() {
  fac[0] = 1;
  for (int i = 1; i <= N; ++i) fac[i] = 1ll * fac[i-1] * i % mo;
  inv[N] = fpm(fac[N], mo - 2);
  for (int i = N; i >= 1; --i) inv[i-1] = 1ll * inv[i] * i % mo;
}

inline int binom(int x, int y) {
  if (x < 0 || y < 0 || x < y) return 0;
  return 1ll * fac[x] * inv[y] % mo * inv[x - y] % mo;
}

int main() {
#ifdef Wearry
  freopen("in", "r", stdin);
  freopen("out", "w", stdout);
#endif

  init();
  cin >> b >> w;

  for (int i = 1; i <= b; ++i) {
    int p = fpm(fpm(2, mo - 2), w + b - i);
    suf[w + b - i + 1] = (suf[w + b - i + 1] + 1ll * binom(w + b - i - 1, w - 1) * p) % mo;
    pre[w + b - i - 1] = (pre[w + b - i - 1] + 1ll * binom(w + b - i - 2, b - i - 1) * p) % mo;
  }

  for (int i = 1; i <= w; ++i) {
    int p = fpm(fpm(2, mo - 2), w + b - i);
    pre[w + b - i - 1] = (pre[w + b - i - 1] + 1ll * binom(w + b - i - 2, b - 2) * p) % mo;
    ans[w + b - i] = (ans[w + b - i] + 1ll * binom(w + b - i - 1, b - 1) * p) % mo;
  }

  for (int i = 1; i <= w + b; ++i) {
    suf[i] = (suf[i] + suf[i-1]) % mo;
    ans[i] = (ans[i] + suf[i]) % mo;
  }

  for (int i = w + b; i >= 1; --i) {
    pre[i] = (pre[i] + pre[i+1]) % mo;
    ans[i] = (ans[i] + pre[i]) % mo;
  }

  for (int i = 1; i <= w + b; ++i) {
    printf("%d\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
queue<pair<int, int> > q;
int main () {
    int h, w;
    cin >> h >> w;
    bool white[h + 1][w + 1];
    int count[h + 1][w + 1];
    memset(count, -1, sizeof(count));
    for (int i = 1; i <= h; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= w; j++) {
            if (s[j - 1] == '.') {
                white[i][j] = true;
            }
            else {
                white[i][j] = false;
                q.push(make_pair(i, j));
                count[i][j] = 0;
            }
        }
    }
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    while (q.size()) {
        pair<int, int> p = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            int nextx = p.first + dx[i];
            int nexty = p.second + dy[i];
            if ((1 <= nextx) && (nextx <= h) && (1 <= nexty) && (nexty <= w) && (count[nextx][nexty] == -1) && (white[nextx][nexty])) {
                count[nextx][nexty] = count[p.first][p.second] + 1;
                q.push(make_pair(nextx, nexty));
            }
        }
    }
    int max = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (count[i][j] > max) {
                max = count[i][j];
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 16256
const M : usize = 1_000_000_007;

fn main()
{
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();

    let data: Vec<&str> = line.split_whitespace().collect();
    let r1 = data[0].parse().unwrap_or(0);
    let c1 = data[1].parse().unwrap_or(0);
    let r2 = data[2].parse().unwrap_or(0);
    let c2 = data[3].parse().unwrap_or(0);

    let n = r2 + c2 + 2;

    let mut f1 = vec![1; n];
    let mut f2 = vec![1; n];
    let mut ff = vec![1; n];

    for i in 2..n
    {
        f1[i]  = f1[i - 1] * i % M;
        ff[i] = M - ff[M % i] * (M / i) % M;
        f2[i] = f2[i - 1] * ff[i] % M;
    }

    let ncr = |n, r| (f1[n] * ((f2[r] * f2[n - r]) % M)) % M;
    let sum = |x, y| (1 .. (x + 2)).fold(0, |v, i| (v + ncr(y + i, i)) % M);

    let a = sum(r2, c2);
    let b = sum(r1 - 1, c2);
    let c = sum(r2, c1 - 1);
    let d = sum(r1 - 1, c1 - 1);

    let ans = (4 * M + a + d - b - c) % M;
    println!("{}", ans);
}


Measured memory_bytes: 53500
#include <bits/stdc++.h>
using namespace std;
int n;
int p[10],q[10];

bool check(int x[], int y[])
{
	for(int i=1;i<=n;i++)
		if(x[i]!=y[i]) return false;
	return true;
}

int main()
{
	cin>>n;
	int b[n+1];
	for(int i=1;i<=n;i++) cin>>p[i]; 
	for(int i=1;i<=n;i++) cin>>q[i];
	for(int i=1;i<=n;i++) b[i]=i; 

	int nc=0,x=0,y=0;
	do{
		nc++;
		if(check(b,p)) x=nc;
		if(check(b,q)) y=nc;
		if(x!=0 && y!=0) break;
	}while(next_permutation(b+1,b+n+1));
	cout<<abs(x-y)<<endl;
	return 0;
}

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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        char[] S = in.s(N);

        int[] c = new int[26];
        for (int i = 0; i < N; i++) {
            c[S[i] - 'a']++;
        }

        int m = 1_000_000_007;
        long ans = 1;
        for (int i = 0; i < 26; i++) {
            ans = ans * (c[i] + 1) % m;
        }
        ans--;

        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


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

int main(void)
{
    IOS
    string s;
    cin >> s;
    int ans = 0;
    vector<string> w{"SUN","MON","TUE","WED","THU","FRI","SAT"};
    REP(i,w.size()) {
        if (w[i] == s) {
            ans = 7-i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

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

    const auto isOK = [](const string &s) {
        return all_of(begin(s), end(s), [&](char c){ return c == s[0]; });
    };

    string x;
    cin >> x;

    int ans = INF;
    for (char ch = 'a'; ch <= 'z'; ++ch) {
        int cnt = 0;
        string s = x;
        while(!isOK(s)) {
            for (int i = 0; i+1 < s.length(); ++i) {
                if (s[i] == ch) continue;
                if (s[i+1] == ch) s[i] = ch;
            }
            s.pop_back();
            ++cnt;
        }
        chmin(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

// vim: set foldmethod=marker :


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x,T a,T b){return a<=x&&x<=b;}
template<class T> void amin(T &a,T v){if(a>v) a=v;}
template<class T> void amax(T &a,T v){if(a<v) a=v;}
int ROUND(double x) { return (int)(x+0.5); }
bool ISINT(double x) { return fabs(ROUND(x)-x)<=EPS; }
bool ISEQUAL(double x,double y) { return fabs(x-y)<=EPS*max(1.0,max(fabs(x),fabs(y))); }
double SQSUM(double x,double y) { return x*x+y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


int main()
{
	ll s, c;
	cin >> s >> c;

	ll lo = 0;
	ll hi = (ll)(1e12+100);


	while (lo < hi)
	{
		ll mid = lo + (hi - lo + 1) / 2LL; // +1 is necessary, otherwise infinite loop when only two elements.


		bool ok = true;

		
		ll remc = c;

		if (s >= mid)
		{

		}
		else
		{
			remc -= (mid-s)*2;
		}

		if(remc<0) ok = false;

		if (remc<2*mid) ok = false;

		if (!ok)
		{
			hi = mid - 1;
		}
		else
		{
			lo = mid;
		}
	}

	cout << lo << 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);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int N = sc.nextInt();
    int[][] ans = new int[H][W];
    int i = 0;
    int j = 0;
    boolean plus = true;
    for (int c = 1; c <= N; c++) {
      int a = sc .nextInt();
      while (a-- > 0) {
        ans[i][j] = c;
        // next
        if (plus) {
          if (j == W-1) {
            i++;
            plus = false;
          } else {
            j++;
          }
        } else {
          if (j == 0) {
            i++;
            plus = true;
          } else {
            j--;
          }
        }
      }
    }
    StringBuilder builder = new StringBuilder();
    for (int q = 0; q < H; q++) {
      for (int r = 0; r < W; r++) {
        builder.append(ans[q][r]);
        if (r == W-1) {
          builder.append('\n');
        } else {
          builder.append(' ');
        }
      }
    }
    System.out.println(builder.toString());
  }
}

Measured memory_bytes: 31948
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
fact = [1]*(2*10**5+1)
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp %= mod
  fact[i]=tmp
  
def comb(n,k):
  k = min(k,n-k)
  fa = 1
  for i in range(n,n-k,-1):
    fa*=i
    fa%=mod
  return fa*pow(fact[k],mod-2,mod)
mi = comb(n,a)+comb(n,b)
mi%=mod
ans-=mi
ans%=mod
print(ans)

Measured memory_bytes: 40304
N = int(input())
A = [int(i) for i in input().split()]
count = 0 
flag=True
while flag:
  for i in range(len(A)):
    if not A[i] % 2 == 0:
      flag=False
      print(count)
      break
    else:
      A[i] = int(A[i] / 2)
  count+=1

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int s, d, m, k, w, p, f;

    while(cin >> s >> d >> m){
        int dp[301] = {};

        vector<pair<int,int>> v[s];
        for(int i = 0; i < s; i++){
            cin >> k;
            while(k-- > 0){
                cin >> w >> p;
                v[i].push_back({w,p});
            }
        }

        map<pair<int,int>,int> ma;

        for(int i = 0; i < d; i++){
            cin >> f;
            for(pair<int,int> price : v[f]) ma[price]++;
        }

        for(auto x : ma){
            pair<int,int> price = x.first;
            for(int i = 0; i < ma[price]; i++){
                // 2進を使って効率よくやった方が良いかもしれないが、面倒なのでさぼる
                for(int j = m; j >= price.second; j--){
                    dp[j] = max(dp[j], dp[j-price.second]+price.first);
                }
            }
        }

        int a = 0, b = 0;
        for(int i = 0; i <= m; i++){
            if(dp[i] > a){
                a = dp[i], b = i;
            }
        }
        cout << a << " " << b << endl;
    }

    return 0;
}


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

int main()
{
  vector<int> v(3);
  for(int i=0;i<3;i++)
    cin>>v[i];
  
  set<int> s;
   for(int i=0;i<3;i++)
   {
     s.insert(v[i]);
   }
  if(s.size()==2)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<P> BA(N);
    for(int i = 0; i < N; ++i)  cin >> BA[i].second;
    for(int i = 0; i < N; ++i)  cin >> BA[i].first;
    sort(BA.begin(), BA.end());
    vector<P> A(N);
    for(int i = 0; i < N; ++i)  A[i] = P(BA[i].second, i);
    sort(A.begin(), A.end());
    vector<int> rev(N);
    for(int i = 0; i < N; ++i){
        if(A[i].first > BA[i].first){
            cout << "No\n";
            return 0;
        }
        rev[A[i].second] = i;
    }
    vector<bool> used(N, false);
    auto dfs = [&](auto&& self, int cur) -> void {
        used[cur] = true;
        int nxt = A[cur].second;
        if(!used[nxt])  self(self, nxt);
    };
    for(int v = 0; v < N; ++v){
        if(!used[v])    dfs(dfs, v);
    }
    vector<int> idx(N, -1);
    int k = 0;
    auto rdfs = [&](auto&& self, int cur) -> void {
        idx[cur] = k;
        int nxt = rev[cur];
        if(idx[nxt] == -1)  self(self, nxt);
    };
    for(int v = 0; v < N; ++v){
        if(idx[v] == -1){
            rdfs(rdfs, v);
            ++k;
        }
    }
    if(k > 1){
        cout << "Yes\n";
        return 0;
    }
    for(int i = 0; i < N - 1; ++i){
        if(BA[i].first >= A[i + 1].first){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 5520
#include <cstdio>
#include <algorithm>

using namespace std;

int N;
int a[100000];
int b[100000];
int c[100000];
int dp[100000][3];

int main(){

    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%d %d %d", &a[i], &b[i], &c[i]);
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i < N; i++){
        int temp0 = max(dp[i - 1][1], dp[i - 1][2]);
        int temp1 = max(dp[i - 1][2], dp[i - 1][0]);
        int temp2 = max(dp[i - 1][0], dp[i - 1][1]);
        dp[i][0] = temp0 + a[i];
        dp[i][1] = temp1 + b[i];
        dp[i][2] = temp2 + c[i];
    }

    int ans = 0;
    
    for(int i = 0; i < 3; i++){
        if(dp[N - 1][i] > ans){
            ans = dp[N - 1][i];
        }
    }

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

    return 0;
}

Measured memory_bytes: 2560
#                               #
    # author : samars_diary #
    # 18-09-2020 │ 22:13:22 #
#                               #

import sys, os.path

#if(os.path.exists('input.txt')):
    #sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    k=ii();s=i()
    if len(list(s))<=k: print(s)
    else: print(s[:k]+'...')

for _ in range(1):
    solve()

Measured memory_bytes: 9200
# Educational_DP_A_Frogs.py

N = int(input())
H = list(map(int, input().split()))
# dp[i]:カエルがiに行くまでのコスト最小値
# dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]), dp[i-1]+abs(H[i]-H[i-1]))

dp = [0 for i in range(N)]
dp[1] = abs(H[0] - H[1])
for i in range(2,N):
    dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]))
    # print(dp)
print(dp[N-1])

Measured memory_bytes: 90264
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASecurity solver = new ASecurity();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASecurity {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            String s = sc.nextLine();
            for (int i = 1; i < 4; i++) {
                if (s.charAt(i) == s.charAt(i - 1)) {
                    out.println("Bad");
                    return;
                }
            }
            out.println("Good");
        }

    }

    static class inputClass {
        BufferedReader br;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

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

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, m;std::cin >> n >> m;
  ll P = 1000000007;
  ll a;
  vll dp(n+1, 0);
  re(i, m){
    std::cin >> a;
    dp[a] = -1;
  }
  dp[0] = 1;
  for(int i=1;i<=n;i++){
    if(dp[i]==-1) continue;
    dp[i] = ((dp[i-1]==-1?0:dp[i-1]) + (i==1?0:(dp[i-2]==-1?0:dp[i-2])))%P;
  }

  std::cout << dp[n] << '\n';
  return 0;
}


Measured memory_bytes: 1024
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;
void Anon_mouS(){
    int n;
    cin>>n;
    set <int> s;
    for(i=0;i<n;i++){
        int x;
        cin>>x;
        s.insert(x);
    }
    if(sz(s)==n)cout<<"YES";
    else cout<<"NO";
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  ll N;
  std::cin >> N;
  ll h[N];
  REP(i, N) std::cin >> h[i];
  ll dp[N] = {0};
  dp[1] = abs(h[1] - h[0]);
  REP(i, N) {
    if (i > 1) {
      ll one = abs(h[i] - h[i - 1]);
      ll two = abs(h[i] - h[i - 2]);
      dp[i] = min(dp[i - 1] + one, dp[i - 2] + two);
    }
  }
  std::cout << dp[N - 1] << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
bool used[100001]={};
vector<int> hen[100001];
int grundy(int a){
  used[a]=true;
  int ans=0;
  for(int i=0;i<hen[a].size();i++){
    if(!used[hen[a][i]])ans^=(1+grundy(hen[a][i]));
  }
  return ans;
}
signed main() {
int n;
cin>>n;
int a,b;
for(int i=0;i<n-1;i++){
  cin>>a>>b;a--;b--;
  hen[a].push_back(b);
  hen[b].push_back(a);
}
if(grundy(0))cout<<"Alice"<<endl;
else cout<<"Bob"<<endl;


return 0;
}


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

struct Dice{
  Dice(vector<int>& dice) : dice_(dice) {
    east_.push_back(4);    east_.push_back(2);
    east_.push_back(1);    east_.push_back(6);
    east_.push_back(5);    east_.push_back(3);
    north_.push_back(2);    north_.push_back(6);
    north_.push_back(3);    north_.push_back(4);
    north_.push_back(1);    north_.push_back(5);
    south_.push_back(5);    south_.push_back(1);
    south_.push_back(3);    south_.push_back(4);
    south_.push_back(6);    south_.push_back(2);
    west_.push_back(3);    west_.push_back(2);
    west_.push_back(6);    west_.push_back(1);
    west_.push_back(5);    west_.push_back(4);
  }

  void East(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[east_[i]-1];
  }

  void North(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[north_[i]-1];
  }

  void South(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[south_[i]-1];
  }

  void West(){
    vector<int> tmp(dice_);
    for(int i=0; i<6; i++)
      dice_[i] = tmp[west_[i]-1];
  }

  void Ans(){
    cout << dice_[0] << endl;
  }

  vector<int> dice_;
  vector<int> east_;
  vector<int> north_;
  vector<int> south_;
  vector<int> west_;
};

int main(){
  vector<int> a(6);
  string str;
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> str){
    Dice dice(a);
    for(int i=0; i<str.length(); i++){
      if(str[i] == 'E')
	dice.East();
      else if(str[i] == 'N')
	dice.North();
      else if(str[i] == 'W')
	dice.West();
      else
	dice.South();
    }
    dice.Ans();
  }
  return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         String s=gs();
         String t=gs();
         int ans = Integer.MAX_VALUE;
         for (int i=0; i<s.length()+1 - t.length();i++) {
        	 String sub=s.substring(i, i+t.length());
        	 int tmp=0;
        	 for (int j=0;j<t.length();j++) {
        		 char c=sub.charAt(j);
        		 char d=t.charAt(j);
        		 if(c!=d)tmp++;
        	 }
        	 ans=Math.min(tmp, ans);
         }

        	 System.out.println(ans);
         
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 36584
N, L = map(int, input().split())
l = []
a = abs(L)
b = a
for n in range(1, N+1):
  l.append(L+n-1)
  if abs(L+n-1) < a:
    a = abs(L+n-1)
    b = L+n-1

print(sum(l) - b)

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

#define ll long long

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

	ll r, d, x, temp;
	cin >> r >> d >> x;
	temp = x;
	for (int i = 0; i < 10; i++)
	{
		cout << r * temp - d << endl;
		temp = r * temp - d;
	}
	return 0;
}

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

using namespace std;

int main()
{
  int N;
  cin >> N;

  vector<int> W(N);

  int s = 0;

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

  int S1 = 0;
  int ans = s;
  for (int i = 0; i < N - 1; i++) {
    S1 += W[i];
    int S2 = s - S1;

    ans = min(ans, abs(S1 - S2));
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int N, X, T;
  cin >>N >>X >>T;
  
  int numbers;
  
  if (N % X == 0) {
  	numbers = N / X;
  }
  
  else {
    numbers = N / X + 1;
  }
  
  cout << numbers * T << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){ return (a % b)? gcd(b, a%b) : b; }
template<typename T> T lcm(T a, T b){ return a * b / gcd(a, b); }

int main(void){
    int n, m;
    cin >> n >> m;
    pair<ll, ll> p[n];
    REP(i,n) cin >> p[i].first >> p[i].second;

    sort(p, p+n, [](pair<int, int> x, pair<int, int> y){return x.first < y.first;});
    ll ans = 0;
    int i = 0;
    while(1){
        if(m-p[i].second > 0){
            ans += p[i].first * p[i].second;
            m -= p[i].second;
        } else{
            ans += p[i].first * m;
            break;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5168
#include<stdio.h>

int main(){
		long long x,ans;
		scanf("%lld",&x);
		if(x<=6)ans=1;
		else if(x<=11)ans=2;
		else {
				ans=(x/11)*2;
				if(1<=x%11&&x%11<=6)ans++;
				else if(7<=x%11)ans+=2;
		}
		printf("%lld\n",ans);
		return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;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;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<int> a(N);
    REP(i,N)a[i]=in();
    ll ans;ans=40000*100;

    for(int i=-100;i<=100;i++){
        ll s;s=0;
        REP(j,N){
            s+=pow(a[j]-i,2);
        }
        ans=min(ans,s);
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		long cnt = 0;
		for(int i=0;i<n;i++){
			sc.next();
			char c = sc.next().charAt(0);
			if(c=='(') cnt += sc.nextInt();
			else cnt -= sc.nextInt();
			if(cnt==0) System.out.println("Yes");
			else System.out.println("No");
		}
	}

}

Measured memory_bytes: 42540
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"0 75 25 100"# => r#"50"#,
r#"0 33 66 99"# => r#"0"#,
r#"10 99 20 80"# => r#"60"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a: usize, b: usize, c: usize, d: usize,
    }

    let mut alice = false;
    let mut bob = false;
    let mut ans = 0;

    for i in 0..100+1 {
        if alice && bob {
            ans += 1;
        }
        if a <= i {
            alice = true;
        }
        if b <= i {
            alice = false;
        }

        if c <= i {
            bob = true;
        }
        if d <= i {
            bob = false;
        }
    }

    ans.to_string()
}

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

int main() {
	string input;
	cin >> input;
	int N = input[input.length() - 1] - '0';
	if (N == 3) {
		cout << "bon";
	} else if (N == 0 || N == 1 || N == 6 || N == 8) {
		cout << "pon";
	} else {
		cout << "hon";
	}
	return 0;
}


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


int main(){
    string s;cin>>s;
    int n=s.length();
    string rs=s;reverse(rs.begin(),rs.end());
    string l=s.substr(0,n/2);string rl=l;reverse(rl.begin(),rl.end());
    string r=s.substr(n-n/2,n/2);string rr=r;reverse(rr.begin(),rr.end());
    if((s==rs)&&(l==rl)&&(r==rr))cout<<"Yes\n";
    else cout<<"No\n"; 
}

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

int main() {
int A, B;
	char op;
	cin >> A >> op >> B;
	if (op == '+') {
		cout<< A + B<<endl;
	}
	if (op == '-') {
		cout<< A - B<<endl;
	}
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,k=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(2*k)]
    newl=l[1::2]
    newl=itertools.chain(*newl)
    print(n-len(set(newl)))
resolve()

Measured memory_bytes: 67620
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	std::cin >> n;
	print(1 - n);
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD
 
int main(){
  int a,b,c;
  int x=0,y=0;
  while(~scanf("%d,%d,%d",&a,&b,&c)){
    if(a*a+b*b==c*c)++x;
    if(a==b)++y;
  }
  cout<<x<<endl;
  cout<<y<<endl;
  return 0;
}

Measured memory_bytes: 1204
n=int(input())
ans=0
currentpower=0
for i in range(1,n+1):
  if i>=10**(currentpower+1):
    currentpower+=1
  b=i%10
  a=(i-i%(10**currentpower))//(10**currentpower)
  if b==0:
    continue
  if a==b:
    ans+=1
    if currentpower>0:
      ans+=2
    r=max(0,((i-(a*(10**currentpower))-b)//10))
    ans+=2*r
    for j in range(0,currentpower-1):
      ans+=2*(10**j)
  elif a<b:
    for j in range(0,currentpower-1):
      ans+=2*(10**j)
  else:
    for j in range(0,currentpower):
      ans+=2*(10**j)
print(ans)


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

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	char last;
	for (int i = 0; i < n; i++) {
		if (last != s[i]) {
			ans++;
		}
		last = s[i];
	}
	cout << ans << '\n';
}

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

static class CodeJam
{
    static bool GreaterThan(string a, string b)
    {
        return (a.Length == b.Length) ? (a.CompareTo(b) > 0) : (a.Length > b.Length);
    }

    static string Solve(int N, int[] A)
    {
        int[] C = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

        var dp = new string[N + 1];
        dp[0] = "";
        for (int i = 0; i < N; ++i)
        {
            if (dp[i] != null)
            {
                foreach (int a in A)
                {
                    int key = i + C[a];
                    if (key <= N)
                    {
                        string value = a.ToString() + dp[i];
                        if (dp[key] == null || GreaterThan(value, dp[key]))
                        {
                            dp[key] = value;
                        }
                    }
                }
            }
        }
        return dp[N];
    }

    static void Main(string[] args)
    {
        int[] V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(V[0], A));
    }
}


Measured memory_bytes: 95488
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const double EPS = 1e-9;    // 許容誤差。問題によって変える
//typedef complex<double> P;  // Point
//typedef vector<P> VP; //単純多角形
//#define X real()
//#define Y imag()
//#define LE(n,m) ((n) < (m) + EPS)
//#define GE(n,m) ((n) + EPS > (m))
//#define EQ(n,m) (abs((n)-(m)) < EPS)
//namespace std{
//    bool operator < (const P a, const P b){
//        return a.X != b.X ? a.X <b.X : a.Y < b.Y;
//    }
//}
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
//外積cross(a,b) = |a||b|sinθ
//double cross(const P& a, const P& b) {
 // return imag(conj(a)*b);
//}
//内積dot(a,b) = |a||b|cosθ
//double dot(const P& a, const P& b) {
  //return real(conj(a)*b);
//}
//Line
//struct L : public vector<P> {
  //L(const P &a, const P &b) {
    //push_back(a); push_back(b);
  //}
//};
//円
//struct C{
//  P p; double r;
//  C(const P &p, double r) : p(p), r(r) { }
//};
int main(){
    long long b;cin>>b;
    while(b){
        long long k,m;
        for(long long i=sqrt(2*b);i>0;i--){
            if(2*b%i==0  and (2*b/i-i)%2==1){
                k=i; m=(2*b/i+1-i)/2;
                break;
            }
        }
        cout<<m<<" "<<k<<endl;
        cin>>b;
    }
    return 0;
}



Measured memory_bytes: 3084
n,a,b = map(int,input().split())
MOD = 10**9+7

"""繰り返し二乗法"""
def s_pow(x,n):
    ans = 1
    while n>0:
        if(bin(n&1) == bin(1)):
            ans *= x
        x *= x
        n = n>>1
    return ans

"""コンビネーション"""
def cmb(n,r):
    if n-r<r:
        r = n - r
    x,y = 1,1
    for i in range(r):
        x = x*(n-i)%MOD
        y = y*(i+1)%MOD
    return x*pow(y,MOD-2,MOD)


ans = pow(2,n,MOD)-1
ans -= cmb(n,a)
ans -= cmb(n,b)
print(ans%MOD)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int X;

int main(){
    cin>>X;

    int ans;
    if(X<600) ans=8;
    else if(X<800) ans=7;
    else if(X<1000) ans=6;
    else if(X<1200) ans=5;
    else if(X<1400) ans=4;
    else if(X<1600) ans=3;
    else if(X<1800) ans=2;
    else if(X<2000) ans=1;

    cout<<ans<<endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

long long calc(long long b, long long c, long long d){
    return b - (b/c + b/d - b / (LCM(c,d)) );
}


int main(void){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    
    long long ans = calc(b,c,d) - calc(a-1,c,d);
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int num[n]={};
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  int ans=0;
  while(1){
    bool flag=false;
    for(int i=0;i<n;i++){
      if(num[i]%2==0)
        num[i]/=2;
      else
        flag=true;
    }
    if(flag)break;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  long long int a,b,x;
  cin>>a>>b>>x;
  if(a%x==0){
    cout<<b/x-a/x+1<<endl;
  }
  else{
    cout<<b/x-a/x<<endl;
  }
}

Measured memory_bytes: 256
import itertools
n = int(input())
N = [int(i) for i in range(1, n+1)]
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
c = 0
a = 0; b = 0
for i in itertools.permutations(N):
    c += 1
    if i == P: a = c
    if i == Q: b = c
print(abs(a-b))

Measured memory_bytes: 3064