akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {+0,+1,+0,-1};
const static int ty[] = {-1,+0,+1,+0};
 
static const double EPS = 1e-8;

class BIT {
private:
  int n;
  ll* bit;
public:
  BIT(int _n) {
    n = _n;
    bit = new ll[n]();
  }
  
  ll sum(int i){
    ll s = 0;
    while(i > 0){
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  
  void add(int i, ll x){
    while(i <= n){
      bit[i] += x;
      i += i & -i;
    }
  }
};

int main(){
  int first_num;
  int last_num;
  int mod;
  while(~scanf("%d %d %d",&first_num,&last_num,&mod)){
    if(first_num == 0 && last_num == 0 && mod == 0) break;
    
    vector<int> order_lexicon;
    vector<string> nums;
    
    for(int start = first_num; start <= last_num; start++){
      stringstream ss;
      ss << start;
      nums.push_back(ss.str());
    }
    sort(nums.begin(),nums.end());
    
    for(int num_i = 0; num_i < nums.size(); num_i++){
      order_lexicon.push_back(atoi(nums[num_i].c_str()));
    }
    
    ll res = 0;
    BIT bit(last_num - first_num + 2);
    for(int i = 0; i < order_lexicon.size();i++){
      ll tmp = (bit.sum(order_lexicon[i] - first_num + 1) + 1) % mod;
      res += tmp;
      res %= mod;
      bit.add(order_lexicon[i] - first_num + 1,tmp);
    }
    
    printf("%lld\n",res % mod);
  }
}

Measured memory_bytes: 18060
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int b[101][101];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int cur = 0;
    int H, W, N;
    cin >> H >> W >> N;
    vi a(N);
    rep(i, N)cin >> a[i];

    vi xd(W), xr(W);
    rep(i, W)xd[i] = i, xr[i] = W - 1 - i;
    rep(y, H) {
        each(x, y & 1 ? xd : xr) {
            b[y][x] = cur + 1;
            if (--a[cur] == 0)cur++;
        }
    }

    rep(y, H)rep(x, W)cout << b[y][x] << (x != W - 1 ? ' ' : '\n');
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main () {
    int N; cin >> N;
    string S; cin >> S;
    char a = 'A';
    char z = 'Z';
    for (int i = 0; i < S.length(); i++) {
        if (z < S[i] + N) {
            cout << (char)(S[i] + N - 26) << flush;
        } else {
            cout << (char)(S[i] + N) << flush;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
  }
  vector<bool> vis(N);
  vector<int> path;
  vector<int> ans;
  function<void(int, int)> dfs = [&](int tmp, int par) {
    if(vis[tmp]) {
      auto from = find(all(path), tmp);
      int size = path.end() - from;
      if(size != 0) {
        if(ans.size() == 0 || size < (int)ans.size()) {
          ans = vector<int>(size);
          copy(from, path.end(), ans.begin());
        }
      }
      return;
    }
    path.push_back(tmp);
    vis[tmp] = true;
    for(int ne: G[tmp]) dfs(ne, tmp);
    path.pop_back();
  };
  rep(i, N) dfs(i, -1);
  if(ans.size() == 0) {
    cout << -1 << endl;
  } else {
    auto check = [&](vector<int>& path) {
      set<int> se;
      for(int v: path) se.insert(v);
      int n = path.size();
      rep(i, n) {
        for(int ne: G[path[i]]) {
          if(se.count(ne) && ne != path[(i+1)%n]) {
            return make_pair(path[i], ne);
          }
        }
      }
      return make_pair(-1, -1);
    };

    while(true) {
      auto ret = check(ans);
      if(ret.first == -1) break;
      vector<int> newPath;
      int n = ans.size();
      int begin = find(all(ans), ret.second) - ans.begin();
      int end = find(all(ans), ret.first) - ans.begin();
      for(int i=begin; i!=end; i=(i+1)%n) {
        newPath.push_back(ans[i]);
      }
      newPath.push_back(ans[end]);
      ans = vector<int>(newPath.size());
      copy(all(newPath), ans.begin());
    }
    cout << ans.size() << endl;
    for(int a: ans) cout << a+1 << endl;
  }
  return 0;
}


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

typedef long long ll;

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

    int a[n], b[n];
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 0; i < n; i++)  cin >> b[i];

    ll asum = accumulate(a, a+n, 0ll);
    ll bsum = accumulate(b, b+n, 0ll);

    ll chances = bsum - asum;
    if(chances < 0){
        cout << "No" << endl;
        return 0;
    }

    ll wanta = 0, wantb = 0;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == b[i] % 2){
            if(a[i] > b[i]) wantb += (a[i]-b[i]);
            else            wanta += (b[i]-a[i])/2;
        }else{
            wantb++;
            b[i]++;
            if(a[i] > b[i]) wantb += (a[i]-b[i]);
            else            wanta += (b[i]-a[i])/2;
        }
    }

    wanta = chances - wanta;
    wantb = chances - wantb;

    if(2 * wanta != wantb || wanta < 0 || wantb < 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
n=int(input())
A=list(map(int,input().split()))
q=int(input())
from collections import Counter
C=Counter(A)

ans=sum(A)
for i in range(q):
  a,b=map(int,input().split())
  ans+=(b-a) * C[a]
  C[b]+=C[a] ; C[a]=0
  print(ans)

Measured memory_bytes: 23996
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

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

const int N = 1e6 + 5;

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

ll D[N];
map<ll, int> M;
int sz[N];
vector<pii> edges;
vector<int> adj[N];

ll dfs(int v, int p, int dis) {
	ll ans = dis;
	for(auto it : adj[v]) {
		if(it == p) continue;
		ans += dfs(it, v, dis+1);
	}
	return ans;
}

int main() {

	boost;
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>D[i];
		M[D[i]] = i;
		sz[i] = 1;
	}

	for(auto it=M.rbegin(); (int) edges.size() < n-1 and it!=M.rend(); it++) {
		ll d = it->fi;
		int p = it->se;
		ll pard = d - n + 2 * sz[p];
		int par = M[pard];
		if(pard >= d or par == 0) break;
		sz[par] += sz[p];
		edges.pb(mp(par, p));
		adj[par].pb(p), adj[p].pb(par);
	}
	int v = M.begin()->se;

	if((int) edges.size() < n-1 or dfs(v, 0, 0) != D[v]) {
		cout<<"-1\n";
	}
	else {
		for(auto it : edges) {
			cout<<it.fi<<" "<<it.se<<"\n";
		}
	}
	return 0;
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
   int a,b,c,d,e,f;
   cin>>a>>b>>c>>d>>e>>f;
   vector<int>v;
   vector<int>w;
   for(int i=0;i<=f;i++){
       for(int j=0;j<=f;j++){
           int y=i*c+j*d;
           if(y<=f)
           v.push_back(y);
       }
   }
   for(int i=0;i<=f;i++){
       for(int j=0;j<=f;j++){
           int x=100*a*i+100*b*j;
           if(x<=f)
           w.push_back(x);
       }
   }
   double max=0;
   int k=0,l=0;
   for(int i=0;i<v.size();i++){
       for(int j=0;j<w.size();j++){
           if(v[i]+w[j]>f || v[i]>w[j]*e/100 || v[i]+w[j]==0){
               continue;
           }
           if((double)(100*v[i]/(double)(v[i]+w[j])>=max)){
               max=(double)(100*v[i])/(double)(v[i]+w[j]);
                k=i;
                l=j;
           }
       }

   }
    cout<<w[l]+v[k]<<' '<<v[k]<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  cout << ((n-1)+k-2)/(k-1) << endl;
}

