akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  ll a, b;
  std::cin >> a >> b;

  std::string sa = std::string(b, '0' + a);
  std::string sb = std::string(a, '0' + b);
  print(std::min(sa, sb));

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <cmath>
bool is_integer( double x ){
  return std::floor(x)==x;
}
int main (){
	double n;
	bool ans=false;
	cin >> n;
	for(int i=1; i<10; i++){
		if(n/i<10 && is_integer(n/i)){
			ans=true;
		}
	}
	if(ans==true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll n=0;
    cin>>n;
    ll ar[n];
    for(ll i=0;i<n;++i) cin>>ar[i];
    ll s=0;
    for(ll i=0;i<n-1;++i){
        for(ll j=i+1;j<n;++j){
            s+=ar[i]*ar[j];
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    int a,b,c;
    cin >> a >> b >> c;
    
    // REP(i,n+1){
        // cout <<i<<":"<< DP[i] << endl;
    // }
    cout << ((a+b+c>21)?"bust":"win") << endl;
    return 0;
}

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

using namespace std;

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

class UnionFind {
private:
  int n;
  vector<int> a;
public:
  UnionFind(int n) : n(n), a(n, -1) {}
  int find(int x) {return a[x] < 0 ? x : (a[x] = find(a[x]));}
  bool equal(int x, int y) {return find(x) == find(y);}
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] = x;
    --n;
  }
  int size() {return n;}
};

int main() {
  int n;
  while (cin >> n) {
    int cnt[7] = {};
    UnionFind uf(7);
    rep (i, n) {
      string domino;
      cin >> domino;
      ++cnt[domino[0] - '0'];
      ++cnt[domino[1] - '0'];
      uf.unite(domino[0] - '0', domino[1] - '0');
    }
    int c = 0;
    rep (i, 7) if (cnt[i] % 2) ++c;
    if (c > 2) {
      cout << "No" << endl;
      continue;
    }
    c = 0;
    rep (i, 7) if (!cnt[i]) ++c;
    if (uf.size() == c + 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1196
S=input()

if S[0]=='A' :
    if 'C' in S[2:-1]:
        if S.count('C')==1:
            bl = True
            for s in S:
                if s<'a' and s !='A' and s !='C':
                    bl = False
            if bl:
                print('AC')
                exit(0)                
print('WA')
    

                
                
                
    

    


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[1000], b[1000], ans=0, i;
    cin >> n;
    for(i=0;i<n-1;i++){
        cin >> b[i];
    }
    a[0]=b[0];
    for(i=1;i<n-1;i++){
        a[i]=min(b[i], b[i-1]);
    }
    a[n-1]=b[n-2];
    for(i=0;i<n;i++){
        ans=ans+a[i];
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
def resolve():
    N, K = list(map(int, input().split()))
    snacks = [0 for _ in range(N)]
    for i in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            snacks[a-1] += 1
    cnt = 0
    for s in snacks:
        if s == 0:
            cnt += 1
    print(cnt)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 67860
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

struct UnionFind {
    vector<int> par;
    vector<int> siz;

    UnionFind(int N) : par(N), siz(N) { 
        for(int i = 0; i < N; i++) par[i] = i, siz[i] = 1;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        siz[ry] += siz[rx];
        par[rx] = ry; 
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return siz[root(x)];
    }
};

int main() {
    int n, m; cin >> n >> m;
    int a[m], b[m];
    set<Pint> st;
    UnionFind uf(n);
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        if(a[i] > b[i]) swap(a[i], b[i]);
        if(st.count({a[i], b[i]})) continue;
        st.insert({a[i], b[i]});
        uf.unite(a[i], b[i]);
    }
    int ans = 0;
    rep(i, n) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 21932
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
ll mod = pow(10, 9) + 7;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll calcNumOfCombination(ll n, ll r){
        ll num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) % mod * modinv(i,mod) % mod;
        }
        return num;
}
ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
int main(){
    ll n, a, b, ans=1;
    cin >> n >> a >> b;
    ans = myPow(2,n,mod);
    ans = (ans + mod - 1) % mod;
    ans = (ans + mod - calcNumOfCombination(n, a)) % mod;
    ans = (ans + mod - calcNumOfCombination(n, b)) % mod;

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


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a)
        cout << k << endl;
    else if (k <= a + b)
        cout << a << endl;
    else
        cout << a - (k-(a+b)) << endl;


    return 0;
}

Measured memory_bytes: 3632
n, k = gets.strip.split.map(&:to_i)
     
    result = 0
    (1..n).each do |b|
      result += ( (n/b) * [(b-k), 0].max + [(n%b)-k+1, 0].max )
    end
     
    result -= n if k==0
     
    p result

Measured memory_bytes: 3836
#include<stdio.h>

#define MAX_S 100000
#define MAX_T 50000

void insertionSort(int *b,int k){
  int i,j,v;
  
  for(i = 1; i < k; i++){
    v = b[i];
    j = i - 1;
    while(j >= 0 && b[j] > v){
      b[j + 1] = b[j];
      j--;
    }
    b[j + 1] = v;
  }

}

int binarySearch(){
  int n,q,count,i,j,mid,r,l,a,b,c;
  int s[MAX_S],t[MAX_T];

  count = 0;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&s[i]);
  insertionSort(s,n);
  scanf("%d",&q);
  for(i = 0; i < q; i++)
    scanf("%d",&t[i]);

  

   
  for(i = 0; i < q; i++){
    a = 0;
    b = n / 2;
    c = n - 1;
    l = s[a];
    mid = s[b];
    r = s[c];

    while(1){
      if(mid >= t[i]){ 
	c = b;
	b = (a + c)/2;
      }
      else {
	a = b + 1;
	b = (a + c)/2;
      }
      
      l = s[a];
      mid = s[b];
      r = s[c];
    
 
      
      if(mid == t[i]){

	count++;
	break;
      }
      if(l == r)
	break;
      else if(l > r)
	break;
    }
  }
  
  return count;
}

int main(){

  printf("%d\n",binarySearch());
  
  return 0;
}



Measured memory_bytes: 2324
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 50000

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

	int n, i, j, k, ct, x;
	cin >> n;
	vector<vector<int>> q(n + 1, vector<int>(n - 1));
	vector<int> pos(n + 1, 0);
	for (i = 1; i <= n; i++) {
		for (j = 0; j < n - 1; j++) {
			cin >> q[i][j];
		}
	}

	bool allempty, moved;
	ct = 0;
	vector<int> c(n + 1, 0);
	while (1) {
		allempty = true;
		moved = false;
		for (i = 1; i <= n; i++) {
			if (pos[i] < n - 1) {
				allempty = false;
				x = q[i][pos[i]];
				if ((q[x][pos[x]] == i) && (c[x] <= ct) && (c[i] <= ct)) {
					pos[i]++;
					pos[x]++;
					c[x] = ct + 1;
					c[i] = ct + 1;
					moved = true;
				}
			}
		}
		if (allempty) break;
		if (!moved) break;
		ct++;
	}

	if (allempty) cout << ct << "\n";
	else cout << "-1\n";


	return 0;
}


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


