akhauriyash/Code-Regression huggingface dataset:
from collections import Counter

N,K = list(map(int,input().split()))
lis = list(map(int,input().split()))
num = len(set(lis)) 
if num <= K:
    print (0)
else:
    c = Counter(lis)
    sum = 0
    for tuple in c.most_common()[:-num+K-1:-1]:
        sum += tuple[1]
    print (sum)


Measured memory_bytes: 48440
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


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

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	string A;
	std::cin >> A;
	vll cnt(A.size());

	map<char, ll> dic;
	ll ans = 1;
	for (ll i = A.size() - 1; i >= 0; i--) {
		cnt[i] = dic[A[i]];
		dic[A[i]]++;

		ans += A.size() - i - 1 - cnt[i];
	}

	std::cout << ans << endl;


	return 0;
}


Measured memory_bytes: 2180
import java.util.Scanner;

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

     judge(a,b);

  }
  public static void judge (int a ,int b){
    // 奇数偶数判定
    if (a * b % 2 == 0 ) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}


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

int main( void ) {
  int x, y, ans=0;
  
  cin >> x >> y;
  if( x == 1 ) ans+=300000;
  if( x == 2 ) ans+=200000;
  if( x == 3 ) ans+=100000;
  if( y == 1 ) ans+=300000;
  if( y == 2 ) ans+=200000;
  if( y == 3 ) ans+=100000;
  if( x == 1 && y == 1 ) ans+=400000;

  cout << ans << endl;

  return ( 0 );
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

count_odd = Counter(v[1::2]).most_common()
count_even = Counter(v[0::2]).most_common()


if count_odd[0][0] != count_even[0][0]:
    ans = n - count_odd[0][1] - count_even[0][1]
else:
    if len(count_odd) > 1 and len(count_even) > 1:
        if count_odd[1][1] >= count_even[1][1]:
            ans = n - count_odd[1][1] - count_even[0][1]
        else:
            ans = n - count_odd[0][1] - count_even[1][1]
    elif len(count_odd) == 1 and len(count_even) == 1:
        ans = n/2
    else:
        if len(count_odd) == 1:
            ans = n - count_odd[0][1] - count_even[1][1]
        elif len(count_even) == 1:
            ans = n - count_odd[1][1] - count_even[0][1]

print(int(ans))

Measured memory_bytes: 20700
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

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

int main() {
	ll N, K;
	cin >> N >> K;

	vector<char> dislike(K, 0);
	for (ll i = 0; i < K; i++)
	{
		cin >> dislike[i];
	}

	ll ans = 0;
	for (ll i = 0; i <= 100000; i++) {
		if (i < N) {
			continue;
		}
		bool ok = true;
		string s = to_string(i);
		for (ll j = 0; j < s.size(); j++)
		{
			for (auto&& d : dislike)
			{
				if (s[j] == d) {
					ok = false;
				}
			}
		}
		if (ok) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}

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

int main() {
  int N, count;
  cin >>N;
  for(int i=1;i<=N;i += 2){
    int A = 0;
    for(int j=1;j<=i;j += 2){
      if(i % j == 0){
        A++;
      }  
    }  
    if(A == 8){
      //cout << i <<endl;
      count++;
    }  
  }  
  cout << count <<endl;
}


Measured memory_bytes: 256
#include <algorithm>
//#include <cstdio>
//#include <functional>
//#include <bits/stdc++.h>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
using namespace std;
 
int main()
{
	int n,i,temp[200000];

	cin>>n;
	vector <long long> A(n);
	for(i=0; i<n; i++) 	{
		cin>>A[i];
		temp[i]=A[i]; 
	}
	sort(A.begin(),A.end());
	
	for(i=0; i<n; i++){
		if(temp[i]<A[n/2]) cout<<A[n/2]<<endl;
		else cout<<A[n/2-1]<<endl;
	}		
		
    rt0;
}


Measured memory_bytes: 4480
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<i64>();
    let a = input::<i64>();
    let b = input::<i64>();
    let c = input::<i64>();
    let l = (0..n).map(|_| input()).collect::<Vec<i64>>();

    let ans = dfs(0, 0, 0, 0, n, a, b, c, &l, 0);
    println!("{}", ans);
}

fn dfs(
    depth: i64,
    len0: i64,
    len1: i64,
    len2: i64,
    n: i64,
    a: i64,
    b: i64,
    c: i64,
    l: &Vec<i64>,
    mp: i64,
) -> i64 {
    if depth == n {
        if len0 == 0 || len1 == 0 || len2 == 0 {
            std::i64::MAX
        } else {
            mp + i64::abs(len0 - a) + i64::abs(len1 - b) + i64::abs(len2 - c) - 30
        }
    } else {
        let mut min = std::i64::MAX;
        min = std::cmp::min(min, dfs(depth + 1, len0, len1, len2, n, a, b, c, l, mp));
        min = std::cmp::min(
            min,
            dfs(
                depth + 1,
                len0 + l[depth as usize],
                len1,
                len2,
                n,
                a,
                b,
                c,
                l,
                mp + 10,
            ),
        );
        min = std::cmp::min(
            min,
            dfs(
                depth + 1,
                len0,
                len1 + l[depth as usize],
                len2,
                n,
                a,
                b,
                c,
                l,
                mp + 10,
            ),
        );
        min = std::cmp::min(
            min,
            dfs(
                depth + 1,
                len0,
                len1,
                len2 + l[depth as usize],
                n,
                a,
                b,
                c,
                l,
                mp + 10,
            ),
        );
        min
    }
}


Measured memory_bytes: 4476
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int x, n;
	cin >> x >> n;
	if (n == 0) {
		cout << x << endl;
		return 0;
	}
	vector<bool> p(102);
	for (int i = 0; i < n; i++) {
		int p_in;
		cin >> p_in;
		p.at(p_in) = true;
	}

	int diff = 0;
	int ans = -1;
	while (true) {
		if (p.at(x - diff) == false) {
			ans = x - diff;
			break;
		}
		if (p.at(x + diff) == false) {
			ans = x + diff;
			break;
		}
		diff++;
	}

	cout << ans << endl;

}