Measured memory_bytes: 256
n=int(input())
s,ans,num =1,1,2
for i in range(2, n+1):
  s*=i
l=[]
while s!=1:
  if not s%num:
    l.append(num)
    s//=num
  else:
    num+=1
for i in set(l):
  ans*=l.count(i)+1
  ans%=10**9+7
print(ans%(10**9+7))


Measured memory_bytes: 3060
a = [int(input()) for _ in range(5)]
delta = []
time = 0
count = 0

for i in range(5):
    a10 = 0
    if str(a[i])[-1] != '0':
        a10 = (10 - int(str(a[i])[-1]))
        delta.append(a10)
        count += 0
    time += a[i] + a10

if count == 0:
    delta.append(0)

print(time-max(delta))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

ll N,K;
ll dp[100005];

int main(){

	scanf("%lld %lld",&N,&K);

	ll ans = 0;

	for(ll num = K; num >= 1; num--){

		ll tmp = mod_pow(K/num,N,MOD);
		for(ll i = 2; num*i <= K; i++){

			tmp -= dp[num*i];
			if(tmp < 0){
				tmp += MOD;
			}
		}
		dp[num] = tmp;
		ans += num*tmp;
		ans %= MOD;
	}

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

	return 0;
}


Measured memory_bytes: 4580
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> Option<T> {
    let s = s
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let stdin = stdin();

    let input = read::<String>(&mut stdin.lock());
    let input = input.unwrap();

    let bytes = input.into_bytes();
    if bytes[0] == bytes[1] || bytes[1] == bytes[2] || bytes[2] == bytes[3] {
        println!("Bad")
    } else {
        println!("Good");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
#define COUT(x) cout<<(x)<<endl
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

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

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int n, m;
int a[50], b[50];
bool graph[50][50];
bool visited[50];

void dfs(int v) {
	visited[v] = true;
	rep(i, n) {
		if (!graph[v][i])continue;
		if (visited[i])continue;
		dfs(i);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	int ans = 0;
	rep(i, m) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
		rep(j, n)visited[j] = false;
		dfs(0);
		bool bridge = false;
		rep(j, n)if (!visited[j])bridge = true;
		if (bridge)ans += 1;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))  # 親
        self.rank = [1]*n  # 木の高さ
        self.size = [1]*n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def union(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]
    
N, M, K = map(int, input().split())
A, B, C, D = [0]*M, [0]*M, [0]*K, [0]*K
for i in range(0, M):
    A[i], B[i] = map(int, input().split())
for i in range(0, K):
    C[i], D[i] = map(int, input().split())

friend, block = [0]*N, [0]*N
uf = UnionFind(N)
for i in range(0, M):
    friend[A[i]-1] = friend[A[i]-1]+1
    friend[B[i]-1] = friend[B[i]-1]+1
    uf.union(A[i]-1, B[i]-1)
for i in range(0, K):
    if uf.is_same(C[i]-1, D[i]-1):
        block[C[i]-1] = block[C[i]-1]+1
        block[D[i]-1] = block[D[i]-1]+1

ans = [0]*N
for i in range(0, N):
    ans[i] = uf.group_size(i)-friend[i]-block[i]-1
print (*ans)

Measured memory_bytes: 32376
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        System.out.println(solve(A, B, C));

        sc.close();
    }

    static int solve(int A, int B, int C) {
        return Math.min(B / A, C);
    }
}

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

