akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)

int pc(int x) {
  return __builtin_popcount(x);
}
int f(int x) {
  return (x == 0)?0:(f(x%pc(x))+1);
}

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  vector<int> bin(n);
  rep(i, n) bin[i] = s[i]-'0';
  rep(i, n) cnt += bin[i];

  vector<int> ans(n);
  rep(b, 2) {
    int ncnt = cnt;
    if (b == 0) ++ncnt;
    else --ncnt;
    if (ncnt <= 0) continue;

    int base = 0;
    rep(i, n) {
      base = base*2%ncnt;
      base += bin[i];
    }
    int two = 1;
    for (int i = n-1; i >= 0; --i) {
      if (bin[i] == b) {
        int nb = base;
        if (b == 0) nb = (nb+two)%ncnt;
        else nb = (nb+ncnt-two)%ncnt;
        ans[i] = f(nb)+1;
      }
      two = (two*2)%ncnt;
    }
  }
  rep(i, n) cout << ans[i] << endl;
}

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

using namespace std;

typedef long long int64;
const int mod = 1e9 + 7;

int64 N, M;
int64 dp[3001][3001][2];

int64 rec(int step, int idx, bool touch)
{
  if(step == M) return (touch);
  touch |= idx == 0 || idx == N;
  if(~dp[step][idx][touch]) return (dp[step][idx][touch]);
  int ret = 0;
  if(idx - 1 >= 0) (ret += rec(step + 1, idx, touch)) %= mod;
  if(idx + 1 <= N) (ret += rec(step + 1, idx, touch)) %= mod;
  if(idx - 1 >= 0) (ret += rec(step + 1, idx - 1, touch)) %= mod;
  if(idx + 1 <= N) (ret += rec(step + 1, idx + 1, touch)) %= mod;
  return (dp[step][idx][touch] = ret);
}


int main()
{
  memset(dp, -1, sizeof(dp));
  cin >> N >> M;
  int ret = 0;
  for(int i = 0; i <= N; i++) (ret += rec(0, i, false)) %= mod;
  cout << ret << endl;
}


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

int main() {
  int n, k; cin >> n >> k;
  int point;
  
  double p = 0.0;
  double ans = 0.0;
  
  for (int i = 1; i <= n; ++i) {
    point = i;
    p = 1.0 / n;
    while (point < k) {
      point *= 2;
      p *= 0.5;
    }
    ans += p;
  }
  
  cout << fixed << setprecision(12) << ans << endl;
  
  return 0;
}

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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

const int mod = 1e9+7;

map < pair <ll, int>, int > mm;

ll pw[65];

ll ans;

ll n;

void pre() {
    pw[0] = 1;

    for (int i = 1; i <= 60; ++i) {
        pw[i] = (pw[i - 1] * 3) % mod;
    }
}

ll calc(ll n, int pos) {
    if (pos == 0) {
        return n + 1;
    }

    if (mm.find(mp(n, pos)) != mm.end()) {
        return mm[mp(n, pos)];
    }

    ll lim = (1ll << pos) - 1;
    ll cur = 0;

    lim <<= 1;

    for (int i = 0; i <= 2; ++i) {
        ll pr = n - ((ll)i << pos);

        if (pr >= lim) {
            cur += pw[pos];
            cur %= mod;
        }
        else if (pr >= 0) {
            cur += calc(pr, pos - 1);
            cur %= mod;
        }
    }

    return mm[mp(n, pos)] = cur;
}

void solve() {
    scanf("%lld", &n);
    printf("%d", calc(n, 60));
}

int main() {
    #ifdef BThero
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // BThero

    int tt = 1;

    pre();

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    H = [int(i) for i in open(0).read().split()[1:]]
    ans = 0
    tmp = 0
    for h1, h2 in zip(H[:-1], H[1:]):
        if h1 >= h2:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    ans = max(ans, tmp)
    print(ans)
    return


main()


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

ll dp[100100];
const int mod = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a;
        cin >> a;
        dp[a] = -1;
    }
    dp[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (dp[i] == -1)
            continue;
        if (dp[i - 1] != -1)
        {
            dp[i] += dp[i - 1] % mod;
        }
        if (i > 1 && dp[i - 2] != -1)
        {
            dp[i] += dp[i - 2] % mod;
        }
    }
    // rep(i, n + 1) cout << i << " : " << dp[i] % mod << endl;
    cout << dp[n] % mod << endl;
    return 0;
}