int main()
{string S;
 cin >> S;
 bool p=true;
rep(i, S.size()){
  if(!(i%2)){
    if(!(S[i]=='R'||S[i]=='U'||S[i]=='D'))
      p=false;}
  else if(i%2){
    if(!(S[i]=='L'||S[i]=='U'||S[i]=='D'))
      p=false;}
}
 if(p) cout << "Yes" << endl;
 else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int n;cin>>n;
  vi h(n);
  rep(i,n)cin>>h[i];
 
  int ans=0;
  int max=0;
  rep(i,n){
    if(max<h[i])max=h[i];
    if(h[i]>=max)ans++;
  }
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 125568
from collections import defaultdict as dd

d=dd(int)
n,m=map(int,input().split())
l=[[i]+list(map(int,input().split()))+[0] for i in range(m)]

o=sorted(l,key=lambda x:x[2])
for i,j in enumerate(o):
  d[j[1]]+=1
  o[i][3]=d[j[1]]

for i in sorted(o):
  print("%06d%06d"%(i[1],i[3]))


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

int main() {
  
  int A, B, i;
  int count=0;
  
  cin >> A >> B;

  for (int i = A; i <= B; i++){
    if (i / 10000 == i % 10){
      if ((i / 1000 ) % 10 == (i % 100) / 10){
        count++;
      }
    }
  }
  
  cout << count << endl;

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

mod=10**9+7

ans=0
for i in range(60):
  on=0
  off=0
  for j in a:
    if (j>>i)&1:
      on+=1
    else:
      off+=1
  ans+=(on*off)*(2**i)
  ans%=mod

print(ans)

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

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p,p+n);
    int ans[3];
    for(int i=0;i<3;i++) ans[i]=0;
    for(int i=0;i<n;i++){
        if(p[i]<=a) ans[0]++;
        else if(p[i]>=a+1&&p[i]<=b) ans[1]++;
        else if(p[i]>=b+1) ans[2]++;
    }
    cout << min(ans[0],min(ans[1],ans[2])) << endl;
}

Measured memory_bytes: 256
num = list(map(int,input().split()))
lp = 0
while lp < len(num)-1:
    rp = len(num)-1
    while rp > lp:
        if num[rp] < num[rp-1]:
            x = num[rp]
            num[rp] = num[rp-1]
            num[rp-1] = x
        rp -= 1
    lp += 1