int main() {
    
    int a, b, c;
    cin >> a >> b >> c;
    a *= 100;
    b *= 10;
    c += a + b;
    if (c % 4)cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
    
}





Measured memory_bytes: 256
N, M, X = map(int, input().split())
cost = []
text = []
ans = 12 * 10**5
find = False

for _ in range(N):
    C, *A = map(int, input().split())
    cost.append(C)
    text.append(A)

for i in range(2**N):
    yen = 0
    understand = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            yen += cost[j]
            for k in range(M):
                understand[k] += text[j][k]
    
    if all([u >= X for u in understand]):
        ans = min(ans, yen)
        find = True

print(ans if find else -1)

Measured memory_bytes: 68680
from itertools import product
n, m = map(int, input().split())
S = []
for _ in range(m):
    k, *s = map(lambda x: int(x)-1, input().split())
    S.append(s)
P = list(map(int, input().split()))
ans = 0
for bit in product((0, 1), repeat=n):
    for j in range(m):
        switch_cnt = sum(bit[idx] for idx in S[j])
        if P[j] != switch_cnt % 2:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define umap 			unordered_map
#define pb 				push_back
#define eb 				emplace_back
#define ins 			insert
#define all(a) 			a.begin(),a.end()
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
#define rep(i,s,e)		for (int i = s; i <= e; i++)
#define repr(i,s,e) 	for (int i = s; i >= e; i--)
#define mem0(a)			memset(a, 0, sizeof(a))
#define mem1(a)			memset(a, -1, sizeof(a))
#define beg(a)			a.begin()
#define sz(x) 			((int)(x.size()))
#define len(str)		((int)(str.length()))
const ll inf = 1e18 + 1;
const int mod = 998244353;
const int maxn = 3e5;
ll modpow(ll a,ll b,int mod = inf) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) {return __gcd(a,b);}
int n, a[maxn][4], dp[maxn][4];