Measured memory_bytes: 4428
#include <iostream>
using namespace std;
typedef long long ll;

const ll M = 998244353;
ll fac [300001];
ll ifac[300001];

ll powe(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    ll den = ifac[a-b]* ifac[b] % M;
    return den * fac[a] % M;
}

int main()
{
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++) fac[i+1] = fac[i]*(i+1) % M;
    for(ll i = 0; i<300000; i++) ifac[i+1] = ifac[i]*powe(i+1, M-2) % M;
    
    ll ans = 0;
    for(ll x = 0; x<=n; x++){
        if((k-a*x)%b !=0 ) continue;
        ll y = (k-a*x)/b;
        if(y<0 || y>n) continue;
        ans += comb(n, x)* comb(n, y) % M;
        ans %= M;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
#include <map>

int main(int argc, char const* argv[])
{
    int n, k;
    std::cin >> n >> k;
    //       <ball index, count>
    std::map<int, int> mm;

    for (int i = 0; i < n; ++i) {
        int tmp;
        std::cin >> tmp;

        auto count = mm.count(tmp);
        if (count == 0) {
            mm[tmp] = 1;
        }
        else {
            mm[tmp]++;
        }
    }

    std::vector<int> nums;
    for (auto& pair : mm) {
        nums.push_back(pair.second);
    }

    std::sort(nums.begin(), nums.end());
    /* nums.sort(); */
    int result = 0;
    if(k >= nums.size())
    {
        std::cout << 0 << std::endl;
        return 0;
    }

    for(int i=0; i< nums.size() - k; ++i)
    {
        result += nums[i];
    }
    std::cout << result << std::endl;
    /*
    while (k < nums.size()) {
        result += nums.front();
        nums.pop_front();
    }
    std::cout << result << std::endl;
    */
}

Measured memory_bytes: 10748
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      	int x = a % 10;
      	int y = (a % 100 - x)/10;
       	int z = a/100;
		if(x==7||y==7) {
          System.out.println("Yes");
        }
   	    else if(z==7) {
          System.out.println("Yes");
        }
   		else{
          System.out.println("No");
        }
	}
}

Measured memory_bytes: 35760
import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int count[] = new int[26];
        char abc ='a';

        while((str=br.readLine())!=null){

            for(int i=0;i<str.length();i++){
                if(Character.isLetter(str.charAt(i))){
                    count[Character.toLowerCase(str.charAt(i)) - 'a']++;
                }
            }
        }
       for(int i=0;i<26;i++){
           System.out.println(abc++ + " : " +count[i]);
    }


    }


}

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

using namespace std;


template< typename T >
struct SegmentTree
{
  const T INF;

  vector< T > seg;
  int sz;

  SegmentTree(int n) : INF(numeric_limits< T >::max())
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, INF);
  }

  T merge(T a, T b)
  {
    return (min(a, b));
  }

  void set(int k, int x)
  {
    seg[k + sz - 1] = x;
  }

  void build()
  {
    for(int k = sz - 2; k >= 0; k--) {
      seg[k] = merge(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }

  T rmq(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (INF);
    if(a <= l && r <= b) return (seg[k]);
    return (merge(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
                  rmq(a, b, 2 * k + 2, (l + r) >> 1, r)));
  }

  T rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, sz));
  }

  void update(int k, T x)
  {
    k += sz - 1;
    seg[k] = x;
    while(k > 0) {
      k = (k - 1) >> 1;
      seg[k] = merge(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }
};

int main()
{
  int N, A[200000], B[200000];

  scanf("%d", &N);
  for(int i = 0; i < N; i++) scanf("%d", &A[i]);
  for(int i = 0; i < N; i++) scanf("%d", &B[i]);
  SegmentTree< int > seg1(N), seg2(N);
  for(int i = 0; i < N; i++) seg1.set(i, A[i]);
  for(int i = 0; i < N; i++) seg2.set(i, B[i]);
  seg1.build();
  seg2.build();

  int Q;
  scanf("%d", &Q);
  bool first = false;
  vector< pair< int, int > > aa, bb, cc, dd;
  while(Q--) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    --b;
    if(a == 1) cc.emplace_back(b, seg1.rmq(b, b + 1)), seg1.update(b, c), aa.emplace_back(b, c);
    if(a == 2) dd.emplace_back(b, seg2.rmq(b, b + 1)), seg2.update(b, c), bb.emplace_back(b, c);
    if(a == 3) printf("%d\n", seg1.rmq(b, c));
    if(a == 4) printf("%d\n", seg2.rmq(b, c));
    if(a == 5) {
      if(!first) {
        for(int i = 0; i < N; i++) seg1.update(i, seg2.rmq(i, i + 1));
      } else {
        reverse(begin(cc), end(cc));
        for(auto &p : cc) seg1.update(p.first, p.second);
        for(auto &p : bb) seg1.update(p.first, p.second);
      }
      first = true;
      aa.clear();
      bb.clear();
      cc.clear();
      dd.clear();
    }
    if(a == 6) {
      if(!first) {
        for(int i = 0; i < N; i++) seg2.update(i, seg1.rmq(i, i + 1));
      } else {
        reverse(begin(dd), end(dd));
        for(auto &p : dd) seg2.update(p.first, p.second);
        for(auto &p : aa) seg2.update(p.first, p.second);
      }
      first = true;
      aa.clear();
      bb.clear();
      cc.clear();
      dd.clear();
    }
  }
}