print(num[0]+num[1])


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> p(N);
	for (auto &x : p) {
		cin >> x;
		--x;
	}

	int ans = 0;
	for (int i = 0; i < N; ) {
		if (p[i] == i) {
			if (i + 1 < N && p[i + 1] == i + 1) {
				i += 2;
			}
			else {
				i += 1;
			}
			++ans;
		}
		else {
			i += 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 100000000000


int main() {
	ll n;
	vector<ll>a;
	cin>>n;
	for(int i=0;i<n;i++){
		ll z;
		cin>>z;
		a.push_back(z);
	}
	sort(a.begin(),a.end());
	cout << a[n/2]-a[n/2-1];
}

Measured memory_bytes: 1400
n = int(input())
a = [n]
flag = True
i = 0
while flag:
    if a[i] %2 == 0: 
        if a[i]/2 in a:
            flag = False
        a.append(a[i]/2)
        i += 1
    else:
        if (a[i]*3 + 1) in a:
            flag = False
        a.append((a[i]*3 + 1))
        i += 1
print(i +1)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>

using namespace std;
#define vsort(v) sort(v.begin(), v.end());

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	bool array[26];
	for(int i = 0; i < 26; i++) array[i] = false;
	int j ;
	j = 'a';
	for(int i = 0; i < S.size(); i++) {
		int idx = S[i] - 'a';
		array[idx] = true;
	}
	for(int i = 0;i < 26; i++){
		if(!array[i]) {
			printf("%c\n", 'a' + i);
			//cout << 'a' + i << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep2(i,st,ed) for(int i = st; i < ed; ++i)
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
const ll mod = 1e9 + 7;
const ll N = 2e5 + 200;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;

int dis[N];
int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
map<int, bool> have;
int main()
{
    int n;
    cin>>n;
    int k;
    for(int i=0;i<n;i++) 
    {
        cin>>k;
        if(have[k]) have.erase(k);
        else have[k] = true;
    }
    cout<<have.size()<<endl;
    return 0;
}

Measured memory_bytes: 4864
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,cnt,f;
	int d[12];
	map<int,int> s;
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		cnt=0;
		rep(i,n)scanf("%d",d+i);
		for(;;cnt++){
			s.clear();
			rep(i,n)s[d[i]]++;
			f=1;
			rep(i,n)if(s[d[i]]!=d[i])f=0;
			if(f)break;
			rep(i,n)d[i]=s[d[i]];
			//break;
		}
		printf("%d\n",cnt);
		rep(i,n)printf("%d%c",d[i],i==n-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1192
def main():
    n = int(input())
    a = list(map(int,input().split()))
    from collections import Counter
    c = Counter(a)
    cnt = 0
    for i,j in c.items():
        if i == 1:
            cnt += max(j-1,0)
        else:
            cnt += j%i
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 98588
/*  -*- coding: utf-8 -*-
 *
 * b.cc: D: AtCoDeerくんと変なじゃんけん / AtCoDeer and Rock-Paper
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int gn = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'g') gn++;
    else gn--;
  }
  printf("%d\n", gn / 2);
  return 0;
}


Measured memory_bytes: 512
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define MP make_pair
#define PB push_back

int main(){
	
	int N, K;
	cin >> N >> K;
	double ans = 0;
	for(int i=1; i<=N; i++){
		int s = i;
		double tmp = 1;
		while(s < K){
			s *= 2;
			tmp /= 2;
		}
		ans += tmp / N;
	}
	cout << setprecision(18) << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline
inf = 10 ** 18

L, R = map(int, input().split())

if (L // 2019) < (R // 2019):
    print(0)
else:
    ans = inf
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans_tmp = (i * j) % 2019
            if ans > ans_tmp:
                ans = ans_tmp
    print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define mema(a) mem(a,127)
#define memi(a) mem(a,128)
#define mem0(a) mem(a,0)
#define mem1(a) mem(a,-1)
#define Qclear(q) while(!q.empty())q.pop()
#define LL long long
#define EPS 1e-6
#define PI (acos(-1))
#define E exp(1.0)
#pragma comment (linker,"/STACK:102400000,102400000")
#define true false
#define false true
template<class T> T lcm(T a, T b){return a/__gcd(a,b)*b;}
template <class T>
inline bool scan_d(T &ret)
{
    char c;
    int sgn;
    if (c=getchar(),c==EOF) {
        return false;
    }
    while (c!='-'&&(c<'0'||c >'9')) {
        c=getchar();
    }
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') {
        ret=ret*10+(c - '0');
    }
    ret*=sgn;
    return true;
}
template <class T>
inline void print_d(T x)
{
    if(x>9)
    {
        print_d(x/10);
    }
    putchar(x%10+'0');
}
const int maxn=100000+5;
const int MOD=1E9+7;
const int INF=0x3f3f3f3f;
const int dx[]={0,0,1,-1,0,0};
const int dy[]={1,-1,0,0,0,0};
const int dz[]={0,0,0,0,1,-1};
int main(){
    int a,b;
    cin>>a>>b;//.#
    --a;
    --b;
    swap(a,b);
    string s[111];
    for(int j=0;j<98;j++)s[109]+="#";
    for(int j=0;j<98;j++)s[108]+=".";
    int i=0;
    while(b){
        s[i]=s[i]+".#";
        b--;
        if(s[i].length()==98){
            i+=2;
            s[i-1]=s[109];
        }
    }
    for(int j=s[i].length();j<98;j++)s[i]+="#";
    s[++i]=s[109];
    s[++i]=s[108];
    i++;
	while(a){
        s[i]=s[i]+"#.";
        a--;
        if(s[i].length()==98){
            i+=2;
            s[i-1]=s[108];
        }
    }
	for(int j=s[i].length();j<98;j++)s[i]+=".";
	s[++i]=s[108];
    printf("%d %d\n",i+1,98);
    for(int j=0;j<=i;j++)cout<<s[j]<<endl;
}
/*
..........
..........
..........
..........
..........
..........
..........
..........
..........
..........
*/


Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,T = MI()
	max_T = -1
	dish = []
	for i in range(N):
		A,B = MI()
		dish.append([A,B])
		dish.sort(key=lambda x : x[0])
		max_T = max(max_T, A)

	dp=np.array([-1 for _ in range(T+max_T)])
	dp[0] = 0
	upper = 1
	for i in range(N):
		ch = (dp>=0)
		ch[T:] = False
		ch2 = np.roll(ch, dish[i][0])
		ch2[:dish[i][0]]=False
		dp[ch2] = np.maximum(dp[ch2] , dp[ch] + dish[i][1])
	print(max(dp))
main()

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

typedef complex<double> P;

int main() {
    int N;
    while (cin >> N, N != -1) {
        P p = P(1., 1.);
        for (int i = 2; i < N; i++) {
            P e = p / abs(p);
            double SIN = sin(0.5 * M_PI);
            double COS = cos(0.5 * M_PI);
            e = P(e.real() * COS - e.imag() * SIN, e.real() * SIN + e.imag() * COS);
            p += e;
        }

        cout << p.real() << endl;
        cout << p.imag() << endl;
    }

    return 0;
}

Measured memory_bytes: 3244
# from math import factorial,sqrt,ceil,gcd,pi
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
R = int(input())

ans = 2*R*3.14159265359

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 9088
n = int(input())
x = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    x[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += x[i][j] * x[j][i]
print(ans)


Measured memory_bytes: 3060
A, B, C, X, Y = map(int, input().split())

import math
saishou = math.inf

temp = 0

for i in range (0, X+1):
	temp = A*i+C*2*(X-i)
	if X-i < Y:
		if 2*C <= B:
			temp+=2*C*(Y-(X-i))
		else:
			temp+=B*(Y-(X-i))
	if saishou > temp:
		saishou = temp
                      
print(saishou)

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

int main() {
	int n;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

    int count = 0;
    for (int i = 0; i < n; i++){
        if (data.at(i) == i + 1 && i != n - 1){
            int tmp = data.at(i);
            data.at(i) = data.at(i + 1);
            data.at(i + 1) = tmp;
            count++;
        }
        else if(data.at(i) == i + 1 && i == n - 1){
            int tmp = data.at(i - 1);
            data.at(i - 1) = data.at(i);
            data.at(i) = tmp;
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int a, b;

	scanf("%d %d", &a, &b);

	if (a > b){
		printf("a > b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}
	else {
		printf("a < b\n");
	}

	return (0);
}

Measured memory_bytes: 576
from collections import deque
import heapq
H, W, M = map(int, input().split())
bomb = []
heapq.heapify(bomb)
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
  h, w = map(int, input().split())
  h -= 1
  w -= 1
  heapq.heappush(bomb, h+ w*H)
  counth[h] += 1 
  countw[w] += 1

counth = deque(counth)
countw = deque(countw)

maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = []
for k in range(H):
  h = counth.popleft()
  if h == maxh:
    index_h.append(k)
for k in range(W):
  w = countw.popleft()
  if w == maxw:
    index_w.append(k)

ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)

if lenh*lenw > M:
  ans += 1
else:
  kouho = []
  heapq.heapify(kouho)
  for i in range(lenh):
    h = index_h.pop()
    for j in range(lenw):
      w = index_w[j]
      heapq.heappush(kouho, h+ H*w)
  B = heapq.heappop(bomb)
  K = heapq.heappop(kouho)
  while True:
    if B > K:
      ans += 1
      break
    elif B == K:
      if len(kouho) == 0:
        break
      else:
        K = heapq.heappop(kouho)
    else:
      if len(bomb) == 0:
        ans += 1
        break
      else:
        B = heapq.heappop(bomb)
print(ans)



Measured memory_bytes: 160912
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int h,w,i,j,k,c,ny,nx,d[110][110]={};
  int Y[]={1,0};
  int X[]={0,1};
  char s[110][110]={};
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++)scanf("%s",s[i]);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)d[i][j]=1e9;
  }
  if(s[0][0]=='#')d[0][0]=1;
  else            d[0][0]=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      for(k=0;k<2;k++){
		ny=i+Y[k];
		nx=j+X[k];
		if(s[ny][nx]==0)continue;
		c=0;
		if(s[i][j]=='.'&&s[ny][nx]=='#')c=1;
		d[ny][nx]=MIN(d[ny][nx],d[i][j]+c);
      }
    }
  }
  printf("%d\n",d[h-1][w-1]);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(bf.readLine());
        String s = bf.readLine();
        int b = 0;
        int r = 0;
        int g = 0;
        int br = 0;
        int rg = 0;
        int gb = 0;
        long ans = 1;
        long mod = 998244353;
        for(int i=1; i<=n; i++) {
          ans *= i;
          ans %= mod;
        }

        for(int i=0; i<3*n; i++) {
          char c = s.charAt(i);
          if(c == 'B') {
            if(rg != 0) {
              ans *= rg;
              rg--;
            }
            else if(r!= 0) {
              ans *= r;
              r--;
              br++;
            }
            else if(g!= 0) {
              ans *= g;
              g--;
              gb++;
            }
            else b++;
          }
          if(c == 'G') {
            if(br != 0) {
              ans *= br;
              br--;
            }
            else if(r!= 0) {
              ans *= r;
              r--;
              rg++;
            }
            else if(b!= 0) {
              ans *= b;
              b--;
              gb++;
            }
            else g++;
          }
          if(c == 'R') {
            if(gb != 0) {
              ans *= gb;
              gb--;
            }
            else if(b!= 0) {
              ans *= b;
              b--;
              br++;
            }
            else if(g!= 0) {
              ans *= g;
              g--;
              rg++;
            }
            else r++;
          }
          ans %= mod;
        }
        out.println(ans);
        // StringTokenizer st = new StringTokenizer(bf.readLine());
        // int[] a = new int[n]; for(int i=0; i<n; i++) a[i] = Integer.parseInt(st.nextToken());
        // int n = Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }
}


Measured memory_bytes: 27660
import sys
import random
import itertools
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
r,g,b,n = map(int,input().split())
ans = 0
for i in range(n+1):
    noko = n-r*i
    if noko < 0:
        break
    for j in range(n+1):
        noko = n-r*i
        noko = noko - g*j
        if noko < 0:
            break
        if noko % b == 0:
            ans += 1
print(ans)

Measured memory_bytes: 41196
from math import sin,cos,sqrt,pi
a,b,h,m=map(int,input().split())

ta=30*h+m/2
tb=6*m

xa=a*cos(ta*pi/180)
ya=a*sin(ta*pi/180)

xb=b*cos(tb*pi/180)
yb=b*sin(tb*pi/180)

print(sqrt((xa-xb)**2+(ya-yb)**2))

Measured memory_bytes: 9512
from itertools import combinations
h,w ,k = map(int, input().split())
grid = []
for i in range(h):
    grid.append(list(input()))
ans = 0
for row in range(2**h):
    for column in range(2**w):
        grid_a =[[True for i in range(w)] for j in range(h)]
        count = 0
        for p in range(h):
            if (row >> p) & 1:
                for i in range(w):
                    grid_a[p][i] = False
        for p in range(w):
            if (column >> p) & 1:
                for i in range(h):
                    grid_a[i][p] = False
        for i in range(h):
            for j in range(w):
                if grid_a[i][j] and grid[i][j] == '#':
                    count+=1
        if count == k:
            ans += 1
print(ans)




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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector< vector<bool> > G(n, vector<bool>(n, true));
    for (int i = 0; i < n; ++i)
        G[i][i] = false;
    int a = 0, b;
    if (n % 2 == 0)
        b = n - 1;
    else
        b = n - 2;
    int kr = n * (n - 1) / 2;
    while (a < b)
    {
        G[a][b] = G[b][a] = false;
        ++a;
        --b;
        --kr;
    }
    cout << kr << endl;
    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j)
            if (G[i][j])
                cout << i + 1 << " " << j + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
def rally(x):
    avg = sum(x) // len(x)
    sumf = sumc = 0
    for i in x:
        sumf += (i - avg) * (i - avg)
        sumc += (i - avg - 1) * (i - avg - 1)
    print(min(sumf, sumc))

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    x = [int(_) for _ in in_str[1].split(' ')]
    rally(x)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n<=999){
		cout<<"ABC"<<endl;
		return 0;
	}
	if(n>999 && n<=1998){
		cout<<"ABD"<<endl;
		return 0;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
int main()
{
    char a[3],b[3];
    scanf("%s%s",&a,&b);
    if(a[0]!=b[2]||a[1]!=b[1]||a[2]!=b[0])
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double x,h;
    while (cin>>x>>h) {
        if (x==0&&h==0) {
            break;
        } else {
            double S=0.0;
            S=S+x*x;
            double H=sqrt(h*h+(x/2)*(x/2));
            S=S+(x*H/2)*4;
            printf("%.6f",S);
            cout<<endl;
        }
    }
}



Measured memory_bytes: 3228
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

bool find(string str, vector<string> v){
	for (int i = 0; i < v.size(); i++){
		if (v[i] == str) return true;
	}
	return false;
}

int main(){
	int n; cin >> n;
	vector<string> regist(n);
	for (int i = 0 ; i < n; i++){
		cin >> regist[i];
	}
	bool lock = false;

	int m; cin >> m;
	for (int i = 0; i < m; i++){
		string id; cin >> id;
		if (find(id,regist) and !lock){
			cout << "Opened by " << id << endl;
			lock = true;
		}else if (find(id,regist) and lock){
			cout << "Closed by " << id << endl;
			lock = false;
		}else if (!find(id,regist)){
			cout << "Unknown " << id << endl;
		}
	}

return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define TRACE
#ifndef TRACE
#define tcout 0 && cout
#else
#define tcout cout << "Debug: "
#endif
#define in inline
#define reg register
#define int long long
#define MAX 20030813
using namespace std;
namespace qwq{
	in void read(int &o)
	{
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			o=(o<<3)+(o<<1)+(c^48);
			c=getchar();
		}
		o*=w;
	}
	in void write(int x)
	{
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
    	putchar(x%10+48);
	}
	in int max(int x,int y)
	{
		return x>y?x:y;
	}
	in int min(int x,int y)
	{
		return x<y?x:y;
	}
}
using namespace qwq;
int N;
signed main()
{
	read(N);
	write(N*N*N);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#define ll long long
#define ar array
using namespace std;
string a, b;
int dp[3005][3005];
int arrow[3005][3005];

void print_res(int i, int j){
    if(i==0 || j==0)
        return;
    if(arrow[i][j] == 1){
        print_res(i-1,j-1);
        cout<<a[i-1];
    }
    else if(arrow[i][j]==0)
        print_res(i-1, j);
    else
        print_res(i, j-1);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin>>a>>b;
    for(int i=1; i<=a.size(); i++){
        for(int j=1; j<=b.size(); j++){
            if(a[i-1]==b[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
                arrow[i][j] = 1;
            }
            else if(dp[i-1][j]>=dp[i][j-1]){
                dp[i][j] = dp[i-1][j];
                arrow[i][j] = 0;
            }
            else{
                dp[i][j] = dp[i][j-1];
                arrow[i][j] = 2;
            }
        }
    }

    print_res(a.size(), b.size());
    cout<<endl;
}

Measured memory_bytes: 73572
#include<stdio.h>
int main()
{
    int N, K;
    scanf("%d%d", &N, &K);
    int h[100000];
    for(int i=0; i<N; i++){
            scanf("%d", &h[i]);
            }
    int br=0;
    for(int i=0; i<N; i++){
            if(h[i]>=K) br++;
            }
    printf("%d", br);
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int n,a[100005],b[100005];
int ans=0;
inline void smax(int &a,int b){b>a?a=b:0;}
inline void test(int x,int y) {
	if(x!=y) smax(ans,a[x]+b[y]);
}
int main() {
	int x,f1=0,f2=0,g1=0,g2=0;
	scanf("%d",&n);n/=2;
	for(int i=0;i<n;++i) {
		scanf("%d",&x);++a[x];
		scanf("%d",&x);++b[x];
	}
	for(int i=1;i<=100000;++i) {
		if(a[i]>a[g1]) {
			if(a[i]>=a[f1]) {
				g1=f1;f1=i;
			} else {
				g1=i;
			}
		}
		if(b[i]>b[g2]) {
			if(b[i]>=b[f2]) {
				g2=f2;f2=i;
			} else {
				g2=i;
			}
		}
	}
	test(f1,f2);
	test(f1,g2);
	test(g1,f2);
	test(g1,g2);
	printf("%d",2*n-ans);
	return 0;
}

Measured memory_bytes: 896
n,m=map(int,input().split())
al=[input() for _ in range(n)]
bl=[input() for _ in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if bl[k]!=al[i+k][j:j+m]:
                break
        else:
            print('Yes')
            exit()
else:
    print('No')


Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
#include <stack>

using namespace std;

int main() {
    string s;
    getline(cin, s);
    vector<char> SS;
    for (auto i = 0; i < s.size() - 1; i++) {
        if (s[i] == 'A') {
            SS.push_back('A');
        } else {
            if (s[i] == 'B' && s[i + 1] == 'C') {
                SS.push_back('D');
                i++;
            } else {
                if (SS.size() >= 1) { if (SS.back() != '|') SS.push_back('|'); }
            }
        }
    }

    stack<int> mys;

    SS.push_back('|');

    long long cc = 0;

    for (auto i=0; i< SS.size(); i++) {
        auto c = SS[i];
        if (c == '|') {
            auto j = i-1;
            while (! mys.empty()) {
                auto t = mys.top();
                cc += (j - t);
                mys.pop();
                j--;
            }
            continue;
        }

        if (c=='A') mys.push(i);
    }

        cout << cc << endl;
        return 0;
    }

Measured memory_bytes: 1404
#include<stdio.h>
#include<string.h>
#define LEN 100000

typedef struct {
    char name[100];
    int t;
}P;

P Q[LEN];

int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(1+tail)%LEN;
}

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

int min(int a,int b){
    if(a>b) return b;
    else return a;
}

int main(){
    int elaps=0,c;
    int i,q;
    P u;
    
    scanf("%d%d",&n,&q);
    
    for(i=1;i<=n;i++){
        scanf("%s%d",Q[i].name,&Q[i].t);
    }
    
    head=1;
    tail=n+1;
    
    while(head!=tail){
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0)enqueue(u);
        else printf("%s %d\n",u.name,elaps);
    }
    return 0;
}


Measured memory_bytes: 11924
#include <cstdio>
#include <cstring>
using namespace std;

int main(void)
{
  char ring[202], cp[101], search[101];
  scanf("%s %s", ring, search);
  strcpy(cp, ring);
  strcat(ring, cp);
  if (strstr(ring, search)) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

using i64 = int64_t;

int main(){
    int n, k;
    cin >> n >> k;
    vector<i64> a;
    for(int i=0;i<n;++i){
        i64 tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    vector<i64> cumsum(n+1);
    for(int i=1;i<=n;++i){
        cumsum[i] = cumsum[i-1] + a[i-1];
    }
    vector<i64> v;
    for(int i=0;i<n;++i){
        for(int j=i;j<n;++j){
            v.push_back(cumsum[j+1]-cumsum[i]);
        }
    }
    i64 ans = 0;
    for(i64 i=63;i>=0;--i){
        vector<i64> v2;
        for(auto e: v){
            if(e&(1ll<<i))v2.push_back(e);
        }
        if(v2.size() >= k){
            ans |= (1ll<<i);
            v = v2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6516
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>

using ll = long long;

using namespace std;

using P = pair<int, ll>;
#define fi first
#define se second


struct node {
    // nodeに書く値はx + sig*t (tはノード0のあたい)
    ll x, sig;
    bool operator==(node n) {
        return x == n.x && sig == n.sig;
    }
};

bool visited[100010] = {0};
vector<P> G[100010];
node nodes[100010];


int dfs(int i=0) {
    visited[i] = true;
    for (auto &g:G[i]) {
        if (visited[g.fi]) {
            node n = {g.se - nodes[g.fi].x, -nodes[g.fi].sig};
            if (nodes[i] == n) continue;
            if ((nodes[i].x - n.x) % 2 == 0 && nodes[i].sig * n.sig != 0 && ((nodes[i].x <= n.x && nodes[i].sig > n.sig) || (nodes[i].x >= n.x && nodes[i].sig < n.sig))) {
                fill(begin(visited), end(visited), false);
                nodes[i] = {(nodes[i].x + n.x) / 2, 0};
                return (dfs(i) ? 1 : 0);
            }
            return 0;
        }
        nodes[g.fi] = {g.se - nodes[i].x, -nodes[i].sig};
        int ret = dfs(g.fi);
        if (ret < 2) return ret;
    }
    return 2;
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i=0, u, v; i<m; i++) {
        ll s; cin >> u >> v >> s;
        u--; v--;
        G[u].push_back(P{v, s});
        G[v].push_back(P{u, s});
    }
    fill(begin(nodes), end(nodes), node{0, 1});
    ll l=1, r=999999999;
    if (dfs()) {
        for (int i=0; i<n; i++) {
            if (nodes[i].sig > 0) l = max(-nodes[i].x+1, l);
            else if (nodes[i].sig < 0) r = min(nodes[i].x-1, r);
            else if (nodes[i].x < 1) {
                cout << 0 << '\n';
                return 0;
            } else {
                l = r = 0;
            }
        }
        cout << max(0ll, r - l + 1) << '\n';
    } else {
        cout << 0 << '\n';
    }
    return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vb color(4, false);
    REP(i, N)
    {
        char S;
        cin >> S;
        if(S == 'P') color[0] = true;
        else if(S == 'W') color[1] = true;
        else if(S == 'G') color[2] = true;
        else color[3] = true;
    }
    int ans = 0;
    REP(i, 4) if(color[i]) ans++;
    if(ans == 3) cout << "Three" << endl;
    else cout << "Four" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

typedef long long ll;

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

// (a^b)%m
ll exp(ll a, ll b, ll m) {
	ll r=1;
	while(b) {
		if(b%2) r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

// a^-1 %m, any m
ll inv(ll a, ll m) {
	return exp(a, phi(m)-1, m);
}

// a^-1 %m, prime m
ll invp(ll a, ll m) {
	return exp(a, m-2, m);
}

// (a*b)%m
ll mul(ll a, ll b, ll m) {
	ll x=0, y=a%m;
	while(b>0) {
		if(b%2) x=(x+y)%m;
		y=(y*2)%m;
		b/=2;
	}
  return x%m;
}

// (a+b)%m
ll add(ll a, ll b, ll m) {
	return (a+b)%m;
}

const int mx=1e5+5;
const int mod=1e9+7;
ll fact[mx];
ll invnum[mx], num[mx];
ll mu[mx];
bool prime[mx];
vector<ll> pr;
vector<ll> memo(mx,-1);

ll combi(int n, int x, ll m) {
	ll p=fact[n], q=fact[x], r=fact[n-x];
	ll ret=p;
	ret=(ret*invp(q,m))%m;
	ret=(ret*invp(r,m))%m;
	return ret;
}

bool isprime(int n) {
	if(n==1) return false;
	for (int i=2; i*i<=n; i++)
		if(n%i==0) return false;
	return true;
}

int gcd(int a, int b) {
	if(!b) return a;
	else return gcd(b,a%b);
}

ll get_mu(int x) {
	if(x==1) return 1;
	int ct=0;
	for (auto p : pr) {
		if(p*p>x)
			break;
		if(x%p==0) {
			if(x%(p*p)==0) return 0;
			else ct++;
			x/=p;
		}
	}
	if(x>0) ct++;
	return ct%2 ? -1 : 1;
}

ll eval(ll t, ll N) {
	if(memo[t]!=-1)
		return memo[t];
	ll ret=0;
	for (int i=1; i<=t; i++) {
//cout<<"MU="<<i<<"/"<<t<<endl;
		ret=(ret+mod+mu[i]*num[t/i])%mod;
//cout<<i<<" "<<ret<<"::MU="<<mu[i]<<"::EXP="<<exp(t/i,N,mod)<<"="<<t/i<<"^"<<N<<endl;
	}
	return memo[t]=ret;
}

int main() {
	memset(prime,true,sizeof prime);
	prime[0]=prime[1]=false;
	for (int i=2; i*i<mx; i++)
		if(prime[i])
			for (int j=i; j*i<mx; j++)
				prime[i*j]=false;
	for (int i=0; i<mx; i++)
		if(prime[i])
			pr.push_back(i);

//	cout<<get_mu(195)<<endl;

	for (int i=1; i<mx; i++) {
		mu[i]=get_mu(i);
	}

/*
	cout<<mu[195]<<endl;
*/

//	for (int i=1; i<100; i++)
//		cout<<i<<" "<<mu[i]<<endl;

	ll N,K; cin>>N>>K;
	for (int i=1; i<mx; i++)
		invnum[i]=invp(i,mod), num[i]=exp(i,N,mod);
	ll ret=0;
//	ll ct=num[K];
	map<int,ll> mp2;
	for (ll i=1; i<=K; i++) {
		ll cur=eval(K/i,N);
		mp2[i]=cur;
//cout<<i<<" "<<cur<<endl;
		ret=(ret+(i*cur)%mod)%mod;
//		ct=(ct+mod-cur)%mod;
	}
/*
	map<int,ll> mp;
	for (int i=1; i<=K; i++)
		for (int j=1; j<=K; j++)
			for (int k=1; k<=K; k++) {
				mp[__gcd(i,__gcd(j,k))]++;
//				if(__gcd(i,__gcd(j,k))==1) cout<<i<<" "<<j<<" "<<k<<endl;
			}
	for (auto it : mp)
//		cout<<it.first<<" "<<it.second<<"-"<<mp2[it.first]<<"="<<it.second-mp2[it.first]<<endl;
*/
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 12848
extern crate proconio;

use proconio::*;

fn main() {
    input! {
        k: usize,
        mut s: String,
    }
    if s.len() > k {
        while s.len() > k {
            s.pop();
        }
        println!("{}...", s);
        return;
    }
    println!("{}", s);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  char ans;
  ans = S[0];
  for (int i = 1;i<K&&i<S.size(); i++) {
    if (ans != '1') break;
    ans = S[i];
    if(ans!='1')break;
  }
  cout << ans << endl;
}

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

int main(){

  int A, B, C;
  int f=0;

  cin>>A>>B>>C;

  for(int i=1;i<=B;i++){
    if(A*i%B==C){
      f=1;
      break;
    }
  }

  if(f) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,L,i,sum;
  scanf("%d %d",&N,&L);
  sum=(N*(L+L+N-1))/2;
  if(L>=0){
    printf("%d",sum-L);
  }
  else if(L<=0 && L+N-1>=0){
    printf("%d",sum);
  }
  else if((L+N-1)<0){
    printf("%d",sum-L-N+1);
  }
  return 0;
  
}

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

int main() {
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    double takahashi = ceil(c/b);
    double aoki = ceil(a/d);
    if(takahashi <= aoki){
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 3732