akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

vector<int> v(10);
vector<int> b(10);
int main() {
	rep(i,5)cin>>v[i];

	rep(i,5){
		b[i] = v[i]%10;
	}

	int cnt = 0;
	rep(i,5){
		if(b[i]==0)cnt++;
	}
	int ans = 0;
	if(cnt == 5){
		rep(i,5)ans+=v[i];
		cout<<ans<<endl;
		return 0;
	}
	int ind = 0;
	int minb = INF;
	rep(i,5){
		if(b[i]>0&&minb>b[i]){
			ind = i;
			minb = min(b[i],minb);
		}
	}
	rep(i,5){
		if(b[i]==0||i == ind)ans+=v[i];
		else{
			ans+= v[i]-b[i]+10;
		}
	}
	cout<<ans<<endl;
}

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

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int xdif, ydif;
  xdif=tx-sx;
  ydif=ty-sy;
  for(int i=0; i<xdif; i++){
    cout << "R";
  }
  for(int i=0; i<ydif; i++){
    cout << "U";
  }
  for(int i=0; i<xdif; i++){
    cout << "L";
  }
  for(int i=0; i<ydif; i++){
    cout << "D";
  }
  cout << "D";
  for(int i=0; i<=xdif; i++){
    cout << "R";
  }
  for(int i=0; i<=ydif; i++){
    cout << "U";
  }
  cout << "L";
  cout << "U";
  for(int i=0; i<=xdif; i++){
    cout << "L";
  }
  for(int i=0; i<=ydif; i++){
    cout << "D";
  }
  cout << "R" << endl;
}
    

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