Measured memory_bytes: 8680
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  string s; cin >> s;
  stack<ll> S1;
  stack<P> S2;
  int sum = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '\\') S1.push(i);
    else if (s[i] == '/' && !S1.empty()) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;

      while (!S2.empty() && S2.top().first > j) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<ll> ans;
  while (!S2.empty()) {
    ans.emplace_back(S2.top().second);
    S2.pop();
  }
  reverse(ans);

  outl(sum);
  cout << ans.size();
  for (int ai : ans) cout << " " << ai;
  cout << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3392
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){ 
	double x,h;
	double sum;
	while(true){
		scanf("%lf %lf",&x,&h);
		if(x==0 && h==0){
			break;
		}
		sum=pow(x,2);
		h=sqrt(pow(x/2,2)+pow(h,2));
		sum=sum+2*h*x;
		printf("%0.6lf\n",sum);
	}
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 1000000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)

using namespace std;

//ll c[MAX];




int main() {
	ll n;
	cin>>n;
	ll h[n];
	forn(i,n)	cin>>h[i];
	ll sum=0;
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int readtime(string time){
	int h,m;
	sscanf(time.c_str(),"%02d:%02d",&h,&m);
	return h*60+m;
}

int main(){
	int n,t;cin>>n>>t;
	vector<pair<string,int> > ans;
	string st,sn,at,an;
	for(int i=0;i<n;++i){
		string old_at;
		if(i){
			old_at=at;
		}
		cin>>st>>sn>>at>>an;
		if(readtime(st)-readtime(old_at)>=t){
			ans.push_back(make_pair(sn,readtime(st)-readtime(old_at)));
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();++i){
		cout<<ans[i].first<<" "<<ans[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h> 
using namespace std;
#define fastio std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(10); cout<<fixed;
#define forn(i,n) for(int i = 0; i < (int)(n); ++i)
#define for1(i,n) for(int i = 1; i <= (int)(n); ++i)
#define fore(i,l,r) for(int i = (int)(l); i <= (int)(r); ++i)
#define ford(i,n) for(int i = (int)(n)-1; i >= 0; --i)
#define cn(ar,n) for(lli i=0;i<n;i++) cin>>ar[i];
#define pb push_back
#define fi first
#define se second
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define mp make_pair
#define MOD 1000000007
typedef long long int lli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<vlli> vvlli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
lli modexp(lli x, lli y, lli mod){ lli ans=1ll; while(y>0){ if(y&1) ans = (ans*x)%mod; x = (x*x)%mod; y=y>>1; } return ans; }
lli modinv(lli x, lli mod){ return modexp(x, mod-2, mod); }
bool solve(string s){
    forn(i,s.size()){
        if(i%2==0&&(s[i]!='R'&&s[i]!='U'&&s[i]!='D'))
            return false;
        if(i%2==1&&(s[i]!='L'&&s[i]!='U'&&s[i]!='D'))
            return false;
    }
    return true;
}
int main()
{
    fastio;
    string s;cin>>s;
    if(solve(s))cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 256
s = gets.chomp                                                                                                                                                                                                                                                                 

a = s[0..1].to_i
b = s[2..3].to_i

if a == 0
  if b == 0
    puts "NA"
  elsif (1..12).member? b
    puts "YYMM"
  else
    puts "NA"
  end
elsif (1..12).member? a
  if b == 0
    puts "MMYY"
  elsif (1..12).member? b
    puts "AMBIGUOUS"
  else
    puts "MMYY"
  end
else
  if b == 0
    puts "NA"
  elsif (1..12).member? b
    puts "YYMM"
  else
    puts "NA"
  end
end

Measured memory_bytes: 3836
n=int(input())
count=0
lst=[]
while count<n:
    value=input().split()
    for i in value:
        if i.isdecimal():
            lst.append(int(i))
            continue
        lst.append(i)
    count+=1
S_lst=[]
H_lst=[]
C_lst=[]
D_lst=[]
for s in range(2*n):
    if lst[s]=='S':
        S_lst.append(lst[s])
        S_lst.append(lst[s+1])
for h in range(2*n):
    if lst[h]=='H':
        H_lst.append(lst[h])
        H_lst.append(lst[h+1])
for c in range(2*n):
    if lst[c]=='C':
        C_lst.append(lst[c])
        C_lst.append(lst[c+1])
for d in range(2*n):
    if lst[d]=='D':
        D_lst.append(lst[d])
        D_lst.append(lst[d+1])
if 1 not in S_lst:
    print('S',1)
if 2 not in S_lst:
    print('S',2)
if 3 not in S_lst:
    print('S',3)
if 4 not in S_lst:
    print('S',4)
if 5 not in S_lst:
    print('S',5)
if 6 not in S_lst:
    print('S',6)
if 7 not in S_lst:
    print('S',7)
if 8 not in S_lst:
    print('S',8)
if 9 not in S_lst:
    print('S',9)
if 10 not in S_lst:
    print('S',10)
if 11 not in S_lst:
    print('S',11)
if 12 not in S_lst:
    print('S',12)
if 13 not in S_lst:
    print('S',13)
if 1 not in H_lst:
    print('H',1)
if 2 not in H_lst:
    print('H',2)
if 3 not in H_lst:
    print('H',3)
if 4 not in H_lst:
    print('H',4)
if 5 not in H_lst:
    print('H',5)
if 6 not in H_lst:
    print('H',6)
if 7 not in H_lst:
    print('H',7)
if 8 not in H_lst:
    print('H',8)
if 9 not in H_lst:
    print('H',9)
if 10 not in H_lst:
    print('H',10)
if 11 not in H_lst:
    print('H',11)
if 12 not in H_lst:
    print('H',12)
if 13 not in H_lst:
    print('H',13)
if 1 not in C_lst:
    print('C',1)
if 2 not in C_lst:
    print('C',2)
if 3 not in C_lst:
    print('C',3)
if 4 not in C_lst:
    print('C',4)
if 5 not in C_lst:
    print('C',5)
if 6 not in C_lst:
    print('C',6)
if 7 not in C_lst:
    print('C',7)
if 8 not in C_lst:
    print('C',8)
if 9 not in C_lst:
    print('C',9)
if 10 not in C_lst:
    print('C',10)
if 11 not in C_lst:
    print('C',11)
if 12 not in C_lst:
    print('C',12)
if 13 not in C_lst:
    print('C',13)
if 1 not in D_lst:
    print('D',1)
if 2 not in D_lst:
    print('D',2)
if 3 not in D_lst:
    print('D',3)
if 4 not in D_lst:
    print('D',4)
if 5 not in D_lst:
    print('D',5)
if 6 not in D_lst:
    print('D',6)
if 7 not in D_lst:
    print('D',7)
if 8 not in D_lst:
    print('D',8)
if 9 not in D_lst:
    print('D',9)
if 10 not in D_lst:
    print('D',10)
if 11 not in D_lst:
    print('D',11)
if 12 not in D_lst:
    print('D',12)
if 13 not in D_lst:
    print('D',13)


Measured memory_bytes: 5752
/*input
211 5
31 41 59 26 53
*/
#include<bits/stdc++.h>
#define ll long long int
#define nl "\n"
using namespace std;


int main()
{
  int h,n;
  cin>>h>>n;
  vector<int>v(n);
  int sum=0;
  for(int i=0; i<n; i++)
  {
  	cin>>v[i];
  	sum+=v[i];
  }
  if(sum>=h)
  	cout<<"Yes";
  else
  	cout<<"No";

return 0;
}
	

Measured memory_bytes: 640
//g++ test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;

int X,Y;

int prize(int rank){
	switch(rank){
	case 1:
		return 300000;
		break;
	case 2:
		return 200000;
		break;
	case 3:
		return 100000;
		break;
	}
	return 0;
}

int main(){
	cin >> X >> Y;

	if(X==Y && X==1){
		cout << 300000*2+400000;
		return 0;
	}

	cout << prize(X)+prize(Y);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
struct UnionFind{
    vector<int> d;
    UnionFind(int n):d(n,-1){}
    int root(int x){//xの根を返す
        if(d[x]<0)
            return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x,int y){
        x = root(x);//xとyを連結する
        y = root(y);
        if(x==y)
            return 0;
        if((d[x]>d[y]))
            swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x){
        return -d[root(x)];
    }
};
int deg[100005];
vector<int> to[100005];//ブロックされてるやつ
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a,b);
    puts("");
  }
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n) {
    int ans = uf.size(i)-1-deg[i];//属している木の大きさ-自分-フォローしている人
    for (int u : to[i]) {//ブロックしている人が自分と同じユニオンに居ないか確認
      if (uf.same(i,u)) --ans;
    }
    printf("%d%c", ans, i==n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 6784
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int main(){
	long long s,c;
	cin >> s >> c;
	long long cnt=0;
	cnt+=min(c/2,s);
	c-=2*cnt;
	cnt+=c/4;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np
from itertools import combinations


def solve(N: int, K: int):
    if K > (N-1) * (N-2) // 2:
        print(-1)
        return
    print(N-1 + ((N-1) * (N-2) // 2 - K))
    for n in range(2, N+1):
        print(1, n)
    count = 0
    for c in combinations(range(2, N+1), 2):
        if (N-1) * (N-2) // 2 - K == count:
            return
        count += 1
        print(c[0], c[1])
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12884
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N, T, A; cin >> N>> T>>A;
    float minabs=INFI;
    int ans=0;
    for(int i=0;i<N;i++){
        int h; cin >> h;
        float tmp = T-h*0.006;
        if(minabs > abs(tmp-A)){
            minabs=abs(tmp-A); ans=i+1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import sys,math

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 = II()
	ans = float('inf')
	for i in range(1,int(math.sqrt(N))+1):
		if(N%i==0):
			j = N//i
			ans  = min(i+j, ans)
	print(ans-2)
main()

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
int main(void){
  int l,i,m=0;
  char s[100];
  scanf("%s",s);
  l=strlen(s);
  for(i=0;i<l/2;i++){
    if(s[i] == s[l-i-1]){
    }
    else{
      m=m+1;
    }
  }
  printf("%d",m);
  return 0;
}

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

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

  long double A, B;
  long long N;
  cin >> A >> B >> N;
  if((long long)B > N){
    cout << (long long)(floor(A * N / B) - A * floor(N / B)) <<endl;
  } else{
    cout << (long long)(floor(A * (B - 1) / B)) <<endl;
  }
}

Measured memory_bytes: 3800
import sys
input = sys.stdin.readline
char_list = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
def print_ans(S):
    """Test Case
    >>> print_ans("a")
    b
    """
    a = S.upper()
    for i, b in enumerate(char_list):
        if b == a:
            print(char_list[i+1].lower())
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)




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

ll a[1110];
int main() {
	ll n,m;
	cin>>n>>m;
	ll cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt+=a[i];
	}
	ll num=0;
	for(int i=0;i<n;i++){
		if(a[i]*4*m>=cnt)num++;
	}
	cout<<(num>=m?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> s = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            s.add(sc.next());
        }

        int m = sc.nextInt();
        List<String> t = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            t.add(sc.next());
        }

        long max = 0;
        Set<String> set = new HashSet<>(s);
        for (String str: set) {
            long blue = s.stream().filter(a -> a.equals(str)).count();
            long red = t.stream().filter(a -> a.equals(str)).count();
            if ((blue-red) > max) max = blue-red;
        }
        System.out.println(max);
        sc.close();
    }

}


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


int main() {
    const int MAX_N = 1e2 + 10;
    const int MAX_W = 1e5 + 10;
    int N, W;
    long long d[MAX_N][MAX_W];
    for (int j = 0; j <= W; ++j) d[0][j] = 0;
    cin >> N >> W;
    for (int i = 1; i <= N; ++i){
        int w,v;
        cin >> w >> v;
        for (int j = 0; j <= W; ++j){
            if (j-w>=0) d[i][j] = max(d[i-1][j], d[i-1][j-w]+v);
            else d[i][j] = d[i-1][j];
        }
    }
    cout << d[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N,A,B;
  cin>>N>>A>>B;
  int ans=0;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    if(a<A||a>=B)ans++;
  }
  cout<<ans<<endl;
}


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

N, M = map(int, input().split())
PY = [[] for _ in range(N + 1)]

for i in range(M):
    p, y = map(int, input().split())
    PY[p].append((y, i))

ans = []

for pre_id, info in enumerate(PY):
    info.sort()
    for i in range(len(info)):
        ans.append((info[i][1], "%06d" % pre_id, "%06d" % (i + 1)))

ans.sort()
for i, x, y in ans:
    print(str(x) + str(y))

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

using namespace std;

int n,a[105],s,s1;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s+=a[i];
    }
    sort (a+1,a+n+1);
    for (int i = n; i >= 1; i-=2)
        s1+=a[i];
    cout << 2*s1-s;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
typedef pair<int, int> pii;
const int maxn = 1000005;
vector<pii> ver, line[maxn];
vector<int> g[maxn];
int n, m, fa[maxn], cur, was[maxn], newn, dis[maxn];
int getfa(int u) {
	return fa[u] == u ? u : fa[u] = getfa(fa[u]);
}
void merge(int u, int v) {
	if (was[u] != cur) {
		was[u] = cur;
		ver.pb(pii(0, u));
		fa[u] = u;
	}
	if (was[v] != cur) {
		was[v] = cur;
		ver.pb(pii(0, v));
		fa[v] = v;
	}
	fa[getfa(u)] = getfa(v);
}
int main() {
	scanf("%d %d", &n, &m), newn = n;
	for (int u, v, w, i = 1; i <= m; i++) {
		scanf("%d %d %d", &u, &v, &w);
		line[w].pb(pii(u, v));
	}
	for (int i = 1; i <= 1000000; i++) {
		ver.clear(), ++cur;
		for (int j = 0; j < line[i].size(); j++) {
			merge(line[i][j].x, line[i][j].y);
		}
		for (int j = 0; j < ver.size(); j++) {
			ver[j].x = getfa(ver[j].y);
		}
		sort(ver.begin(), ver.end());
		for (int j = 0, k = 0; j < ver.size(); j = k) {
			++newn;
			while (k < ver.size() && ver[j].x == ver[k].x) {
				g[newn].pb(ver[k].y);
				g[ver[k++].y].pb(newn);
			}
		}
	}
	queue<int> que;
	que.push(1);
	for (int i = 2; i <= newn; i++) {
		dis[i] = -2;
	}
	dis[1] = 0;
	while (!que.empty()) {
		int u = que.front();
		que.pop();
		for (int i = 0; i < g[u].size(); i++) {
			int v = g[u][i];
			if (dis[v] == -2) {
				dis[v] = dis[u] + 1;
				que.push(v);
			}
		}
	}
	printf("%d\n", dis[n] >> 1);
	return 0;
}

Measured memory_bytes: 73984
#include <iostream>

using namespace std;

int main() {

    ios::sync_with_stdio(false);

    int n,m,k;
    cin >> n >> m >> k;

    for(int row = 0; row <= n; row++) {

        for(int col = 0; col <= m; col++) {

            if(row*(m-col) + col*(n-row) == k) {
                cout << "Yes";
                return 0;
            }

        }

    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define sii set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#define INF 1000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}


void solve()
{
  string s;
  cin>>s;
  if(s.size()==2)
  {
    if(s[0]==s[1])
    {
      cout<<"1 2";
    }
    else
    {
      cout<<"-1 -1";
    }
    return;
  }
  rep(i,0,s.size()-2)
  {
    if(s[i]==s[i+1])
    {
      cout<<i+1<<" "<<i+2;
      return;
    }
    if(s[i]==s[i+2])
    {
      cout<<i+1<<" "<<i+3;
      return;
    }
    if(s[i+1]==s[i+2])
    {
      cout<<i+2<<" "<<i+3;
      return;
    }
  }
  cout<<"-1 -1";
}


int main()
{
  fastio
  int tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3728
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;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 VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue<int>
#define PQR priority_queue<int,VE,greater<int>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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;
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;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}
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]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	string t; cin >> t;
	reverse(ALL(s)); reverse(ALL(t));
	bool ok = false;
	rep(i, s.size() - t.size() + 1) {
		bool ok2 = true;
		rep(j, t.size()) {
			if (s.at(i+j)!='?'&&s.at(i + j) != t.at(j)) {
				ok2 = false; break;
			}
		}
		if (ok2) {
			ok = true;
			rep(j, t.size()) {
				s.at(i + j) = t.at(j);
			}
			break;
		}
	}
	if(!ok)cout << "UNRESTORABLE" << endl;
	else {
		rep(i, s.size()) {
			if (s.at(i) == '?') {
				s.at(i) = 'a';
			}
		}
		reverse(ALL(s));
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    ll a, b; cin >> a >> b;
    if(b>a) swap(a, b);

    map<ll, int> m;
    for(ll i=2;i*i<=b;i++){
        while(b!=1 && b%i==0){
            if(a%i==0) m[i]++;
            b/=i;
        }
    }

    if(b!=1 && a%b==0) m[b]++;

    pr(m.size()+1);
    return 0;}

Measured memory_bytes: 3520
n = int(input())
a = list(map(int,input().split()))
suma = 0
sumb = 0
a.sort(reverse = True)
 
for i in range(len(a)):
  if i%2 == 0:
    suma += a[i]
  else:
    sumb += a[i]
    
print(suma-sumb)

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

int main() {
    int h, w;
    while (cin >> h >> w, (h or w)) {
        int d = (h*h) + (w*w);

        int ans=1e8;
        pair< int, int > hw = { 1e8, 1e8 };

        //cerr << d << endl;

        for (int ww=1; ww<150; ++ww) {
            for (int hh=1; hh<ww; ++hh) {
                if (ww == w and hh == h) continue;
                int dd = (hh*hh)+(ww*ww);

                if (dd == d and hh > h) {
                    ans = d;
                    hw = { hh, ww };
                }
                else if (d < dd and ans >= dd) {
                    if (ans == dd and hw.first > hh) {
                        ans = dd;
                        hw = { hh, ww };
                    }
                    else {
                        ans = dd;
                        hw = { hh, ww };
                    }
                }

            }
        }

        cout << hw.first << ' ' << hw.second << endl;

    }
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e5 + 5;

ll n, k, a[nax];
vector<ll> v;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> k;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
	}
	set<ll> s;
	ll node = 1;
	while(1){
		if(s.count(node)){
			break;
		}
		v.pb(node);
		s.insert(node);
		node = a[node];
	}
	s.clear();
	vector<ll> u;
	node = v[v.size() - 1];
	while(1){
		if(s.count(node)){
			break;
		}
		u.pb(node);
		s.insert(node);
		node = a[node];
	}
	if(k <= v.size() - 1){
		cout << v[k] << '\n';
	}
	else {
		k -= v.size();
		k = k % u.size();
		cout << u[(k + 1) % u.size()] << '\n';
	}
}	


Measured memory_bytes: 17884
#include<bits//stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++){
        if(a[i]==','){
            cout<<" ";
        }
        else{
            cout<<a[i];
        }
    }
    cout<<endl;
}

Measured memory_bytes: 256
function main(){
	while(1){
		var n = scan();
		if(n == 0){
			break;
		}
		var x = Array(n);
		rep(n, function(i){
			x[i] = scan();
		});
		x[-1] = 0;
		rep(n, function(i){
			x[i] += x[i - 1];
		});
		var a = -Infinity;
		rep(n, function(i){
			for(var j = i; j < n; ++j){
				a = Math.max(x[j] - x[i - 1], a);
			}
		});
		print(a);
	}
}

function rep(n, func){
	for(var i = 0; i < n; ++i){
		func(i);
	}
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input = '';
var input_index = 0;

function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}

function print(val){
	console.log(val);
}

process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.split(/\s+/);
	main();
});

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

using namespace std;

int main() {
    int i, N;
    cin >> N;
    vector<long long> A(N+2),B(N+1);
    for(int i=1;i<=N+1;i++) cin >> A[i];
    for(int i=1;i<=N;i++) cin >> B[i];
    long long killed = 0;
    
    for(i=1; i<=N; i++) {
        if(B[i] >= A[i]) {
            killed += A[i];
            B[i] -= A[i];
            A[i] = 0;
        } else {
            killed += B[i];
            A[i] -= B[i];
            B[i] = 0;
        }
        if(B[i] >= A[i+1]) {
            killed += A[i+1];
            B[i] -= A[i+1];
            A[i+1] = 0;
        } else {
            killed += B[i];
            A[i+1] -= B[i];
            B[i] = 0;
        }
    }

    cout << killed << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
using ll = long long;

int main(void) {
    ll N,A,B; cin >> N >> A >> B;
    ll x = N/(A+B);
    ll y = N%(A+B);
    ll ans = A*x;
    if(y<A) ans += y;
    else ans += A;
    cout << ans << endl;
}

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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long mod = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

template< int mod >
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
        ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }
    static int get_mod() { return mod; }
};
using mint = ModInt< mod >;