Measured memory_bytes: 3628
// Aizu 0213: Subdivide The Land
// 2017.9.24 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NOMARK 100

typedef struct { int id, x, y, k; } T;
T tbl[16]; 
int X, Y, n;
char map[10][10];
char ans[10][10], cnt;
int pair[101][5][2], plen[101];

int cmp(T *a, T *b) { if (a->y - b->y) return a->y - b->y; return a->x - b->x; }

void mark(int c, int x, int y, int w, int h)
{
	int yy;
	for (yy = 0; yy < h; yy++) memset(map[y+yy]+x, c, w);
}

int check(int c, int x, int y, int w, int h)
{
	int xx, yy;
	for (yy = 0; yy < h; yy++) for (xx = 0; xx < w; xx++) 
		if (map[y+yy][x+xx] > 0 && map[y+yy][x+xx] != c) return 0;
	return 1;
}

int combi(int i)
{
	int x, y, x0, y0, id, x1, y1, h, w, j, k;
	char tmp[10][10];

	if (i == n+1) {
		if (++cnt > 1) return 0;
		memcpy(ans, map, sizeof(map));
		return 1;
	}
	k = tbl[i].k;
	if (k == 1) return combi(i+1);
	x0 = tbl[i].x, y0 = tbl[i].y, id = tbl[i].id;
	for (j = 0; j < plen[k]; j++) {
		w = pair[k][j][0], h = pair[k][j][1];
		if (x0 != NOMARK) {
			x1 = x0 - w + 1, y1 = y0 - h + 1;
			if (x1 < 0) x1 = 0; if (y1 < 0) y1 = 0;
			for (y = y1; y <= y0 && y + h <= Y; y++) {
				for (x = x1; x <= x0 && x + w <= X; x++) {
					if (!check(id, x, y, w, h)) continue;
					memcpy(tmp, map, sizeof(tmp));
					mark(id, x, y, w, h);
					if (!combi(i+1)) return 0;
					memcpy(map, tmp, sizeof(tmp));
				}
			}
		} else {
			for (y = 0; y + h <= Y; y++) {
				for (x = 0; x + w <= X; x++) {
					if (!check(id, x, y, w, h)) continue;
					memcpy(tmp, map, sizeof(tmp));
					mark(id, x, y, w, h);
					if (!combi(i+1)) return 0;
					memcpy(map, tmp, sizeof(tmp));
				}
			}
		}
	}
	return 1;
}