int main() {
  string s,t;
  int ans = 0;
  cin >> s >> t;
  rep(i,0,s.size()){
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
//#define mp map<int,int>
//#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n,d;
   cin>>n>>d;
   int ans=ceil(n/(double)(2*d+1));
   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    A = [input() for _ in range(N)]
    B = [input() for _ in range(M)]

    for sy in range(N):
        for sx in range(N):

            ok = True
            for y in range(M):
                for x in range(M):
                    if sy + y < N and sx + x < N:
                        ok &= A[sy + y][sx + x] == B[y][x]
                    else:
                        ok = False

            if ok:
                print("Yes")
                return
    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int H, W;
int a[501][501];
struct edge {int fromh, fromw, toh, tow; };
vector<edge> Ans;
int S[501][501];
queue<int> que;

// 右か下に動かす。
void calc(int h, int w) {
  if (w<W-1) {
    edge e = {h, w, h, w+1};
    a[h][w+1]++;
    a[h][w]--;
    Ans.push_back(e);
  } else if (h<H-1){
    edge e = {h, w, h+1, w};
    a[h+1][w]++;
    a[h][w]--;
    Ans.push_back(e);
  }
} 

int main() {
  INCANT;
  cin >> H >> W;
  rep(i, H) rep(j, W) cin >> a[i][j];

  rep(i, H) {
    rep(j, W) {
      if (a[i][j]%2==0) continue; 
      calc(i, j);
    }
  }
  cout << Ans.size() << endl;
  rep(i, Ans.size()) {
    edge e = Ans[i];
    cout << e.fromh+1 << ' ';
    cout << e.fromw+1 << ' ';
    cout << e.toh+1 << ' ';
    cout << e.tow+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <string>
#include <algorithm>

int main(){
   std::string s, t;
   std::cin >> s >> t;
   std::sort(s.begin(), s.end());
   std::sort(t.begin(), t.end());
   std::reverse(t.begin(), t.end());
   if (s < t){
      std::cout << "Yes" << std::endl;
   } else{
      std::cout << "No" << std::endl;
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[400010],lbound,rbound,mid,ans;
bool zz(int x){
  	return !(x<=mid);
}
bool check(){
	for (int i=1;i<=n-1;i++){
		if (zz(a[n+i-1])==zz(a[n+i])) return zz(a[n+i]);
		if (zz(a[n-i+1])==zz(a[n-i])) return zz(a[n-i+1]);
	}
	return zz(a[1]);
}
int main(){
	cin>>n;
	for (int i=1;i<=2*n-1;i++) cin>>a[i];
	lbound=1;rbound=2*n-1;
	while (lbound<=rbound){
		mid=(lbound+rbound)/2;
		if (!check()){
			rbound=mid-1;
			ans=mid;
		}
		else
			lbound=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int N;
    int A[100002];
    int sum = 0;
    A[0] = 0;
    cin >> N;
    rep(i, N) {
        cin >> A[i+1];
        sum += abs(A[i+1] - A[i]);
    }
    sum += abs(A[N]);
    A[N+1] = 0;
    rep(i, N) {
        cout << sum + abs(A[i+2] - A[i]) - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) << endl;
    }
    return 0;
}


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

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

int solve(int i,int j,string s,string t)
{
    if(i==s.length()) return 0;
    if(j==t.length()) return 0;

    if(s[i]==t[j]) return 1 + solve(i+1,j+1,s,t);

    return max(solve(i+1,j,s,t),solve(i,j+1,s,t));
}

int main()
{
    FASTIO;

    string s,t;
    cin>>s>>t;

    // Recursive - will return max_length subsequence
    // cout<<solve(0,0,s,t);

    int n = s.length();
    int m = t.length();

    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i = n-1;i>=0;i--)
    {
        for(int j = m-1;j>=0;j--)
        {
            if(s[i]==t[j])
            {
                dp[i][j] = 1 + dp[i+1][j+1];
            }
            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }

    // for(auto vec : dp)
    // {
    //     for(auto ele : vec) cout<<ele<<" ";
    //     cout<<endl;
    // }

    int max_len = dp[0][0];

    string ans = "";
    int i = 0, j = 0;

    while(max_len)
    {
        if(dp[i][j] == 1 + dp[i+1][j+1] && dp[i][j] == max(dp[i+1][j],dp[i][j+1]) + 1)
        {
            ans += s[i];
            max_len--;
            i++;
            j++;
        }
        else{

            if(dp[i+1][j] >= dp[i][j+1])
            {
                i++;
            }
            else j++;

        }
    }

    cout<<ans;
    

}

Measured memory_bytes: 35584
import Foundation

func isFull(_ s: String) -> Bool {
  var c: Int = 0
  for si in s {
    switch si {
    case "(": c += 1
    case ")" where c < 1 : return false
    case ")": c -= 1
    default:  break
    }
  }
  return c == 0
}

extension String {
  func suffix(_ cond: (Character) -> Bool) -> String {
    let a = Array(self)
    var c = ""
    for i in 0..<a.count {
      if cond(a[a.count - i - 1]) {
        c.append(a[a.count - i - 1])
      } else {
        return c
      }
    }
    return c
  }
}

let nl = readLine()!.split(separator: " ").map { Int($0)! }
let n = nl[0]
var l = [(String, Int, Int)]()
var r = [(String, Int, Int)]()
for _ in (0..<n) {
  let si = readLine()!
  let ai = si.prefix { $0 == ")" }.count - si.prefix { $0 == "(" }.count
  let bi = si.suffix { $0 == "(" }.count - si.suffix { $0 == ")" }.count
  if bi - ai >= 0 {
    l.append((si, ai, bi))
  } else {
    r.append((si, ai, bi))
  }
}

l.sort { $0.1 < $1.1 }
r.sort { $0.2 > $1.2 }
print("\(isFull(l.map{$0.0}.joined() + r.map{$0.0}.joined()) ? "Yes": "No")")

Measured memory_bytes: 54528
# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
s_kari = []
for i in range(n):
    s_kari.append(int(stdin.readline().rstrip()))
s = sorted(s_kari)

if sum(s) % 10 != 0:
    print(sum(s))
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(sum(s)-s[i])
            exit()
    print("0")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

vector<vector<int> > a;


int main(){
	fastread;
	int n,m,k;
	cin>>n>>m>>k;
	a = vector<vector<int> > (n, vector<int>(m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char c;
			cin>>c;
			a[i][j] = c-'0';
		}
	}

	for(int i=0;i<n;i++){
		for(int j=1;j<m;j++){
			a[i][j] += a[i][j-1];
		}
	}

	int ans = INT_MAX;
	for(int mask =0;mask<(1<<(n-1));mask++){
		vector<int> lin;
		int cnt = 0;
		for(int j=0;j<n-1;j++){
			if((mask&(1<<j))){
				lin.pb(j+1);
				cnt += 1;
			}
		}
		lin.pb(n);
		int prev = -1;


		for(int j=0;j<m;j++){
			int p = 0;
			int su = 0;
			bool fg = 0;
			for(int i=0;i<n;i++){
				if(i==lin[p]){
					p++;
					su = 0;
				}
				su += a[i][j];
				if(prev != -1){
					su -= a[i][prev];
				}
				if(su > k){
					if(j==0){
						fg = 1;
						break;
					}
					cnt += 1;
					prev = j-1;
					break;
				}
			}
			if(fg){
				cnt = INT_MAX;
				break;
			}
		}
		// cout<<mask<<" "<<cnt<<endl;
		ans = min(ans,cnt);

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


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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

lli dp[300][300];

int main()
{
    int n;

    cin >> n;
    lli sum, r=0, g=0, b=0;
    string s;
    cin >> s;
    for(auto c: s){
        if(c == 'R') r++;
        else if(c == 'G') g++;
        else b++;
    }
    sum = r*g*b;
    lli ex = 0;
    for(int i=0; i<n; i++){
        int l=i-1, r=i+1;
        while(l>=0 && r<n){
            if(s[l] != s[i] && s[l] != s[r] && s[i]!=s[r]) ex++;
            l--, r++;
        }
    }
    sum -= ex;

    cout << sum << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    int ans = n*2;
    for(int i=0;i<n;i++){
        string a,b;
        int x=0;
        for(int k=0+i;k<n;k++){
            a+=s[k];
            b+=t[x];
            x++;
        }
        if(a==b){
            ans-=a.size();
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  char s[100];
  string a;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>s[i];
  }
  a="Three";
  for(i=0;i<n;i++)
  {
    if(s[i]=='Y')a="Four";
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100001;
int n,m,ans,f[N];
struct node{
	int a,b;
}w[N];
bool cmp(node w,node l){
	return w.b>l.b;
}
int gf(int w){return f[w]==w?w:f[w]=gf(f[w]);}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&w[i].a,&w[i].b);
	for(int i=1;i<=m;i++)f[i]=i;
	sort(w+1,w+n+1,cmp);
	for(int i=1;i<=n;i++){
		if(w[i].a>m)continue;
		int fa=gf(m-w[i].a+1);
		if(fa==0)continue;
		f[fa]=fa-1;
		ans+=w[i].b;
	}printf("%d",ans);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long LL;
const int maxn = 1000010;
const int inf = 1 << 30;

inline LL read() {
	register LL x = 0, neg = 1;
	register char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') neg = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { x = (((x << 2) + x) << 1) + (ch ^ '0'); ch = getchar(); }
	return x * neg;
}

int n, m, flag = 0;
char s[maxn], t[maxn];

inline LL gcd(LL a, LL b) { return b == 0 ? a : gcd(b, a % b); }
inline LL lcm(LL a, LL b) { return a * b / gcd(a, b); }

int main() {
	n = read(), m = read();
	std::cin >> s >> t;
	int len = gcd(n, m);
	for(register int i = 0; i < len; ++i) {
		if(s[n / len * i] != t[m / len * i]) {
			flag = 1;
			break;
		}
	}
	if(flag) printf("-1\n");
	else printf("%lld", lcm(n, m));
	return 0;
}

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

int cnt[10][10];

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

    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        cnt[s[0] - '0'][s[s.size() - 1] - '0']++;
    }

    ll ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += cnt[i][j] * cnt[j][i];
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N;
    double sum=0;
    cin>>N;
    double* A =new double[N]();

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

    for(int i=0;i<N;i++){
        sum=sum+(1/A[i]);
    }

    cout<<1/sum<<endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    string s;
    cin>>s;
    ll ans=0,cnt=0;
    
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i]=='B') cnt++;
        else ans+=cnt;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), x.end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e4 + 5;
const double eps = 1e-9;
ll a[N];
vector<ll> mat;
string s;

void solve() {
  int n; cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  cin >> s;
  mat.clear();
  for (int i = n-1; ~i; i--) {
    if (s[i] == '0') {
      trav(x, mat) a[i] = min(a[i], a[i]^x);
      if (!a[i]) continue;
      int j = 0;
      while (j < sz(mat) && mat[j] > a[i])
        j++;
      mat.insert(mat.begin() + j, a[i]);
    } else {
      trav(x, mat) a[i] = min(a[i], a[i]^x);
      if (!a[i]) continue;
      cout << "1\n";
      return;
    }
  }
  cout << "0\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t; cin >> t;
  while (t--)
    solve();
  return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

template <class T>
vector<T> divisor(T n) {
    vector<T> res;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    int cnt_divided = 0;
    vector<int> a(n);
    cin >> a;
    vector<int> cnt(1000010);
    rep(i, n) {
        cnt[a[i]]++;
    }

    rep(i, n) {
        for (int d: divisor(a[i])) {
            if (d == a[i]) {
                if (2 <= cnt[d]) {
                    cnt_divided++;
                    break;
                }
            }
            else if (1 <= cnt[d]) {
                cnt_divided++;
                break;
            }
        }
    }
    cout << n - cnt_divided << endl;
}

Measured memory_bytes: 8008
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}


fn main(){
    let n: usize = read_as_vec()[0];
    let mut t = read_as_vec::<usize>();
    let mut v = read_as_vec::<f64>();
    t.insert(0, 0);
    v.insert(0, 0.0);
    let mut speed_max: Vec<f64> = vec![0.0;(t.iter().sum::<usize>()+1)*2];

    let mut acc = 0;
    //for (&section, &limit) in t.iter().zip(v.iter()){
    for i in 1..t.len(){
        let section = t[i];
        let limit = v[i];
        for j in 0..section*2{
            speed_max[j+acc] = limit;
        }
        if v[i-1] > speed_max[acc]{
            speed_max[acc] = speed_max[acc];
        }else{
            speed_max[acc] = v[i-1];
        }
        acc += section*2;
    }
    speed_max[0] = 0.0;
    *speed_max.last_mut().unwrap() = 0.0;

    for i in (0..speed_max.len()-1).rev(){
        //speed_max[i] = cmp::min(speed_max[i], speed_max[i+1]+1);
        speed_max[i] =
            if speed_max[i] > speed_max[i+1]+0.5{
                 speed_max[i+1]+0.5
            }else{
                 speed_max[i]
            }
    }

    for i in 1..speed_max.len(){
        speed_max[i] =
            if speed_max[i] > speed_max[i-1]+0.5{
                speed_max[i-1]+0.5
            }else{
                speed_max[i]
            }
    }

    let mut ans: f64 = 0.0;
    for i in 0..speed_max.len()-1{
        ans += (speed_max[i] as f64 + speed_max[i+1] as f64)/4.0;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
using namespace std;
//
// Created by karayuu on 2018-12-23.
//

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

    int d = a / b;
    int r = a % b;
    double f = (double)a / (double)b;

    printf("%d %d %.5lf\n", d, r, f);
}


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

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	vector<int> l(n), r(n);
	rep(i, n - 1) l[i + 1] = gcd(l[i], a[i]);
	for (int i = n - 1; i >= 1; --i) r[i - 1] = gcd(r[i], a[i]);
	int ans = 1;
	rep(i, n) ans = max(ans, gcd(l[i], r[i]));
	cout << ans << endl;
	return 0;
}


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
typedef map<int,int> MII;
typedef queue<int> QI;
typedef queue<PII> QPII;
typedef stack<int> SI;
typedef stack<PII> SPII;
typedef deque<int> DI;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define PF push_front
#define POB pop_back()
#define POF pop_front()
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REPR(i,n) RFOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;
const LL MODD = 998244353;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

VI dx = {1,0,-1,0,1,1,-1,-1};
VI dy = {0,1,0,-1,1,-1,1,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(N == 0) {
    return 0;
  }
  
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S;
  cin >> S;
  int N = SZ(S);
  int M = N/2;
  string T,U;
  T = S.substr(0,M), U = S.substr(M+1,M);
  
  REP(i,N/2){
    if(S.at(i) != S.at(N-1-i)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  REP(i,M/2){
    if(T.at(i) != T.at(M-i-1)){
      cout << "No" << endl;
      return 0;
    }
    if(U.at(i) != U.at(M-i-1)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string s;
    int a=0;
    int b=0;
    cin >> s;
    for(int i=0;i<3;i++)
    {
      if (s[i] == 'A') ++a;
      else ++b;
    }

    if (a==3||b==3)cout << "No" << endl;
    else cout << "Yes" << endl;
      return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

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

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

//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N;

int a[200010];
ll sum[200010];
signed main(void) {
    cin >> N;
    REP(i, N) cin >> a[i];
    FOR(i, 0, N) sum[i+1] = sum[i]+a[i];
    
    ll ans=10000000000;
    for(int i=1; i<N; ++i){
        ans = min(ans, abs(sum[N]-sum[i]-sum[i]));
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7680
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<unordered_set>
#include<unordered_map>
#define int long long
#define P pair<int,int>
using namespace std;

P a[4];//1Lあたりの値段　量
signed main() {
	int b, c, d, e; cin >> b >> c >> d >> e;
	int S; cin >> S;
	S *= 4;
	a[0] = { b * 8,1};
	a[1] = { c * 4,2 };
	a[2] = { d * 2,4 };
	a[3] = { e * 1,8 };
	sort(a, a + 4);
	long long ans = 0;
	for (int i = 0; i < 4; i++) {
		long long f = S / a[i].second;
		ans += f*a[i].first*a[i].second/8;
		S -= f*a[i].second;
	}
	cout << ans << endl;
	getchar();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>


using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int n = 0;
	int ha, hb, hc;
	ha = a;
	hb = b;
	hc = c;
	if (a % 2 == 0
		&& b % 2 == 0
		&& c % 2 == 0) {
	}
	else {
		cout << 0 << endl;
		return 0;
	}

	while (true) {
		if (ha % 2 == 1 || hb % 2 == 1 || hc % 2 == 1) {
			cout << n << endl;
			return 0;
		}

		if (ha == hb && hb == hc && ha == hc) {
			cout << -1 << endl;
			return 0;
		}

		int tempa, tempb, tempc;
		tempa = ha;
		tempb = hb;
		tempc = hc;
		ha = (tempb + tempc) / 2;
		hb = (tempa + tempc) / 2;
		hc = (tempa + tempb) / 2;
		n += 1;



	}
	return 0;
}



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

int main(void){
    ll x;
    cin >> x;
    for(int a=1000;a>=-1000;a--){
        for(int b=1000;b>=-1000;b--){
            ll a5 = a;
            ll b5 = b;
            for(int i=0;i<4;i++){a5*=a; b5*=b;}
            if(a5-b5==x){cout << a << " " << b << endl; return 0;}
        }
        
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    REP(i, N) {
        ll x;
        cin >> x;
        if (x > K-x) ans += (K-x)*2;
        else ans += x*2;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main ()
{

    int d;
    int t;
    int s;
    cin >> d >> t >> s;
   	int ds = s*t;
    if (ds>=d)
    {
        cout<<"Yes"<<endl;
    }
    else 
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 2345;
int a[MAXN], dp[MAXN][2];
bool visit[MAXN][2];

int dfs(int cur, int N, int idx) {
    if (visit[cur][idx]) return dp[cur][idx];
    visit[cur][idx] = 1;
    int ans = abs(a[N] - a[cur - 1]);
    for (int i = cur; i < N; i++) {
        if (idx == 0) {
           ans = max(ans, dfs(i + 1, N, idx ^ 1));
        } else {
           ans = min(ans, dfs(i + 1, N, idx ^ 1));
        }
    }
    // printf("cur = %d idx = %d dp = %d\n", cur, idx, ans);
    return dp[cur][idx] = ans;
}

int main() {
    int N, Z, W;
    while (~scanf("%d %d %d", &N, &Z, &W)) {
          for (int i = 1; i <= N; i++)
              scanf("%d", &a[i]);
          a[0] = W;
          memset(visit, 0, sizeof(visit));
          printf("%d\n", dfs(1, N, 0));
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    string s;
    cin>>s;
    int r=0,w=0;
    for (int i=0;i<n;i++)
    {
        if (s.at(i)=='R')
        r++;
        else
        w++;
    }
    int wrong=0;
    for (int i=0;i<n;i++)
    {
        if (i<r)
        {
            if (s.at(i)=='W')
            wrong++;
        }
    }
    printf("%d\n",wrong);
    return 0;
}

Measured memory_bytes: 3912
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
dp = [0, 0, 0]

for i in range(n):
    dp = [A[i][0] + max(dp[1], dp[2]), A[i][1] + max(dp[0], dp[2]), A[i][2] + max(dp[0], dp[1])]
    
print(max(dp))    

Measured memory_bytes: 24308
import java.util.*;

public class Main {
	String str;
	int pos;
	int [] data;
	
	private TreeMap<Integer, Integer> fact() {
		char c = str.charAt(pos++);
		TreeMap<Integer, Integer> res = new TreeMap<Integer, Integer>();
		if(Character.isDigit(c)){
			//res.add(c - '0');
			int ind = (c - '0') - 1;
			int num = data[ind];
			//System.out.println("ind= "+(ind + 1));
			res.put(num, 1);
			return res;
		}
		else if(c == '('){
			//System.out.println("pos= " + pos);
			TreeMap<Integer, Integer> right = fact();
			pos++;
			TreeMap<Integer, Integer> left = fact();
			pos++;
			//System.out.println("test1 = " +right.toString() + " " + left.toString());
			//calc
			for(int r: right.keySet()){
				for(int l: left.keySet()){
					for(int i=0; i < 3; i++){
						int res2 = -1;
						switch(i){
						case 0:
							res2 = r & l;
							break;
						case 1:
							res2 = r | l;
							break;
						case 2:
							res2 = r ^ l;
							break;
						}
						if(res2 != -1){
							int sum = right.get(r) * left.get(l);
							if(res.containsKey(res2)){
								int count = res.get(res2) + sum;
								res.put(res2, count);
							}
							else{
								res.put(res2, sum);
							}
						}
					}
				}
			}
			//System.out.println("res= " + res.toString() + " r= " + right.toString() + " l= " + left.toString());
			return res;
		}
		return null;
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			str = sc.nextLine();
			if(str.equals("END")) break;
			str += "#";
			pos = 0;
			int n = sc.nextInt();
			data = new int[n];
			for(int i=0; i < n; i++){
				int num = 0;
				for(int j = 0; j < 4; j++){
					int temp = sc.nextInt();
					num = num * 2 + temp;
				}
				data[i] = num;
			}
			sc.nextLine();
			TreeMap<Integer, Integer> res = new TreeMap<Integer, Integer>();
			res = fact();
			int lastind = res.lastKey();
			//System.out.println(res.toString());
			if(lastind == 15){
				System.out.println(res.get(lastind));
			}
			else{
				System.out.println(0);
			}
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

class Dice{
	public int Top;
	public int Front;
	public int Right;
	public int left;
	public int Back;
	public int Bottom;

	public Dice() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	public void W() {
		int Topch = Top;
		int leftch = left;
		Top = Right;
		Right = Bottom;
		left = Topch;
		Bottom = leftch;
	}
	public void E() {
		int Topch = Top;
		int Rightch = Right;
		Top = left;
		Right = Topch;
		left = Bottom;
		Bottom = Rightch;
	}

	public void S() {
		int Topch  =Top;
		int Frontch = Front;
		Top = Back;
		Front = Topch;
		Back = Bottom;
		Bottom = Frontch;
	}

	public void N() {
		int Topch = Top;
		int Backch = Back;
		Top = Front;
		Front = Bottom;
		Back = Topch;
		Bottom = Backch;
	}

	public void test(Dice b) {
		if(this.Top==b.Top&&this.Front==b.Front&&this.Right==b.Right&&this.left==b.left&&this.Back==b.Back&&this.Bottom==b.Bottom) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}


}

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice a = new Dice();
		Dice b = new Dice();
		a.Top = sc.nextInt();
		a.Front = sc.nextInt();
		a.Right = sc.nextInt();
		a.left = sc.nextInt();
		a.Back = sc.nextInt();
		a.Bottom = sc.nextInt();


		b.Top = sc.nextInt();
		b.Front = sc.nextInt();
		b.Right = sc.nextInt();
		b.left = sc.nextInt();
		b.Back = sc.nextInt();
		b.Bottom = sc.nextInt();
		int n=1;
		String str = "";
		int test1,test2;
		for(int i=0;i<n;i++){
			test1 = b.Top;
			test2 = b.Front;

			if(test1 == a.Front){
				str = str +"N";
			}else if(test1 == a.Right){
				str = str + "W";
			}else if(test1 == a.left){
				str = str + "E";
			}else if(test1 == a.Back){
				str = str + "S";
			}else if(test1 == a.Bottom){
				str = str + "NN";
			}

			char data[] = new char[str.length()];
			data = str.toCharArray();
			for(int j=0;j<str.length();j++) {
				switch(data[j]) {
				case 'W':
					a.W();
					break;
				case'S':
					a.S();
					break;
				case'N':
					a.N();
					break;
				case'E':
					a.E();
					break;
				default:
					break;
				}
			}
			str = "";
			if(test2 == a.Right){
				str = str + "WSE";
			}else if(test2 == a.left){
				str = str + "ESW";
			}else if(test2 == a.Back){
				str = str + "SSEE";
			}
			data = str.toCharArray();
			for(int j=0;j<str.length();j++) {
				switch(data[j]) {
				case 'W':
					a.W();
					break;
				case'S':
					a.S();
					break;
				case'N':
					a.N();
					break;
				case'E':
					a.E();
					break;
				default:
					break;
				}
			}
			a.test(b);
			
			str = "";
		}

		sc.close();
	}
}



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

int main(){
    int n,x;
    cin>>n>>x;
    vector<int>m(n);
    rep(i,n)cin>>m[i];
    int under=0;
    rep(i,n)under+=m[i];
    x-=under;
    sort(m.begin(),m.end());
    int cnt=0;
    int now=0;
    rep(i,100000){
        
        now+=m[0];

        if(now<=x)cnt+=1;
        else break;
    }
    
    cout<<cnt+n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s,ans=1,f[1000005];
int main(){
	cin>>s;
	f[s]++;
	while(f[s]<=1)
	{
		ans++;
		if(s%2==0) s/=2;
		else s=s*3+1;
		f[s]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n,a,b;
    cin >>n>>a>>b;
    ans=min(n*a,b);

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))

minA, maxA = min(As), max(As)
diff = maxA - minA
if diff > 1:
    print('No')
elif diff == 1:
    numMinA = As.count(minA)
    if numMinA+1 <= maxA <= numMinA+(N-numMinA)//2:
        print('Yes')
    else:
        print('No')
else:
    if 2*maxA <= N or maxA == N-1:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 13964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,a,b;cin>>n>>m;
  lvector H(n,0),V(n,0);
  rep(i,n) cin>>H[i];
  rep(i,m) {
    cin>>a>>b;a--,b--;
    V[a]=max(V[a],H[b]);
    V[b]=max(V[b],H[a]);
  }
  ll ans=0;
  rep(i,n) if(H[i]>V[i]) ans++;
  print(ans);
  return 0;
}

Measured memory_bytes: 4784
/*
[tenka1-2018] D - Crossing
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int N;

int calc_num(int a, int b) {
    if (a < b) {
        swap(a, b);
    }
    return a * (a - 1) / 2 + b + 1;
}

bool solve(vector<set<int>>& ans) {
    int k = 0;
    while (k * (k - 1) / 2 < N) {
        k++;
    }
    if (k * (k - 1) / 2 != N) {
        return false;
    }

    ans.resize(k);
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < k; j++) {
            if (i == j) {
                continue;
            }
            ans[i].insert(calc_num(i, j));
        }
    }

    return true;
}

int main() {
    cin >> N;

    vector<set<int>> ans;
    bool ret = solve(ans);

    if (!ret) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    cout << ans.size() << endl;
    for (set<int>& s : ans) {
        cout << s.size();
        for (int n : s) {
            cout << " " << n;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  v1i v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;
  cout << v[n-1] << endl;
  return 0;
}

Measured memory_bytes: 256
HW = list(map(int,input().split()))
s = [input() for i in range(HW[0])]



for j in range(len(s) - 1):
    for i in range(len(s[j]) - 1):
        if s[j][i] == "#" and s[j][i] != s[j][i+1] and (s[j][i] != s[j][i-1] or i == 0):
            if s[j][i] != s[j+1][i] and (s[j][i] != s[j-1][i] or j == 0):
                print("No")
                exit()

print("Yes")

Measured memory_bytes: 3064
#include<stdio.h>


int main(){
	int n,m;
	int i,j;
	char c[1000000][2];
	char t[1000000];
	int f;
	while(scanf("%d",&n),n){
		for(i=0;i<n;i++){
			scanf("%s",&c[i][0]);
			scanf("%s",&c[i][1]);
		}

		scanf("%d",&m);
		for(i=0;i<m;i++){
			scanf(" %s",&t[i]);
		}

		for(i=0;i<m;i++){
			f=-1;
			for(j=0;j<n;j++){
				if(t[i]==c[j][0]){
					f=j;
				}
			}

			if(f!=-1){
				printf("%c",c[f][1]);
			}else if(f==-1){
				printf("%c",t[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int n, m;
  cin >> n >> m;
  ll x[n], y[m];
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < m; i++) cin >> y[i];

  ll sum_x = 0;
  for (int i = 0; i < n; i++) {
    sum_x += i * x[i] - (n - i - 1) * x[i];
    sum_x %= MOD;
  }
  ll sum_y = 0;
  for (int i = 0; i < m; i++) {
    sum_y += i * y[i] - (m - i - 1) * y[i];
    sum_y %= MOD;
  }

  // 解答
  cout << sum_x * sum_y % MOD << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    
    int A, B, C;
    cin >> A >> B >> C;
    if (A <= C && C <= B) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3600
n=int(input())
D={}
for i in range(n):
      s=input()[0]
      if s in D:
            D[s]+=1
      else:
            D[s]=1
L=[]
for p in "MARCH":
      if p in D:
            L.append(D[p])
ans=0
for i in range(len(L)):
      for j in range(i+1,len(L)):
            for k in range(j+1,len(L)):
                  ans +=L[i]*L[j]*L[k]
print(ans)


Measured memory_bytes: 3064
package main
import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
    // Your code here!
    length, _ := strconv.Atoi(nextLine())
    height, _ := strconv.Atoi(nextLine())
    width, _ := strconv.Atoi(nextLine())
    
    heightCount, widthCount := 0, 0
    
    for height <= length {
        heightCount = heightCount + 1
        height = height + 1
    }
    for width <= length {
        widthCount = widthCount + 1
        width = width + 1
    }
    fmt.Println(heightCount * widthCount)
}


Measured memory_bytes: 640
import bisect

S=[]

def insert(S,count,x):
    y=bisect.bisect(S,x)
    S.insert(y,x)
    count+=1
    print(count)
    return S,count

def find(S,x):
    y0=bisect.bisect_left(S,x)
    y1=bisect.bisect_right(S,x)
    return y0,y1

def erase(S,count,x):
    y0,y1=find(S,x)
    if y1-y0>0:
        del S[y0:y1]
        count-=y1-y0
    return S,count

def dump(S,L,R):
    s=bisect.bisect_left(S,L)
    e=bisect.bisect_right(S,R)
    if e-s>0:
        print('\n'.join(map(str,S[s:e])))

q=int(input())
count=0
for i in range(q):
    query=list(map(int,input().split()))
    
    if query[0]==0:
        S,count=insert(S,count,query[1])
    elif query[0]==1:
        y0,y1=find(S,query[1])
        print(y1-y0)
    elif query[0]==2:
        S,count=erase(S,count,query[1])
    else:
        dump(S,query[1],query[2])



Measured memory_bytes: 25816
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9 + 7

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod
combination = lambda n, k: fact[n] * fact_inv[k] * fact_inv[n-k] % mod

A.sort()
ans = 0
for i in range(N):
    if i >= K - 1:
        ans += A[i] * combination(i, K - 1)
    if N - i - 1 >= K - 1:
        ans -= A[i] * combination(N - i - 1, K - 1)
    ans %= mod
print(ans)

Measured memory_bytes: 59248
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
typedef pair<P, P> P2;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[110000] = {};

int main(){
	
	int N;
	cin >> N;
	
	P2 A[1100];
	for(int i = 0; i < N; i++){
		cin >> A[i].second.first >> A[i].first.second >> A[i].second.second;
		A[i].first.first = A[i].second.first + A[i].first.second;
	}
	
	sort(A, A + N);
	
	for(int i = 0; i < N; i++){
		int w = A[i].second.first;
		int s = A[i].first.second;
		long long int v = A[i].second.second;
		for(int j = s; j >= 0; j--){
			DP[j + w] = max(DP[j + w], DP[j] + v);
		}
	}
	
	long long int ans = 0;
	
	for(int i = 0; i < 100000; i++){
		ans = max(ans, DP[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  int ans=0;
  rep(i,N/R+1){
    rep(j,(N-R*i)/G+1){
      if((N-R*i-G*j)%B==0) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256