int main(void) {
    ll N;
    cin >> N;
    mint ans = mint(10).pow(N) - mint(2)*mint(9).pow(N) + mint(8).pow(N);


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





Measured memory_bytes: 3576
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()
    val q = scanner.nextInt()
    val point = IntArray(n)
    for(i in 0..q-1){
        val ans = scanner.nextInt()
        point[ans-1]++
    }
    for(i in 0..n-1){
        if(q-point[i] >= k) println("No")
        else println("Yes")
    }
}

Measured memory_bytes: 53228
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) (x).begin(),(x).end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    for(int i = 0; i < n; i++)
    {
        cin >> m[i];
    }
    int min = *min_element(all(m));
    int sum = accumulate(all(m),0);
    x-= sum;
    cout << n + x/min << endl;

    return 0;
}

Measured memory_bytes: 384
/**
 * @author ayaankhan98
 */
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <valarray>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <array>
#include <climits>
#include <limits>
#include <memory>
#include <sstream>

using namespace std;

#define gc getchar_unlocked
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ULLONG_MAX
#define dbg(x) cout << #x << "=" << x << endl
#define dbg2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
#define FIO                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define setz(x) memset(x, 0, sizeof(x))
#define seto(x) memset(x, 1, sizeof(x))
#define PI 3.1415926535897932384626