int main()
{
    int i, b, t, s, x, y, f;

	for (x = 1; x <= 10; x++) for (y = 1; y <= 10; y++) {
		t = x * y;
		pair[t][plen[t]][0] = x, pair[t][plen[t]++][1] = y;
	}

	while (scanf("%d%d%d", &X, &Y, &n) && n > 0) {
		for (s = f = i = 0; i < n; i++) {
			scanf("%d%d", &b, &t);
			tbl[b].k = t, tbl[b].id = b, tbl[b].x = tbl[b].y = NOMARK;
			s += t; if (plen[t] == 0) f = 1;
		}
		for (y = 0; y < Y; y++) for (x = 0; x < X; x++) {
			scanf("%d", &b), map[y][x] = b;
			if (b > 0) tbl[b].x = x, tbl[b].y = y;
		}
		if (f || s != X*Y) { puts("NA"); continue; }
		qsort(tbl+1, n, sizeof(T), cmp);

		cnt = 0;
		combi(1);
		if (cnt != 1) puts("NA");
		else for (y = 0; y < Y; y++) {
			printf("%d", ans[y][0]);
			for (x = 1; x < X; x++) printf(" %d", ans[y][x]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1800
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-b)<=d&&abs(b-c)<=d) cout<<"Yes"<<endl;
  else if(abs(c-a)<=d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int N;
vector<P> a;
set <int> flag;

int main() {
  cin >> N;
  ll tmp = 0;
  for(int i = 0; i < N; i++) {
    int stone;
    cin >> stone;
    a.push_back(P(stone,i+1));
    if(tmp < a[i].first) {
      tmp = a[i].first;
      flag.insert(i+1);
    }
  }
  flag.insert(0);
  a.push_back(P(0,0));
  map<ll,ll> ret;
  sort(a.begin(),a.end());
 

  for(ll i = a.size() - 1, last = a.back().first, lastflag = -1,tmp = 0; i >= 0; i--) {
    tmp += (last-a[i].first) * (a.size() - i - 1);
    if(flag.count(a[i].second)) {
      ret[lastflag] = tmp;
      tmp = 0;
      lastflag = a[i].second;
    }
    last = a[i].first;
  }
  
  for(int i = 1; i <= N; i++) {
    cout << ret[i] <<endl;
  }
}
  

  


Measured memory_bytes: 13552
#include <stdio.h>

int c[31];

int main(void)
{
	int i;
	int a;
	
	for (i = 1; i <= 28; i++){
		scanf("%d", &a);
		c[a] = 1;
	}
	
	for (i = 1; i <= 30; i++){
		if (c[i] == 0){
			printf("%d\n", i);
		}
	}
	
	return (0);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define FOR_EX(i, a, b) for (int i = a; i < b; i++)
#define FOR_IN(i, a, b) for (int i = a; i <= b; i++)

#define ALL(a) a.begin(), a.end()

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    long long x, y;
    cin >> x >> y;
    int pos = 0;
    while (x <= y) {
        x *= 2;
        pos++;
    }
    cout << pos << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b, c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  cout << min(c, a+b+1)+b << endl;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i = 0;i < 4;i++){
    cout << s[i];
  }
  cout << " ";
  for(int i = 4;i < 12;i++){
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))

s = A[0]+sum(B)
o = [s]

for i in range(N-1):
    s = s - B[i] + A[i+1]
    o.append(s)

print(max(o))

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
#include <cstdlib>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<utility>
#include<limits>

using namespace std;

#define pii pair<int,int>
#define ll long long
#define MAX 200005

int cnt[MAX];

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

	string s;
	cin >> s;

	int n = s.size();
	ll tot = n*(n - 1LL) / 2LL;
	ll rep = 0;

	for (int i = 0; i < n; i++) {
		rep += cnt[(s[i] - 'A')];
		cnt[(s[i] - 'A')]++;
	}
	cout << tot - rep + 1LL << '\n';

	return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int dp[100010][3];

int main(){
    int n;
    cin >> n;
    vector<int>a(n),b(n),c(n);
    rep(i,n)cin >> a[i] >> b[i] >> c[i];
    for(int i=1;i<=n;i++){
        dp[i][0] = max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
        dp[i][1] = max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
        dp[i][2] = max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
    }
    cout << max({dp[n][0],dp[n][1],dp[n][2]}) << endl;
    return 0;
}

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

int main(){
    long n;
    cin >> n;
    string s;
    while(n>0){
    n--;
    s += char(n%26+97);
    n = (n-n%26)/26;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;
struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n), id(n);
  rep(i,n) {
    cin >> p[i];
    id[--p[i]] = i;
  }
  UnionFind uf(n);
  int res = 0;
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    uf.unite(x, y);
  }
  rep(i,n) res += uf.same(i, id[i]);
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 4556
/**
 *  author: arpunagar
 *
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define fi first
#define se second
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define sortv(v) sort(v.begin(),v.end())
#define db(x) cout << (#x) << " is " << (x) << endl;
#define rsortv(v) sort(v.begin(),v.end(), greater<>());

ll modPower(ll num,ll r) {
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    if (r > n - r) {
        r = n - r;
    }
    for(int i=0;i<r;i++) {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

/*******************************************/
const int mod = 1e9+7;
ll modpow(ll a, ll p) {
    ll res = 1;
    while(p) {
        if(p & 1) res = (res * a) % mod;
        p >>= 1;
        a = (a * a) % mod;
    }
    return res;
}
 
void solve() {
    ll n;
    cin >> n;
    if(n == 1) {
        cout << "0\n";
        return;
    }
    ll total = modpow(10, n), no09 = modpow(8, n), no0 = modpow(9, n);
    total = (total - no0 + mod) % mod;
    total = (total - no0 + mod) % mod;
    total = (total + no09 + mod) % mod;
    cout << total << "\n";
}

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

        while (t--)
            solve();
        return 0;
}






Measured memory_bytes: 3636
N,K = list(map(int,input().split()))

Ds = []
As = []
for i in range(K):
    Ds.append(list(map(int, input())))
    As.append(list(map(int, input().split())))

sunukes = [0] * N
for A in As:
    for a in A:
        sunukes[a-1] += 1

#print("sunuke")
ans = 0
for sunuke in sunukes:
    if(sunuke == 0):
        ans += 1

print(ans)


Measured memory_bytes: 67776
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;

#define EPS 1e-10



double f(int s, int a, int c, vector<int> &l, int n){
	int r = s;
	int x[256] = {0};
	
	for(int i=0;i<n;i++){
		r = (a * r + c) % 256;
		int o = (l[i] + r) % 256;
		x[o]++;
	}
	double h = 0;
	for(int i=0;i<256;i++){
		if(x[i]) h -= (double)x[i]/n * log((double)x[i]/n);
	}
	
	return h;
}


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;
	
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>> v[i];
	}
	
	double h = 1e20;
	int s, a, c;
	for(int i=0;i<16;i++){
		for(int j=0;j<16;j++){
			for(int k=0;k<16;k++){
				double h2 = f(i, j, k, v, n);
				if(h2 + EPS < h){
					h = h2;
					s = i;
					a = j;
					c = k;
				}
			}
		}
	}
	
	cout<< s<< " "<< a<< " "<< c<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());
	return 0;
}

 

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    Rep(i, 1, n + 1)
    {
        cin >> a[i];
    }

    int cur = 1;
    rep(i, n)
    {
        cur = a[cur];
        if (cur == 2)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  int64_t result = (N / (A + B)) * A;
  if (A < (N % (A + B))) {
    result += A;
  } else {
    result += (N % (A + B));
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e,i;
	while(1){
		i=0;
		cin >> a >> b >> c >> d;
		if(a==0 && b ==0 && c==0 && d==0) break;
		while(1){
			e=a/b;
			if(e<c){
				a+=d;
				i++;
			}else{
				break;
			}
		}
		cout << i << endl;
	}
}


Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  final int VMAX = 10000;

  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      String[] line = br.readLine().split(" ");
      int min = VMAX;
      for (int i=0; i < n; i++) {
        seq[i] = Integer.parseInt(line[i]);
        if(seq[i] < min) min = seq[i];
      }
      System.out.println( minimumCostSort(seq,min) );
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private int minimumCostSort(int[] seq, int s) {
    int result=0;
    int n = seq.length;
    boolean[] v = new boolean[VMAX];
    int[] b = Arrays.copyOf(seq,n);
    int[] t = new int[VMAX+1];

    Arrays.sort(b);
    for(int i=0; i<n; i++)
      t[b[i]] = i;
    for(int i=0; i<n; i++) {
      if(v[i]) continue;

      int cur = i;
      int S   = 0;
      int m   = VMAX;
      int an  = 0;
      while(true) {
        v[cur] = true;
        an++;
        int iv = seq[cur];
        m = Math.min(m,iv);
        S += iv;
        cur = t[iv];

        if(v[cur]) break;
      }
      result += Math.min(S + (an-2) *m, m + S + (an+1) * s);
    }

    return result;
  }
}