int rec(int i, int ty){
	if (i > n) return 0;
	if (dp[i][ty] != -1) return dp[i][ty];
	rep(j,1,3) if (j != ty) dp[i][ty] = max(a[i][j] + rec(i + 1, j), dp[i][ty]);
	return dp[i][ty];
}

signed main(){
	FLASH
	cin>>n;
	rep(i,1,n) cin>>a[i][1]>>a[i][2]>>a[i][3];
	mem1(dp);int ans1 = rec(1,1);
	mem1(dp);int ans2 = rec(1,2);
	mem1(dp);int ans3 = rec(1,3);
	cout<<max(ans1, max(ans2, ans3));
	return 0;
}


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

int main() {
    int N; cin>>N;
    for (int i = 1; i < 10; i++){
        if(N%i==0 && N/i<=9){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3612
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 0; i < 3; i++) {
            set.add(in.nextInt());
        }
        System.out.println(set.size());
    }
}


Measured memory_bytes: 27064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

ll dp[2010][2010];

void chmax(ll& a, ll b) {
	a = max(a, b);
}

int main() {
	for (int i = 0;i < 2010;i++) {
		for (int j = 0;j < 2010;j++) {
			dp[i][j] = 0;
		}
	}
	ll N, X;
	cin >> N;
	vector<pair<ll, int>> A(N);
	for (int i = 0;i < N;i++) {
		cin >> X;
		A[i] = { X,i };
	}
	sort(all(A));
	reverse(all(A));
	for (int i = 0;i < N;i++) {
		for (int j = 0, k = i;k >= 0;j++, k--) {
			chmax(dp[j + 1][k], dp[j][k] + A[i].first * (ll)abs(j - A[i].second));
			chmax(dp[j][k + 1], dp[j][k] + A[i].first * (ll)abs(N - 1 - k - A[i].second));
		}
	}
	ll ans = 0;
	for (int j = 0, k = N;k >= 0;j++, k--) {
		chmax(ans, dp[j][k]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 35228
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    X, N = MI()
    p = LI()
    W = X
    Y = X


    while True:

        if (W not in p)and (Y not in p):
            ans = W
            break
        elif (W not in p) and (Y in p):
            ans = W
            break
        elif (W in p) and (Y not in p):
            ans = Y
            break
        W -= 1
        Y += 1 
    print(ans)


    
    print()

if __name__ == "__main__":
	main()

Measured memory_bytes: 9208
#include <iostream>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if(y&1){	cout << "No\n";}
  else{
    	if(y>=2*x and y<=4*x)
          	cout << "Yes\n";
    	else
          	cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n;
  cin >> n;
  cout << (n - 1) * n / 2 << "\n";
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc163/tasks/abc163_a

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var r int
	fmt.Fscanf(in, "%d\n", &r)

	fmt.Fprintln(out, float32(2*(math.Pi)*float32(r)))
}


Measured memory_bytes: 1832
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main(void){
    int x;
    std::cin >> x;
    std::cout << ((1 == x)? 0 : 1) << std::endl;

    return 0;
}

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

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

    vector<int> elems;
    elems.push_back(a + b);
    elems.push_back(a * b);
    elems.push_back(a - b);
    cout << *max_element(elems.begin(), elems.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
#define Endl endl
int kai_size = 100001;
vel kai(kai_size, 1);
vel ink(kai_size, 1);

int RE() {
	vel v(3, 2);
	return v.at(4);
}
signed main() {
	int n; cin >> n;
	V<pin> x(n);
	rep(i, n) {
		int a; cin >> a; a--;
		x[i] = mkp(a, i);
	}
	sor(x);
	vvel ans(n);
	vel pq(0);
	rep(i, n) {
		rep(j, x[i].second) {
			pq.push_back(x[i].second);
		}
	}
	rep(i, n) {
		rep(j,n-1- x[i].second) {
			pq.push_back(x[i].second);
		}
	}
	int now_val = 0;
	auto itr = pq.begin();
	rep(i, n) {
		while (now_val < x[i].first) {
			int pla = *itr;
			if (ans[pla].size() == pla) { cout << "No" << endl; return 0; }
			ans[pla].push_back(now_val); now_val++;
			itr++;
		}
		int pla = x[i].second;
		if (ans[pla].size() < pla) { cout << "No" << endl; return 0; }
		ans[pla].push_back(x[i].first);
		now_val++;
	}
	while (now_val < n*n) {
		int pla = *itr;
		if (ans[pla].size() == pla) { cout << "No" << endl; return 0; }
		ans[pla].push_back(now_val);
		itr++;
		now_val++;
	}
	vel ret(n*n);
	rep(i, n) {
		rep(j, n) {
			ret[ans[i][j]] = i;
		}
	}
	cout << "Yes" << endl;
	rep(i, n*n-1) { cout << ret[i]+1<<" "; }
	cout << ret[n*n - 1]+1 << endl;
	return 0;
}


Measured memory_bytes: 8692
#include <stdio.h>

#define MAX 200000

int main()
{
  int n;
  int i;
  int maxv,minv;
  int R[MAX];

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      scanf("%d",&R[i]);
    }
  maxv = -2000000000;
  minv = R[0];
  for(i = 1; i < n; i++)
    {
      maxv = (maxv <= R[i] - minv) ? R[i] - minv : maxv;
      minv = (minv >= R[i] ) ? R[i] : minv;
    }

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

  return 0;
}




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

int main(){
  int N1,N2,N3,Ntot;
  cin >> N1 >> N2 >> N3 >> Ntot;

  int ans= 0;
  for(int n1=0; n1<= Ntot/N1; n1++){
    for(int n2=0; n2<= Ntot/N2; n2++){
      int remain= Ntot- (N1*n1+ N2*n2);
      if(remain < 0){ break; }
      else{
        if(remain % N3==0){ ans++; }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

lli n, k;
lli a[MAXN], dp[MAXN];

lli f(lli x) {
    if (x > n) return INF;
    if (x == n) return 0;
    if (dp[x] != -1) return dp[x];

    lli ans = INF;
    for (int i = 1; i <= k; ++i) {
        if (x + i > n) continue;
        ans = min(ans, abs(a[x] - a[x + i]) + f(x + i));
    }
    return dp[x] = ans;
}
void solve() {
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    lli ans = f(1);
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    solve();

    return 0;
}

Measured memory_bytes: 6528
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    println(count(i->i=='1',chomp(readline())))
end
main()

Measured memory_bytes: 167072
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
using namespace std;

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

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

    vector<pair<int, int>> b(n);
    for (int i = 0; i < n; ++i) {
        b[i].first = a[i];
        b[i].second = (i & 1);
    }

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

    int bad[2];
    bad[0] = bad[1] = 0;

    for (int i = 0; i < n; ++i) {
        if ((i & 1) != b[i].second) {
            ++bad[b[i].second];
        }
    }

    cout << max(bad[0], bad[1]) << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

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

    rrep(i, n)
    {
        if ((i + n) % 2 == 1) {
            cout << a[i] << " ";
        }
    }
    rep(i, n)
    {
        if ((i + n) % 2 == 0) {
            cout << a[i] << " ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-


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

d = [0]*K
A = [0]*N
Ak = [0]*K

for i in range(0,K):
    d[i]= input()
    d[i]= int(d[i])
    Ak[i] = input().split()
    Ak[i] = [int(s) for s in Ak[i]]
    for j in range(0,d[i]):
        A[Ak[i][j]-1] += 1
        
print(A.count(0))

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
vector<int>par;
vector<int>S;
void init(int N) {
  par.resize(N + 1);
  S.resize(N + 1);
  for (int i = 0; i <= N; i ++) {
    par[i] = i;
    S[i] = 1;
  }
}
int root(int v) {
  if (v == par[v]) return v;
  return par[v] = root(par[v]);
}
int siz(int v) {
  return S[root(v)];
}
void merge(int a, int b) {
  a = root(a);
  b = root(b);
  if (a == b) return;
  if (siz(a) < siz(b)) swap(a, b);
  par[b] = a;
  S[a] += S[b];
}

int main () {
  int N;
  cin >> N;
  init(N);
  vector<tuple<int, int, int>> X_yu(N);
  vector<tuple<int, int, int>> Y_yu(N);
  for (int i = 0; i < N; i ++) {
    int x, y;
    cin >> x >> y;
    X_yu[i] = make_tuple(x, y, i);
    Y_yu[i] = make_tuple(y, x, i);
  }
  sort(X_yu.begin(), X_yu.end());
  sort(Y_yu.begin(), Y_yu.end());
  int fl = N;
  for (int i = 0; i < N; i ++) {
    int x, y, i_;
    tie(x, y, i_) = X_yu[i];
    for (int j = y; j < fl; j ++) {
      merge(i_, get<2>(Y_yu[j]));
      //cout << i_ << ' ' << get<2>(Y_yu[j]) << endl;
    }
    fl = min(fl, y - 1);
  }
  fl = -1;
  for (int i = N - 1; i >= 0; i --) {
    int x, y, i_;
    tie(y, x, i_) = Y_yu[i];
    for (int j = x - 1; j > fl; j --) {
      merge(i_, get<2>(X_yu[j]));
      //cout << i_ << ' ' << get<2>(X_yu[j]) << endl;
    }
    fl = max(fl, x - 1);
  }
  fl = N;
  for (int i = 0; i < N; i ++) {
    int x, y, i_;
    tie(y, x, i_) = Y_yu[i];
    for (int j = x; j < fl; j ++) {
      merge(i_, get<2>(X_yu[j]));
      //cout << i_ << ' ' << get<2>(X_yu[j]) << endl;
    }
    fl = min(fl, x - 1);
  }
  fl = -1;
  for (int i = N - 1; i >= 0; i --) {
    int x, y, i_;
    tie(x, y, i_) = X_yu[i];
    for (int j = y - 1; j > fl; j --) {
      merge(i_, get<2>(Y_yu[j]));
      //cout << i_ << ' ' << get<2>(Y_yu[j]) << endl;
    }
    fl = max(fl, y - 1);
  }
  for (int i = 0; i < N; i ++) cout << siz(i) << endl;
}

Measured memory_bytes: 9512
let () = Scanf.scanf "%d" (fun n ->
  Array.init 10 (( * ) 111)
  |> Array.to_list
  |> List.exists (fun m -> n mod 1000 = m || n / 10 = m)
  |> (function true -> "Yes" | false -> "No")
  |> print_endline)

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
  int a=0;
  int b=0;
  int c=0;
  int e=1;
  int f=0;
  scanf("%d",&a);
  int d[a];
  for(b=0;b<a;b++){
    scanf("%d",&d[b]);
  }
  f=d[0];
  for(c=1;c<a;c++){
    if(f==d[c]){
      e++;
    }else
    if(f<d[c]){
      f=d[c];
      e++;
    }
  }
  printf("%d\n",e);
}


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

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  int h[n];
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  sort(h, h+n);
  int ans;
  ans =1000000000;
  for(int i=0; i<n+1-k; i++){
    ans = min(ans, h[i+k-1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
from bisect import bisect
s = input()
t = input()
def ctoi(c):
	return ord(c) - ord("a")
if not (set(s) >= set(t)):
	print(-1)
else:
	alph = [[] for _ in range(26)]
	for i in range(len(s)):
		alph[ctoi(s[i])].append(i)
	for a in alph:
		if a:
			a.append(a[0] + len(s))
	#print(alph)
	cur = len(s)-1
	ans = 0
	for i in range(len(t)):
		ind = bisect(alph[ctoi(t[i])], cur)
		ans += alph[ctoi(t[i])][ind] - cur
		cur = alph[ctoi(t[i])][ind] % len(s)
	print(ans)

Measured memory_bytes: 52976
n = int(input())
a = [int(i) for i in input().split()]
table = [True for _ in range(2 * (10 ** 6))]
a.sort()
ans = 0
for i in range(n):
    if table[a[i]]:
        for j in range(a[i], 2 * (10 ** 6), a[i]):
            table[j] = False
        if i + 1 < n:
            if a[i + 1] != a[i]:
                ans += 1
        elif i + 1 == n:
            ans += 1
print(ans)

Measured memory_bytes: 36612
// https://atcoder.jp/contests/abc048/tasks/arc064_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, X;
  cin >> N >> X;

  VL as(N);
  rep(i, N) cin >> as[i];

  ll res = 0;

  rep1(i, N - 1) {
    ll cur_sum = as[i] + as[i - 1];

    if (cur_sum > X) {
      res += cur_sum - X;

      as[i] = max(as[i] - (cur_sum - X), 0ll);
    }
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 1024
n, ma, mb = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
a_limit = [0]
b_limit = [0]
for i in range(n):
    a_limit.append(a_limit[-1] + x[i][0])
    b_limit.append(b_limit[-1] + x[i][1])

INF = 10 ** 9
DP = [None for _ in range(n + 1)]
for i in range(n + 1):
    DP[i] = [[INF for k in range(b_limit[-1] + 1)] for j in range(a_limit[-1] + 1)]

DP[0][0][0] = 0
for i in range(n):
    for j in range(a_limit[i] + 1):
        for k in range(b_limit[i] + 1):
            DP[i + 1][j][k] = min(DP[i + 1][j][k], DP[i][j][k])
            DP[i + 1][j + x[i][0]][k + x[i][1]] = min(DP[i + 1][j + x[i][0]][k + x[i][1]], DP[i][j][k] + x[i][2])

ans = INF
for j in range(1, a_limit[-1] + 1):
    for k in range(1, b_limit[-1] + 1):
        if k * ma == j * mb:
            ans = min(ans, DP[-1][j][k])
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27584
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
//ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
//const long double EPS=1E-8;
////////////////////////////////////////
#define N 100004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*mod(po(i,p-1)));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(int i=1;i<N;i++){
        kai[i]=mod(kai[i-1]*i);
        kai2[i]=mod(po(kai[i],i_5));
    }
}
ll comb(ll n,ll k){
    if(n==0){
        if(k==0)return 1;
        else return 0;
    }
    else if(n<k)return 0;
    else return mod(mod(mod(kai[n])*mod(kai2[n-k]))*mod(kai2[k]));
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    calc();
    ll n,k;cin>>n>>k;
    ll ans=0;
    for(int c=k;c>=1;c--){
        ll add=mod(po(c,n)*comb(k,c));
        if((c-k)%2==0)Add(&ans,add);
        else Add(&ans,-add);
    }
    cout<<ans<<endl;
    
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);



Measured memory_bytes: 4796
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)

//your code here!

int main(void){
    ll N, ans=0; char S[100100];
    scanf("%lld %s", &N, S);
    for(ll i=0; '\0'!=S[i]; i++) if(S[i]!=S[i+1]) ans++;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
S = input()
n = []
for i in range(len(S)):
  for p in range(i+1,len(S)):
    if S[i] == S[p]:
      n.append(0)
  if i == len(S)-1:
    n.append(1)
for i in range(len(n)):
  if n[i] == 0:
    print('no')
    break
  if i == len(n)-1:
    print('yes')

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

using namespace std;

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

int main() {
	int n; cin >> n;
	vector<int> L(n);
	vector<int> R(n);
	set<int> P;
	rep(i, n) {
		P.insert(i);
	}
	rep(i, n) {
		int v, l, r; cin >> v >> l >> r;
		L[v] = l; R[v] = r;
		P.erase(l); P.erase(r);
	}
	auto a = [&](auto f, int p) -> void {
		if (p == -1) return;
		cout << " " << p;
		f(f, L[p]);
		f(f, R[p]);
	};
	auto b = [&](auto f, int p) -> void {
		if (p == -1) return;
		f(f, L[p]);
		cout << " " << p;
		f(f, R[p]);
	};
	auto c = [&](auto f, int p) -> void {
		if (p == -1) return;
		f(f, L[p]);
		f(f, R[p]);
		cout << " " << p;
	};
	int p = *(P.begin());
	cout << "Preorder" << endl;
	a(a, p);
	cout << endl;
	cout << "Inorder" << endl;
	b(b, p);
	cout << endl;
	cout << "Postorder" << endl;
	c(c, p);
	cout << endl;
}


Measured memory_bytes: 3092
#include <stdio.h> 
#define _USE_MATH_DEFINES 
#include <math.h> 
  int main(){ 
     int a, b, angle; 
     double s, l, h; 
     scanf("%d %d %d", &a, &b, &angle); 
     h=b*sin(angle*M_PI/180.0); 
   s=a*h/2; 
     l=a+b+sqrt((a*a+b*b-2*a*b*cos(angle*M_PI/180.0))); 
     printf("%f\n", s); 
     printf("%f\n", l); 
     printf("%f\n", h); 
      return 0; 
} 


Measured memory_bytes: 2076
n, m = map(int, input().split())
x = list(map(int, input().split()))


if n >= m:
    # 全ての地点にコマを置ける
    print(0)
else:
    x.sort()
    # 隣り合う地点間の距離を求める
    # ex. 地点:[-100,0,1,5]
    # ans. diff:[100,1,4]
    diff = [x[i + 1] - x[i] for i in range(m - 1)]
    diff.sort()
    # そのなかで削減可能なのは、高々n-1個分
    print(sum(diff[0:m - n]))

Measured memory_bytes: 13964
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

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

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

public class Main {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	public void run() {
		while (true) {
			int n = in.nextInt();
			if (n == 0) break;
			
			int res = 0;
			for (int i = 0; i < n / 2; i++) {
				String s1 = in.next(), s2 = in.next();
				if (s1.matches("lu") && s2.matches("ru")) res++;
				if (s1.matches("ru") && s2.matches("lu")) res++;
				if (s1.matches("rd") && s2.matches("ld")) res++;
				if (s1.matches("ld") && s2.matches("rd")) res++;				
			}
			if (n % 2 != 0) in.next();
			System.out.println(res);
		}
		out.close();
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

Measured memory_bytes: 44132
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18

int main() {
    int n ;
    cin >> n ;
    vector<pair<pair<string,int>, int>> vec (n);
    rep(i, n){
        string s ;
        int p ;
        cin >> s >> p ;
        p = 100 - p ;
        pair<pair<string,int>, int> k (pair<string,int>(s, p), i) ;
        vec[i] = k ;
    }
    sort(vec.begin(), vec.end()) ;
    rep(i, n){
        cout << vec[i].second + 1  << endl ;
    }
} 

Measured memory_bytes: 3644
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 50
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <int, int> P;

int main(){
    int a;
    cin >> a;
    cout << a + a * a + a *a * a << endl;
    return 0;
}


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

using namespace std;

int main(){
	int N;
	while(true){
		cin >> N;
		if(N == 0)break;
		int DATA[N+1][2];
		int score = 0,n1,n2;
		for(int i = 0;i < N;i++){
			cin >> DATA[i][0];
			for(int j = 0;j < 8 / 2;j++){
				cin >> n1 >> n2;
				score += (n1 * 60) + n2; 
			}
			DATA[i][1] = score;
			score = 0;
		}
		int max = -1;
		int z = 0,c = 0;
		for(int i = 0;i < N;i++){
			for(int j = 0;j < N;j++){
				if(max < 0){
					max = DATA[j][1];
					c = j;
				}else if(max > DATA[j][1] and DATA[j][1] >= 0){
					max = DATA[j][1];
					c = j;
				}
			}
			if(i <= 1 or i == N-2){
			cout << DATA[c][0] << endl;
			}
			DATA[c][1] = -1;
			c=0;
			max = -1;
		}
	}
}

Measured memory_bytes: 1196
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> a[i][j];
	}
	int ans = 1e9 + 7;
	for (int bit = 0; bit < (1 << n); bit++) {
		vector<int> cnt(m);
		int ansi = 0;
		rep(i, n) {
			if (bit & (1 << i)) {
				ansi += c[i];
				rep(j, m) cnt[j] += a[i][j];
			}
		}
		bool flag = true;
		rep(i, m) {
			if (cnt[i] < x) flag = false;
		}
		if (flag) ans = min(ans, ansi);
	}
    if(ans==1e9+7) cout<<-1<<endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3636