typedef int64_t ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef vector<pii> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef set<int> si;

auto ONLINE = []() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
};

void solve() {
  /// write your code here
  string s;
  cin >> s;
  int res = 0;
  int cnt = 0;
  for(int i = 0; i < s.length(); i++) {
    if (s[i] == 'R')
      cnt++;
    else {
      res = max(res, cnt);
      cnt = 0;
    }
  }
  res = max(res, cnt);
  cout << res;
}

int main() {
  FIO;
  ONLINE();
  int t = 1;
 // cin >> t;
  while (t--)
    solve();
  return 0;
}


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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;

int N;
int arr[MAXN];

int _[2 * MAXN];
int *back = _ + MAXN;

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

    cin >> N;

    for(int a = 1; a <= N; a++){
        cin >> arr[a];
    }

    int lo = 1, hi = 1e9;
    while(lo <= hi){
        ll cnt = 0;
        memset(_, 0, sizeof _);
        back[0]++;

        int before = 0;
        int mid = (lo + hi) / 2;
        for(int i = 1, cur = 0; i <= N; i++){
            if(arr[i] <= mid){
                cur++;
                before += back[cur - 1];
            } else {
                before -= back[cur - 1];
                cur--;
            }

            cnt += before;
            back[cur]++;
        }

        if(cnt > (ll)N * (N + 1) / 2 - cnt){
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }
    cout << lo;
}


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