Measured memory_bytes: 25040
def main():
    N = int(input())
    used = set()
    prev = input()
    used.add(prev)
    for i in range(1, N):
        w = input()
        if w in used or w[0] != prev[-1]:
            return "No"
        used.add(w)
        prev = w
    return "Yes"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int diff = a - b * 2;
			System.out.println((diff > 0) ? diff : 0);
		}
	}
}


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


int main() {
	int N,cnt=0;
	cin >> N;
	int n[N];
	if (N%2==0) {
		for (int i = 0; i < N; i++) {
			cin >> n[i];
		}
		sort(n, n + N);
		int B = n[N / 2-1];
		int R = n[N / 2 ];
		cout << R-B << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 640
a, b, c = map(int, input().split())

res1 = a+b+c
res2 = max(a, b, c)*3
if (res2-res1)%2==0:
  print((res2-res1)//2)
else:
  res3 = (max(a, b, c)+1)*3
  print((res3-res1)//2)

Measured memory_bytes: 9132
#include<iostream>
using namespace std;
string a,b;
long long c=0,d[1000001];
int main(){
	cin>>a;
	for(long long i=0;i<a.length();i++){
		if(a[i]=='+'){
			c+=1;
		}
		else if(a[i]=='-'){
			c-=1;
		}
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
s=list(input())
d={}
for i in range(4):
    if not s[i] in d:
        d[s[i]]=1
    else:
        d[s[i]]=d[s[i]]+1
flag=0
if len(d)==2:
    for val in d.values():
        if not val==2:
            flag=1
    if flag:
        print("No")
    else:
        print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N,X,T;
    cin>>N>>X>>T;
    cout<<((N-1)/X+1)*T<<endl;
}

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define cutiii(a,b,c) cout << a << " " << b << " " << c << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef long long LL;
typedef pair<int ,int > pii;
typedef pair<string ,int > psi;
typedef pair<string ,string > pss;
typedef pair<LL, LL> pLL;

const long long oo = 1e9 + 7;
const double PI = acos(-1.0);

double DEG_to_RAD(double d) { return d * PI / 180.0; }

int n,a,b;

int get_sum(int x) {
    int tmp = 0;
    while (x) {
        tmp += x % 10;
        x /= 10;
    }
    return tmp;
}

int main(){
  //  freopen("test.txt","r",stdin);
    cin >> n >> a >> b;
    long long ans = 0;
    for (int i =1 ; i <= n ; i++) {
        int now = get_sum(i);
        if (now >= a && now <= b) {
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int N = 0,A[100],i = 0,j = 0,k = 0,l = 0,m = 0,flag = 0,mink = 0;

  scanf("%d",&N);

  for(i = 0;i < N;i++)
    {
      scanf("%d",&A[i]);
    }
  for(j = 0;j <= N-1;j++)
    {
      mink = j;
      for(k = j;k <= N-1;k++)
	{
	  if(A[k] < A[mink])
	    {
	      mink = k;
	    }
	}
      if(A[j] != A[mink])
	{
	  flag += 1;
	}
	  l  = A[mink];
	  A[mink] = A[j];
	  A[j] = l;
    }
  for(m = 0;m < N;m++)
  {
    if(m == N-1)
      {
	  printf("%d\n",A[m]);
	}
      else if(m < N-1)
	{
      printf("%d ",A[m]);
	}
    }
  printf("%d\n",flag);
  return 0;
}



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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    ll n;
    cin>>n;

    vector<ll>l(n);
    rep(i,n)cin>>l[i];

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

    ll ans=0;

    rep2(i,0,n-3){
        rep2(j,i+1,n-2){
            rep2(k,j+1,n-1){
                if(l[i]!=l[j]&&l[j]!=l[k]&&l[i]!=l[k]){
                    if(l[i]+l[j]>l[k]){
                        ans++;
                    }
                }
            }
        }
    }

    cout<<ans<<endl;
}


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

int main(){
	string s;
	cin >> s;

	int n = s.length();
	vector<string> a;
	string temp = "R";

	for(int i=1;i<n;i++){
		if(s[i]=='R' && s[i-1]=='L'){
			a.push_back(temp);
			//temp="R";
			temp="";
		}
		temp = temp + s[i];
		if(i==n-1 && temp!="")
			a.push_back(temp);
	}

	vector<int> ans;
	for(int i=0;i<a.size();i++){
		for(int j=0;j<a[i].length();j++){
			if(a[i][j]=='R' && a[i][j+1]=='L'){
				int t1 = a[i].length()/2;
				int t2 = a[i].length()/2;

				if(a[i].length()%2!=0){
					if(j%2==0)
						t1++;
					else
						t2++;
				}
				
				ans.push_back(t1);
				ans.push_back(t2);
				j++;
			}else{
				ans.push_back(0);
			}
		}
	}

	for(int i=0;i<n;i++){
		cout << ans[i] << " ";
	}
	cout << "\n";
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
    int ans = b;
    if(a >= 6 && a <= 12) ans = b / 2;
    if(a <= 5) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N, X;
    while(cin >> N >> X) {
    LL ans = 0;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    REP(i, N) {
        if(A[i] > X) {
            LL diff = A[i] - X;
            ans += diff;
            A[i] -= diff;
        }
        if(i-1 >= 0) {
            LL diff = (A[i] + A[i-1]) - X;
            if(diff > 0) {
                assert(A[i] >= diff);
                ans += diff;
                A[i] -= diff;
            }
        }
    }
    cout << ans << endl;
    }
    return 0;
}



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

using namespace std;

int main()
{   int N,x=0;
    cin>>N;
    string S;
    cin>>S;
   for (int i=0;i<N;i++){
      if (S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'){
       x++;
       }



   }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
A,B,C = map(int,input().split(" "))
if A == 7 or B == 7 or C == 7:
    if A == 5 or B ==5 or C ==5:
        if A+B+C==17:
            print("YES")

        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")


Measured memory_bytes: 2940
n=int(input())
s=[]
for i in range(n):
    a=input().split()
    a[1]=int(a[1])
    a.append(i)
    s.append(a)
s.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(s[i][2]+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(ll N, vector<ll> A) {

  sort(A.begin(), A.end());
  ll min_ix = 0;
  while (min_ix < N - 1 && A[min_ix + 1] > 0) {
    ll mini = A[min_ix];
    FOR(i, min_ix + 1, N) {
      A[i] -= (A[i] / mini) * mini;
    }
    sort(A.begin(), A.end());
    min_ix = lower_bound(A.begin(), A.end(), 1) - A.begin();
  }
  cout << A.back() << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  solve(N, move(A));

  return 0;
}


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

typedef int Edge;
typedef vector<vector<Edge> > Graph;

struct State {
  int v, bit;
  bool operator == (const State &s) const {
    return v == s.v && bit == s.bit;
  }
  bool operator < (const State &s) const {
    if(v != s.v) return v < s.v;
    return bit < s.bit;
  }
};

int n, m;
Graph g;
vector<vector<int> > r;

void showPath(map<State, pair<pair<int,int>,State> > &prev, State s) {
  vector<pair<int,int> > v;
  vector<int> tmp;
  while(prev.count(s)) {
    v.push_back(prev[s].first);
    s = prev[s].second;
  }
  reverse(v.begin(), v.end());
  for(int i = 0; i < v.size(); ++i) {
    int j = i+1;
    if(v[i].first >= 1)
      while(j < v.size() && v[j].first >= 1) ++j;
    vector<pair<int,int> > u;
    for(int k = i; k < j; ++k) u.push_back(make_pair(v[k].second, v[k].first));
    sort(u.begin(), u.end());
    for(int k = 0; k < u.size(); ++k) {
      if(u[k].second == 0) {
        cout << "Move to room " << u[k].first+1 << "." << endl;
      } else if(u[k].second == 1) {
        cout << "Switch on room " << u[k].first+1 << "." << endl;
      } else if(u[k].second == 2) {
        cout << "Switch off room " << u[k].first+1 << "." << endl;
      }
    }
    i = j-1;
  }
}

void bfs(const State &src) {
  queue<State> que;
  map<State, int> cost;
  map<State, pair<pair<int,int>,State> > prev;
  const State dst = {n-1, 1<<(n-1)};
  bool canGoal = false;
  que.push(src);
  cost[src] = 0;

  while(que.size()) {
    const State s = que.front();
    que.pop();
    if(s == dst) {
      cout << "You can go home in " << cost[s] << " steps." << endl;
      showPath(prev, s);
      return;
    }
    if(s.v == n-1) canGoal = true;

    for(int i = 0; i < g[s.v].size(); ++i) {
      int nv = g[s.v][i];
      if(s.bit & (1<<nv)) {
        const State t = {nv, s.bit};
        if(!cost.count(t)) {
          que.push(t);
          cost[t] = cost[s] + 1;
          prev[t] = make_pair(make_pair(0, nv), s);
        }
      }
    }

    for(int i = 0; i < r[s.v].size(); ++i) {
      if(r[s.v][i] == s.v) continue;
      int nbit = s.bit ^ (1<<r[s.v][i]);
      const State t = {s.v, nbit};
      if(!cost.count(t)) {
        que.push(t);
        cost[t] = cost[s] + 1;
        if(s.bit < nbit) { // ON
          prev[t] = make_pair(make_pair(1, r[s.v][i]), s);
        } else { // OFF
          prev[t] = make_pair(make_pair(2, r[s.v][i]), s);
        }
      }
    }
  }

  if(canGoal) {
    cout << "You can not switch off all lights." << endl;
  } else {
    cout << "Help me!" << endl;
  }
}

int main() {
  while(cin >> n >> m && (n|m)) {
    g = Graph(n);
    for(int i = 0; i < m; ++i) {
      int s, t;
      cin >> s >> t;
      --s; --t;
      g[s].push_back(t);
      g[t].push_back(s);
    }
    State s = {0, 0};
    for(int i = 0; i < n; ++i) {
      int a;
      cin >> a;
      s.bit |= a<<i;
    }
    r = vector<vector<int> >(n);
    for(int i = 0; i < n; ++i) {
      int k;
      cin >> k;
      r[i].resize(k);
      for(int j = 0; j < k; ++j) {
        cin >> r[i][j];
        --r[i][j];
      }
    }
    bfs(s);
  }
  return 0;
}

Measured memory_bytes: 6280
import java.util.Scanner;

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

		String s = sc.next();
		String t = sc.next();
		
		int out = Integer.MAX_VALUE;
		
		for(int i = 0; i<s.length() - t.length()+1; i++) {
			int diff = 0;
			for(int j = 0; j<t.length(); j++) {
				if(s.charAt(j+i) != t.charAt(j)) diff++;
			}
			out = Math.min(out,  diff);
		}
		System.out.println(out);
		
	}
}


Measured memory_bytes: 35592
#include <algorithm>
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int a[n][2], count[n];
  for (int i = 0; i < n; i++) {
    std::cin >> a[i][0];
  }
  for (int i = 0; i < n; i++) {
    std::cin >> a[i][1];
  }
  for (int i = 0; i < n; i++) {
    count[i] = 0;
    for (int j = 0; j < n; j++) {
      if (i == j)
        count[i] += (a[j][0] + a[j][1]);
      else if (j < i)
        count[i] += a[j][0];
      else
        count[i] += a[j][1];
    }
  }
  std::sort(count, count + n);
  std::cout << count[n - 1] << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> vec(10000);
  
  for(int i = 0; i < 10000; i++){
    cin >> vec.at(i);
    if(vec.at(i) == 0){
      break;
    }
    cout << "Case " << i + 1 << ": " << vec.at(i) << endl;
  }
  
}



Measured memory_bytes: 3132
#include<cstdio>
using namespace std;
int n;
int A,B;
long long ans=0;
long long x[100100000];
long long y[100100000];
int main()
{
	scanf("%d %d %d",&n,&A,&B);
	x[0]=0;
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	for(int i=1;i<=n-1;i++)
	    y[i]=x[i+1]-x[i];
	for(int i=1;i<=n-1;i++)
	{
		if(y[i]*A<=B) ans+=y[i]*A;
		else ans+=B;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 4992
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b;

signed main(){
    io();

    in(a,b);
    if(a&1&&b&1){
        yes;
    }else{
        no;
    }

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

bool Graph[10][10];

int main() {
  int N,M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    Graph[a][b] = true;
    Graph[b][a] = true;
  }
  int x[N];
  for (int i = 0; i < N; i++) {
    x[i] = i;
  }
  int ans = 0;
  do {
    bool can = true;
    if (x[0] != 0) {
      can = false;
    }
    for (int i = 1; i < N; i++) {
      if (Graph[x[i-1]][x[i]] == false) {
        can = false;
      }
    }
    if (can) ans++;
} while(next_permutation(x,x+N));
cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int N;
vector<vector<int>> g;

void input(void){
    cin >> N;
    g.resize(N);
    for (int i = 0; i < N - 1; ++i){
        int u, v; cin >> u >> v;
        --u, --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
}

vector<int> parent;

void dfs(int s = 0, int p = -1){
    parent[s] = p;
    for (auto c : g[s])
        if (c != p)
            dfs(c, s);
}

void setup(void){
    input();
    parent.resize(N);
    dfs();
}

int main(void){
    setup();
    ll res = N;
    for (int i = 1; i < N; ++i){
        int p = parent[i];
        // 自分が含まれ、親なしなペア
        if (p > i){
            ll r = p - i;
            ll l = i + 1;
            res += r * l; 
        }
        else{
            ll l = i - p;
            ll r = N - i;
            res += l * r;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 24188
#include<iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include<queue>
using namespace std;
using pint = pair<int,int>;

int dx[4]={0,-1,0,1};
int dy[4]={-1,0,1,0};
int H, W;
string fi[110];
int dist[110][110]; 

int main() {
    cin >> H >> W;
    int nyann = 0;
    for (int i = 0; i < H; ++i) {
        cin >> fi[i];
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '.') ++nyann;
        }
    }

    memset(dist, -1, sizeof(dist));
    dist[0][0] = 1;
    queue<pint> que;
    que.push(pint(0, 0));
    while (!que.empty()) {
        pint c = que.front();
        que.pop();
        int x = c.first;
        int y = c.second;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (fi[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    if (dist[H-1][W-1] == -1) cout << -1 << endl;
    else  cout << nyann - dist[H-1][W-1] << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

K, Q = map(int, input().split())
D = list(map(int, input().split()))
NXM = [list(map(int, input().split())) for _ in range(Q)]

for N, X, M in NXM:
    E = [d % M for d in D]
    cnt, tmp = 0, 0
    for e in E:
        if e > 0:
            cnt += 1
            tmp += e
    cnt *= ((N - 1) // K)
    tmp *= ((N - 1) // K)
    for i in range((N - 1) % K):
        if E[i] > 0:
            cnt += 1
            tmp += E[i]
    tmp += X % M
    print(cnt - tmp // M)

Measured memory_bytes: 69340
#include"bits/stdc++.h"
using namespace std;

int main()
{
    int n,c=0;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j!=n)
            {
                c==0;
            }
            else c++;
        }
    }
    if (c>0)
    {
        cout<<"Yes";
    }
    else cout<<"No";
}


Measured memory_bytes: 256
import sys

n, m = map(int, sys.stdin.readline().split())
ab = map(int, sys.stdin.read().split())
ab = zip(*[ab] * 2)
graph = [[] for _ in range(n)]
for a, b in ab:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

def main():
    ramain = 2 ** n - 1
    cnt = 0
    stack = [(0, 0)]
    while stack:
        v, visited = stack.pop()
        visited ^= 2 ** v
        if not visited ^ ramain: 
            cnt += 1
            continue
        for u in graph[v]:
            if visited >> u & 1:
                continue
            stack.append((u, visited))

    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	Int ans = 1000;
	for (int i = 0; i + 1 < N; ++i) {
		if (a[i] >= a[i + 1]) { continue; }
		ans = ans / a[i] * a[i + 1] + ans % a[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3560
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
using namespace std;
typedef long long ll;
#define my_abs(n) (n > 0 ? (n) : -(n))
#define rep(i,a,b) for(int i=a;i<b;i++)
ll N, M;
int main() {
	scanf("%lld %lld", &N, &M);
	printf("%lld", my_abs((N - 2) * (M - 2)));
	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')

cnt = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        k = 2*j - i
        if not k in range(N):
            continue
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt += 1

print(r*g*b-cnt)

Measured memory_bytes: 67948
#include <iostream>
using namespace std;
int main(void){
	int s;//second
	int m;
//	int imm;
//	imm == s/60;
//	h=;//hour
	cin >> s;
	m=s/60;
    cout << s/3600 << ":" << m%60 << ":" << s%60 << endl;
return 0;
}

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector <vector <int> > a(n, vector<int>(m));
    for (int i=0; i<n; i++){
        for  (int j=0; j<m; j++){
            cin >> a.at(i).at(j);
        }
    }
    vector <int> b(m);
    for(int i=0; i<m; i++){
        cin >> b.at(i);
    }

    vector <int> c(n);
    for (int i=0; i<n; i++){
        for  (int j=0; j<m; j++){
        c.at(i) += b.at(j)* a.at(i).at(j);
        }
    }

    for(int i=0; i<n; i++){
        cout << c.at(i) << endl;
    }

    return 0;
}



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

int main() {
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	long long int low=a+(a%c!=0)*c-(a%c),up=b-(b%c);
	
	long long int cs=(up-low)/c+1;
	low=a+d-(a%d),up=b-(b%d);
	long long int ds=(up-low)/d+1;
	
	long long int gc=__gcd(c,d);
	long long int merge=(c*d)/gc;
	low=a+merge-(a%merge),up=b-(b%merge);
	long long int merges=(up-low)/merge+1;
	
	cout<<b-a+1-cs-ds+merges<</*' '<<cs<<' '<<ds<<' '<<merges<<*/'\n';
}

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

int main() {

	long long n, x;
	cin >> n >> x;
	
	priority_queue<long long> v;
	for (int i=0; i<n; i++) {
		long long k;
		cin >> k;
		v.push(k);
	}
	
	for (int i=0; i<x; i++) {
		long long t = v.top();
		v.pop();
		v.push(t/2);
	}
	
	long long sm = 0;
	
	while (v.size() > 0) {
		sm += v.top();
		v.pop();
	}
	
	cout << sm << endl;
   
}


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

int main(){
    string s;
    while(true){
        cin >> s;
        if(s == "0")
            break;
        
        int sum = 0;
//        for(int i=0; i<s.length(); i++)
//            sum += (s[i]-'0');
        
        for(auto &c: s)
            sum += c-'0';
        
        cout << sum << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3176