int main() {
    string s;
    cin >> s;
    for(auto &c : s) {
        if (c == '1')
            c = '9';
        else
            c = '1';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    int n, w, d;
    while(1){
        cin >> n >> w >> d;
        if(n == 0 && w == 0 && d == 0) break;
        vector<pair<int, int> > cake;
        cake.push_back(make_pair(w, d));
        for(int i = 0; i < n; i++){
            int p, s;
            cin >> p >> s;
            pair<int, int> nowcake = cake[p - 1];
            w = nowcake.first;
            d = nowcake.second;
            if(w == 0 || d == 0) cout << i << " " << w  << " " << d << endl;
            s = s % (w + d);
            if(s < w){
                cake.push_back(make_pair(min(s, w - s), d));
                cake.push_back(make_pair(max(s, w - s), d));
            } else {
                s -= w;
                cake.push_back(make_pair(w, min(s, d - s)));
                cake.push_back(make_pair(w, max(s, d - s)));
            }
            cake.erase(cake.begin() + p - 1);
        }
        vector<int> result;
        for(int i = 0; i < cake.size(); i++){
            result.push_back(cake[i].first * cake[i].second);
        }
        sort(result.begin(), result.end());
        for(int i = 0; i < result.size(); i++){
            if(i != 0) cout << " ";
            cout << result[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1220