akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    lli a, b, k;
    cin >> a >> b >> k;
    if(k > a){
        cout << 0 << endl;
        cout << max<lli>(b+a-k, 0) << endl;
    }else{
        cout << a-k << endl;
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

	int n,cnt=0;	cin >> n;

	for(int i=1;i<=n;i++){

		int k=n/i;

		for(int j=1;j<=k;j++){

			int c=n-i*j;

			if(c>0) cnt++;

		}

	}

	cout << cnt << '\n';	

	return 0;

}

Measured memory_bytes: 3628
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;

template<class T> bool chmin(T &a, T b) { return a>b?(a=b,true):false; }
template<class T> bool chmax(T &a,T  b) { return a<b?(a=b,true):false; }
#define forn(i,x,y) for(int i=(x);i<(int)(y);i++)
#define rep(i,y) for(int i=0;i<(int)(y);i++)
#define repb(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)

template<int M, bool IsPrime = false>
class Modulo {
  using ll = long long;
  int n;
  static enable_if_t<IsPrime, ll> inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
  }
public:
  Modulo () : n(0) {;}
  Modulo (int m) : n(m) {
    if (n >= M) n %= M;
    else if (n < 0) n = (n % M + M) % M;
  }
  Modulo (ll m) {
    if (m >= M) m %= M;
    else if (m < 0) m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo operator+=(const Modulo &a) { n += a.n; if (n >= M) n -= M; return *this; }
  Modulo operator-=(const Modulo &a) { n -= a.n; if (n < 0) n += M; return *this; }
  Modulo operator*=(const Modulo &a) { n = (ll(n) * a.n) % M; return *this; }
  Modulo operator+(const Modulo &a) const { Modulo res = *this; return res += a; }
  Modulo operator-(const Modulo &a) const { Modulo res = *this; return res -= a; }
  Modulo operator*(const Modulo &a) const { Modulo res = *this; return res *= a; }
  Modulo operator^(int n) const {
    if (n == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (n / 2);
    return n % 2 ? res * a : res;
  }
  enable_if_t<IsPrime, Modulo> operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
};

const int mod = 1000000007;
template<int M = mod> Modulo<M, true> fact(int n, bool sw = true) {
   static vector<Modulo<M, true>> v1 = {1}, v2 = {1};
   if (n >= (int)v1.size()) {
     const int from = v1.size(), to = n + 1024;
     v1.reserve(to);
     v2.reserve(to);
     for (int i = from; i < to; ++i) {
       v1.push_back(v1.back() * Modulo<M, true>(i));
       v2.push_back(v2.back() / Modulo<M, true>(i));
     }
   }
   return sw ? v1[n] : v2[n];
 }

 template<int M = mod> Modulo<M, true> comb(int a, int b) {
   if (b < 0 || b > a) return 0;
   return fact<M>(a, true) * fact<M>(b, false) * fact<M>(a-b, false);
 }


using Mod = Modulo<mod, true>;

int main() {
    int S; cin >> S;
    Mod ans(0);
    int th = S/3;
    for (int i=1;i<=th; i++) {
        ans += comb(S - 3*i + (i-1), i-1);
    }
    cout << (int)ans << endl;
}

Measured memory_bytes: 3104
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=rdsp;foreach(ref j;v.tupleof)pick(r,j);}}

void main()
{
  int n, m; readV(n, m);
  int[] a; readA(n, a);
  struct D { int b, c; }
  D[] d; readS(m, d);

  a.sort();
  d.sort!"a.c>b.c";

  auto i = size_t(0), s = 0L;
  foreach (di; d) {
    auto e = min(di.b, a[i..$].assumeSorted.lowerBound(di.c).length);
    i += e;
    s += cast(long)di.c * e;
  }

  writeln(s + a[i..$].to!(long[]).sum);
}


Measured memory_bytes: 5428
fun main(args: Array<String>) {
  val (n, k) = readLine()!!.split(" ").map { it.toInt() }
  val aList = readLine()!!.split(" ").map { it.toInt() }
  val g = aList.groupBy { it }
  val p = g.map { it.key to it.value.count() }.sortedBy { it.second }
  val cnt = p.size - k
  if (cnt < 1) {
    println(0)
    return
  }
  var ans = 0
  for (i in 0 until cnt) {
    ans += p[i].second
  }
  println(ans)
}


Measured memory_bytes: 96576
//need to rotate randomly, but it didn't.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;

int n;
P p[500000];

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	
	int ans = 1145141919;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			int x = p[i].first - p[j].first;
			int y = p[i].second - p[j].second;
			
			if (x * x >= ans) { break; }
			ans = min(ans, x * x + y * y);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6988
import sys

input = sys.stdin.readline
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]
common_l, common_r = 0, N
for l, r in LR:
    common_l = max(l, common_l)
    common_r = min(r, common_r)
print(max(0, common_r-common_l+1))


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



int main(){
  int N, A, B;
  int count = 0;
  int sum = 0;
  int trueSum = 0;
  bool flags = false;
  cin >> N;
  cin >> A;
  cin >> B;
  
  for(int i = 1; i <= N; i++){
    
    if(i < 10){
      if(A <= i && i <= B)flags = true;
    }
    else if(10 <= i && i < 100){
		sum = (i % 10) + (i % 100) / 10;
      	if(A <= sum && sum <= B)flags = true;
    }
	else if(100 <= i && i < 1000){
		sum = (i % 10) + (i % 100) / 10 + (i % 1000) / 100;
    	if(A <= sum && sum <= B)flags = true;
    }
    else if(1000 <= i && i < 10000){
		sum = (i % 10) + (i % 100) / 10 + (i % 1000) / 100 + (i % 10000) / 1000; 
      if(A <= sum && sum <= B)flags = true;
    }
    else if(10000 <= i){
		sum = (i % 10) + (i % 100) / 10 + (i % 1000) / 100 + (i % 10000) / 1000 + (i % 100000) / 10000;
      if(A <= sum && sum <= B)flags = true;
    }
    if(flags){
    	trueSum += i;
        flags = false;
    }
  }
  cout << trueSum << endl;
  
  return 0;
}

Measured memory_bytes: 256
/*
2017_05_04
????????°????????????????????????
?????????????????????????????????????????????????????????????????????
???find, erase ?????????
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

string S;
string x[] = {"A","B","C"};
char cx[] = {'A','B','C'};

int main() {
  cin>>S;
  while(1){
    //cout<<"S: "<<S<<endl;
    if(S=="ABC"){
      cout<<"Yes"<<endl;
      return 0;
    }
    if(S.size() < 5) break;
    int i = 1;
    if(S.substr(0,3)=="ABC") i=0;
    else if(S.substr(S.size()-3,3)=="ABC") i=2;
    int cnt = 0;
    REP(pos,0,S.size()-2){
      if(S.substr(pos,3)=="ABC"){
        S.replace(pos,3,x[i]);
        cnt++;
      }
    }
    if(cnt==0 || cnt!=count(S.begin(),S.end(),cx[i])) break;
  }
  cout<<"No"<<endl;

  return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){
    //AC:0,WA:1.TLE:2,RE:3
    vector<int> ans(4,0);
    ll N;
    cin >> N;
    REP(i,N){
        string str;
        cin >> str;
        if(str == "AC") ans[0]++;
        else if(str == "WA") ans[1]++;
        else if(str == "TLE") ans[2]++;
        else ans[3]++;
    }
    cout << "AC " << "x " << ans[0] << endl;
    cout << "WA " << "x " << ans[1] << endl;
    cout << "TLE " << "x " << ans[2] << endl;
    cout << "RE " << "x " << ans[3] << endl;
    return 0;
}


Measured memory_bytes: 3624
#include "iostream"
#include "algorithm"
#include "string"

using namespace std;

long long int N, M, K, L, R, H, W;

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

	cin >> N >> M >> K;
	if (N <= K && K <= N + M) {
		cout << "YES\n";
		return 0;
	}
	cout << "NO\n";
	return 0;
}

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

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

	if(s[0]=='R'){
		if(s[1]=='R'){
			if(s[2]=='R') cout << 3<< endl;
			else cout << 2 << endl;
		}else{
			cout << 1 << endl;
		}
	}else{
		if(s[1]=='R'){
			if(s[2]=='R'){
				cout << 2 << endl;
			}else{
				cout << 1 << endl;
			}
		}else{
			if(s[2]=='R'){
				cout << 1 << endl;
			}else{
				cout << 0 << endl;
			}
		}
	}

}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
double util(vector<double>& p, int i, int n, int heads, vector<vector<double>>& dp){
    if(i == n){
        if(heads > n/2) return 1;
        else return 0;
    }
    if(dp[i][heads] != -1) return dp[i][heads];
    double res = p[i]*util(p, i + 1, n, heads + 1, dp) + (1 - p[i])*util(p, i + 1, n, heads, dp);
    dp[i][heads] = res;
    return res;
}
int main() {
	int n;
	cin>>n;
	vector<double> p(n);
	for(int i = 0;i<n;i++){
	    cin>>p[i];
	}
	vector<vector<double>> dp(n, vector<double>(n, -1));
	cout<<fixed<<setprecision(10)<<util(p, 0, n, 0, dp);
	return 0;
}

Measured memory_bytes: 70912
#include<stdio.h>
int main(){
    int n,b,f,r,v,A[3][10],B[3][10],C[3][10],D[3][10],i,j;
    for(i=0;i<3;i++){
        for(j=0;j<10;j++){
            A[i][j]=0;
            B[i][j]=0;
            C[i][j]=0;
            D[i][j]=0;
        }
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        if(b==1){
            A[f-1][r-1]=v + A[f-1][r-1];
        }else if(b==2){
            B[f-1][r-1]=v + B[f-1][r-1];
        }else if(b==3){
            C[f-1][r-1]=v + C[f-1][r-1];
        }else if(b==4){
            D[f-1][r-1]=v + D[f-1][r-1];
        }
    }
    for(i=0;i<3;i++){
        for(j=0;j<10;j++){
            printf(" %d",A[i][j]);
            if(j==9){
                printf("\n");
           }
        }
    }
    printf("####################\n");
    for(i=0;i<3;i++){
        for(j=0;j<10;j++){
            printf(" %d",B[i][j]);
            if(j==9){
                printf("\n");
            }
        }
    }
    printf("####################\n");
    for(i=0;i<3;i++){
        for(j=0;j<10;j++){
            printf(" %d",C[i][j]);
            if(j==9){
                printf("\n");
            }
        }
    }
    printf("####################\n");
    for(i=0;i<3;i++){
        for(j=0;j<10;j++){
            printf(" %d",D[i][j]);
            if(j==9){
                printf("\n");
            }
        }
    }
}

Measured memory_bytes: 1780
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	int d = in();
	cout << (d == 25 ? "Christmas" : d == 24 ? "Christmas Eve" : d == 23 ? "Christmas Eve Eve" : "Christmas Eve Eve Eve") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] ar = new long[N];
        long[] dp = new long[N];
        long ans = 0;
        for (int i = 0; i < N; i++) {
            ar[i] = sc.nextLong();
            if (i == 0) {
                dp[i] = ar[i];
            } else {
                dp[i] = dp[i-1]+ar[i];
            }            
        }
        for (int i = 0; i < N-1; i++) {
            ans += ar[i]*((dp[N-1]-dp[i])%1000000007);
            ans = ans%1000000007;
        }
        System.out.println(ans);
    }
}


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

int main(){

    int n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    ll sum = 0;
    for (int i=0; i<n+1; i++){
        cin >> a.at(i);
        sum += a.at(i);
    }
    for (int i=0; i<n; i++){
        cin >> b.at(i);
    }

    for (int i=0; i<n; i++){
        ll temp = a.at(i) - b.at(i);
        if (temp <= 0LL){
            a.at(i) = 0LL;
            a.at(i+1)  = max(0LL, a.at(i+1)+temp);
        }
        else{
            a.at(i) = temp;
        }
    }

    ll diff = 0LL;
    for (int i=0; i<n+1; i++){
        diff += a.at(i);
    }

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

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

int main(){
  int A,B;
  cin >> A >> B;
  if(A <= B){
    cout << "0" << endl;
  }
  else if((A - B * 2) <= 0){
    cout << "0" << endl;
  }
  else{
    cout << A - B * 2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            
            ans += b - a + 1;
        }
        
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 25676
/*input
5
11 1 2 4 8
11 1 2 2 8
32 10 8 5 4
29384293847243 454353412 332423423 934923490 1
900000000000000000 332423423 454353412 934923490 987654321
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    ll res=0LL;
    while(b){
        if(b&1) res=(res+a)%MOD;
        a=(a+a)%MOD;
        b>>=1;
    }
    return res%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll a,b,c,d;
map<ll,ll> mp;
ll rec(ll n){
    if(n==0){
        return 0;
    }
    if(n==1){
        return d;
    }
    if(mp.count(n)){
        return mp[n];
    }
    ll ans=INF64;
    if(n<ans/d) ans=n*d;
    MNTO(ans,rec(n/2)+a+(n%2)*d);
    MNTO(ans,rec(n/3)+b+(n%3)*d);
    MNTO(ans,rec(n/5)+c+(n%5)*d);
    MNTO(ans,rec((n+4)/5)+c+(5-n%5)*d);
    MNTO(ans,rec((n+2)/3)+b+(3-n%3)*d);
    MNTO(ans,rec((n+1)/2)+a+(2-n%2)*d);
    return mp[n]=ans;
}
void solve(){
    mp.clear();
    ll n;
    cin>>n>>a>>b>>c>>d;
    cout<<rec(n)<<'\n';
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int t;
    cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 4380
import java.util.*;

public class Main {

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

  private void exec() {
    Scanner scan = new Scanner(System.in);
    int x = scan.nextInt();
    int y = scan.nextInt();
    int z = scan.nextInt();

    int count = 0;
    int width = 0;
    
    while (true) {
      width = (count + 1) * z + count * y;
      if (width == x) {
        break;
      }
      if (width > x) {
        count--;
        break;
      }
      count++;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 22996
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll A,B,C;
    int N,M,K,X,Y,W,H;
    ll ans;
    string S;
    int temp[100]={0};
    bool f=false;
    bool fir=true;

int main(){
    cin>>A>>B>>C;
    (A*100+B*10+C)%4==0?cout<<"YES":cout<<"NO";


    return 0;

}


Measured memory_bytes: 256
#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(){
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    if (a%3==0||b%3==0||c%3==0)
    {
        /* code */
        cout<<"Possible"<<endl;
    }
    else
    {
        cout<<"Impossible"<<endl;
    }
    
    
}


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

using namespace std;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;

#define pb push_back


#define nline "\n"
typedef long long ll;
typedef long double ld;

int INF = 1e9;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vi arr;
	for(int i=0;i<n;++i){
		int a;
		cin>>a;
		arr.pb(a);
	}
	vi dp;
	dp.assign(n,1e9);
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(int i=2;i<n;++i)
		dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]),dp[i-2] + abs(arr[i]-arr[i-2]));
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1144
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    N, M, K = [int(x) for x in input().split()]

    u = UnionFind(N)
    ans1 = [0] * N
    for _ in range(M):
        a, b = [int(x) for x in input().split()]
        ans1[a - 1] += 1
        ans1[b - 1] += 1
        u.union(a - 1, b - 1)

    ans2 = [0] * N
    for _ in range(K):
        a, b = [int(x) for x in input().split()]
        if u.same(a - 1, b - 1):
            ans2[a - 1] += 1
            ans2[b - 1] += 1

    for i in range(N):
        # friblo[i].add(i)
        # print(u.members(i))
        # print(friblo[i])
        # print(len(set(u.members(i)) - friblo[i]), end=" ")
        print(u.size(i) - ans1[i] - ans2[i] - 1, end=" ")


if __name__ == '__main__':
    main()


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

constexpr long long INF = 10000000007LL;
int N, W;
long long dp[100005];

int main() {
    cin >> N >> W;

    dp[0] = 0LL;
    for (int x = 1; x <= 100*1000; ++x)
        dp[x] = INF;

    int w, v;
    for (int i = 1; i <= N; ++i) {
        cin >> w >> v;
        for (int x = 100*1000; x >= 0; --x) {
            if (x - v >= 0)
                dp[x] = min(dp[x], dp[x - v] + w);
        }
    }

    long long ans = 0LL;
    for (int x = 0; x <= 100*1000; ++x) {
        if (dp[x] <= W)
            ans = x;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,start,end) for(int i=start; i<=end; i++)
#define repd(i,start,end) for(int i=start; i>=end; i--)
#define pb push_back
#define mod 1e9+7
#define all(x) x.begin(),x.end()
int check(string str) 
{ 
    int n = str.length(); 
    int digitSum = 0; 
    for (int i=0; i<n; i++) 
        digitSum += (str[i]-'0'); 
    return (digitSum % 9 == 0); 
} 
void solve() {
	string str;
	cin>>str;
	check(str)?  cout << "Yes" : cout << "No "; 
    
}

int main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0); cin.tie(0); 
	cout<<fixed;
	cout<<setprecision(10);
	 {
		solve();
	}
}


Measured memory_bytes: 3680
// Build Stairs.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

#define ll long long 

const int N = 1e5;
int arr[N];

int main()
{
	int n;

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

	for (int i = n - 1; i >= 1; i--) {
		if (arr[i] < arr[i - 1]) {
			if (arr[i - 1] - arr[i] > 1) {
				cout << "No";
				return 0;
			}
			else if(arr[i - 1] - arr[i] == 1)
				arr[i - 1]--;
		}
	}
	cout << "Yes";


}


Measured memory_bytes: 640
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vvi vector<vector<int>>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007 //10e9+7
    #define INF 0x7FFFFFFF //オーバーフローに注意
    #define ALL(v) v.begin(), v.end()
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
     
    using namespace std;
     
    int gcd(int a,int b){return b?gcd(b,a%b):a;}
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
     
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int N,M,L,Q;
      cin>>N>>M>>L;
      vector<vector<int>> G(N, vector<int>(N, INF));
      vector<vector<int>> d(N,vector<int>(N, MOD));
      REP(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a][b]=c;
        G[b][a]=c;
        d[a][b]=c;
        d[b][a]=c;
      }
      
      //距離でワーシャルフロイド
      for (int i = 0; i < N; i++){      // 経由する頂点
        for (int j = 0; j < N; j++){    // 開始頂点
          for (int k = 0; k < N; k++){  // 終端
            d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
          }
        }
      }
     
      //距離L以下の都市間に重み1の辺を張る
      vector<vector<int>> d2(N,vector<int>(N, MOD));
      REP2(i,1,N)REP(j,i){
        if(d[i][j]<=L){
          d2[j][i]=1;
          d2[i][j]=1;
        }
      }
      for (int i = 0; i < N; i++){      // 経由する頂点
        for (int j = 0; j < N; j++){    // 開始頂点
          for (int k = 0; k < N; k++){  // 終端
            d2[j][k] = min(d2[j][k], d2[j][i] + d2[i][k]);
          }
        }
      }
      //クエリ読み込み
      cin>>Q;
      int s,t;
      REP(i,Q){
        cin>>s>>t;
        if(d2[s-1][t-1]==MOD){
          cout<<"-1"<<endl;
        }else{
          cout<<d2[s-1][t-1]-1<<endl;
        }
      }
      return 0;
    }

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

#define dv(i) for (int c=0; c<(int)(i).size(); c++) cout<<(i)[c]<<(c==(int)(i).size()-1?"\n":" ")
#define dm(i) for (auto f: i) cout<<f.first<<" "<<f.second<<"\n"
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define alp(i) (i),(i)+sizeof((i))/sizeof((i)[0])

const int MOD = 1000000007;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int A,B; cin>>A>>B;
    if (A<=8&&B<=8) cout<<"Yay!\n";
    else cout<<":(\n";
    return 0;
}

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

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        long[] x = new long[n];
        long[] y = new long[n];
        long[] z = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = scanner.nextLong();
            y[i] = scanner.nextLong();
            z[i] = scanner.nextLong();
        }

        long sum1 = IntStream.range(0, n).mapToLong(i -> x[i] + y[i] + z[i]).sorted().skip(n - m).sum();
        long sum2 = IntStream.range(0, n).mapToLong(i -> x[i] + y[i] - z[i]).sorted().skip(n - m).sum();
        long sum3 = IntStream.range(0, n).mapToLong(i -> x[i] - y[i] + z[i]).sorted().skip(n - m).sum();
        long sum4 = IntStream.range(0, n).mapToLong(i -> x[i] - y[i] - z[i]).sorted().skip(n - m).sum();
        long sum5 = IntStream.range(0, n).mapToLong(i -> -x[i] + y[i] + z[i]).sorted().skip(n - m).sum();
        long sum6 = IntStream.range(0, n).mapToLong(i -> -x[i] + y[i] - z[i]).sorted().skip(n - m).sum();
        long sum7 = IntStream.range(0, n).mapToLong(i -> -x[i] - y[i] + z[i]).sorted().skip(n - m).sum();
        long sum8 = IntStream.range(0, n).mapToLong(i -> -x[i] - y[i] - z[i]).sorted().skip(n - m).sum();

        System.out.println(Math.max(sum1, Math.max(sum2, Math.max(sum3, Math.max(sum4, Math.max(sum5, Math.max(sum6, Math.max(sum7, sum8))))))));
    }
}

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

auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; };

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (auto&& e : s) {
    cin >> e;
  }
  vector<vector<int>> dp(h, vector<int>(w, 1e9));
  dp[h - 1][w - 1] = s[h - 1][w - 1] == '#';
  for (int i = h; i--; ) {
    for (int j = w; j--; ) {
      if (i + 1 < h) {
        if (s[i][j] == '.') {
          chmin(dp[i][j], dp[i + 1][j]);
        } else {
          if (s[i + 1][j] == '.') {
            chmin(dp[i][j], dp[i + 1][j] + 1);
          } else {
            chmin(dp[i][j], dp[i + 1][j]);
          }
        }
      }
      if (j + 1 < w) {
        if (s[i][j] == '.') {
          chmin(dp[i][j], dp[i][j + 1]);
        } else {
          if (s[i][j + 1] == '.') {
            chmin(dp[i][j], dp[i][j + 1] + 1);
          } else {
            chmin(dp[i][j], dp[i][j + 1]);
          }
        }
      }
    }
  }
  cout << dp[0][0] << '\n';
}


Measured memory_bytes: 384
S=input()
t= [str(c) for c in S]
flag=0
#S の先頭の文字は大文字の A である。
if t[0]!="A":
    flag=1
b=0
i=0
#S の先頭から 3 文字目と末尾から 2 文字目の間（両端含む）に大文字の C がちょうど 1 個含まれる。
for i in range(2,len(t)-1):
    if t[i]=="C":
        b += 1
if b!=1:
    flag=1
#以上の A, C を除く S のすべての文字は小文字である。
i=0
for i in range(len(t)):
    if t[i]=="A" or t[i]=="C" :
        continue
    elif ord(t[i])>90:
        continue
    else:
        flag=1
        break

if flag==0:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;cin>>n;
    double p[n];
    rep(i,n) cin>>p[i];

    // double dp[index][kosu]
    double dp[n+1][n+1];
    rep(i,n+1) dp[0][i] = 0;
    dp[0][0] = 1;
    REP(i,1,n+1) rep(j,n+1)
    {
        if (j==0)
        {
            dp[i][0] = dp[i-1][0]*(1-p[i-1]);
            continue;
        }
        dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1];
    }
    double ans = 0;
    cout << fixed << setprecision(10);
    REP(i, n/2+1, n+1)
    {
        ans += dp[n][i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 70656
#include<iostream>
using namespace std;
const int N = 1e5+5;
int ord[N];
int n,a;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		ord[a]=i;
	}
	for(int i=1;i<=n;i++)printf("%d ",ord[i]);
	return 0;
 } 

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  vector <char> s(n);
  for(int i = 0; i < n; i++) {
    cin >> s[i];
  }

  for(int i = 0; i < n; i++) {
    if(s[i] == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }

  cout << "Three" << endl;
}

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


int main(){
	int N,M,X,Y;
	cin>>N>>M>>X>>Y;
	vector<int> x,y;
	x.push_back(X);
	y.push_back(Y);
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		x.push_back(a);
	}
	
	for(int i=0;i<M;i++){
		int a;
		cin>>a;
		y.push_back(a);
	}
	sort(x.begin(),x.end(),greater<int>());
	sort(y.begin(),y.end());
	
	if(x[0]<y[0]){
		cout<<"No War"<<endl;
	}
	else{
		cout<<"War"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=100000;
int main(){
  int n;
  int limit;
  cin>>n>>limit;
  
  int minimum=INF;
  for(int i=0;i<n;i++){
    int c,t;
    cin>>c>>t;
    if(t<=limit){
      minimum=min(minimum,c);
    }
  }
  if(minimum==INF){
    cout<<"TLE"<<endl;
  }else{
    cout<<minimum<<endl;
  }
  return(0);
}

Measured memory_bytes: 256
/*
Author:loceaner
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

const int A = 1e5 + 11;
const int B = 1e6 + 11;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  for ( ; !isdigit(c); c = getchar()) if (c == '-') f = -1;
  for ( ; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
  return x * f;
}

int n, m, ans, x, y;

signed main() {
	n = read(), m = read();
	for (int i = 1; i <= n; i++) {
		int x = read(), y = read();
		if (sqrt(x * x + y * y) <= m) ans++;
	}
	cout << ans << '\n';
}

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

int main(void){
  int num[] = {0,1,2,3,5,7,8,9};
  int n;
  while(cin>>n,n){
    long long a=0,d=1;
    
    
    while(n){
      a+=num[n%8]*d;
      d*=10;
      n/=8;
    }
    cout<<a<<endl;
    
  }
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

const long long mod = pow(10, 9) + 7;

int main() {
	int X, Y,ans=0;
	cin >> X >> Y;
	if (X == 3 || Y == 3) {
		ans += 100000;
		if (X == Y)ans *= 2;
	}
	if (X == 2 || Y == 2) {
		ans += 200000;
		if (X == Y)ans *= 2;
	}
	if (X == 1 || Y == 1) {
		ans += 300000;
		if (X == Y) {
			ans *= 2;
			ans += 400000;
		}
	}
	cout << ans << endl;
}





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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;

void init(){

}

void solve(){
    int n;
    double ans = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        int p; scanf("%d", &p);
        ans += double(1)/p;
    }
    printf("%.10f\n", double(1)/ans);
}

int main(){
    int test_cases_number = 1;
//    scanf("%d", &test_cases_number);
//    ios_base::sync_with_stdio(0);
//    cin.tie(0); cout.tie(0);
//    cin >> test_cases_number;
    for(int i = 0; i < test_cases_number; i++)
        solve();
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w;cin>>h>>w;
    char maze[h][w];
    rep(i,h) rep(j,w) cin >> maze[i][j];
    ll keiro[h][w];
    rep(i,h) rep(j,w) keiro[i][j] = 0;
    keiro[0][0] = 1;

    rep(i,h) rep(j,w)
    {
        if (maze[i][j]=='#')
        {
            keiro[i][j] = 0;
            continue;
        }

        if (i==0 && j==0) continue;
        if (i==0)
        {
            keiro[i][j] = keiro[i][j-1];
            continue;
        }
        if (j==0)
        {
            keiro[i][j] = keiro[i-1][j];
            continue;
        }

        keiro[i][j] = keiro[i-1][j] + keiro[i][j-1];
        keiro[i][j] %= mod;
    }
    cout << keiro[h-1][w-1] << endl;

}


Measured memory_bytes: 9088
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = res * x%mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
bool usededge[200][200];
ll x[200], y[200];
bool online(int i, int j, int k) {
	if ((x[j] - x[i])*(y[k] - y[i]) - (x[k] - x[i])*(y[j] - y[i]))return false;
	else return true;
}
int main(){
	ll n; cin >> n;
	ll out = mod_pow(2, n);
	out = ((out - 1 - n - n * (n - 1) / 2) % mod + mod) % mod;
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	rep(i, n) {
		Rep(j,i+1, n) {
			if (usededge[i][j])continue;
			ll cnt = 2;
			vector<int> v; v.push_back(i); v.push_back(j);
			Rep(k, j + 1, n) {
				if (usededge[i][k])continue;
				if (online(i, j, k)) {
					rep(l, (int)v.size()) {
						usededge[v[l]][k] = true;
					}
					v.push_back(k);
					cnt++;
				}
			}
			out = ((out - mod_pow(2, cnt) + 1 + cnt + cnt * (cnt - 1) / 2) % mod + mod) % mod;
		}
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int n,k;
int a[101];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i++){
	 int tmp=min(a[i],k-a[i]);
	 ans+=tmp;
}
	cout<<ans*2;
		return 0;
}


Measured memory_bytes: 256
import collections
n=int(input())
a=list(map(int,input().split()))
c = collections.Counter(a)
b=[0,0]
d=[0,0]
for i in c:
    if c[i]>=4:
        b.append(i)
    elif c[i]>=2:
        d.append(i)
b.sort(reverse=True)
d.sort(reverse=True)
if b[0]>d[0]:
    print(b[0]*b[0])
elif b[0]<d[1]:
    print(d[0]*d[1])
else:
    print(b[0]*d[0])


Measured memory_bytes: 22040
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        if(a >=3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans * i % mod;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans * modinv(i, mod) % mod;
    }
    return ans;
}

int main() {
    ll X, Y;
    cin >> X >> Y;
    ll ans;
    if((X + Y) % 3 != 0){
        ans = 0;
    } else {
        ll A, B, N;
        
        A = (2 * Y - X) / 3;
        B = (2 * X - Y) / 3;
        if(A < 0 || B < 0){
            ans = 0;
        } else {
            N = A + B;
            ans = nCr(N, min(A, B));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int siz,time;
	string name;
	while(true){
		cin>>name;
		if(name[0]=='-')break;
		cin>>time;
		for(int abc=0;abc<time;abc++){
			cin>>siz;
			name=name.substr(siz)+name.substr(0,siz);
		}
		cout<<name<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<ll> R[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,f,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005];
char s[500005];
char t[500005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    cin >> s >> t;
    for(ll i=0;i<n;i++){
        pu(s[i]);pu(t[i]);
    }
    el;
    return 0;
}















Measured memory_bytes: 39424
#include<stdio.h>
int main(void){
	int cards[4][13] = {};
	int b,i,j,n;
	char a;
	scanf("%d",&n);

	for(i = 0;i < n;i++){
		scanf(" %c%d",&a,&b);
		if(a == 'S'){
			cards[0][b-1]=1;
		}
		else if(a == 'H'){
			cards[1][b-1]=1;
		}
		else if(a == 'C'){
			cards[2][b-1]=1;
		}
		else{
			cards[3][b-1]=1;
		}
	}

	for(i = 0;i < 4;i++){
		for(j = 0;j < 13;j++){
			if(cards[i][j] != 1){
				if(i == 0){
					printf("S %d\n",j + 1);
				}
				else if(i == 1){
					printf("H %d\n",j + 1);
				}
				else if(i == 2){
					printf("C %d\n",j + 1);
				}
				else{
					printf("D %d\n",j + 1);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main(){
    string s;
    int now,last;
    bool found;
    while(getline(cin,s)){
        found=false;
        for(int i=0;i<26;i++){
            for(int j=0;j<s.size();j++)if('a'<=s[j]&&s[j]<='z'){
                s[j]++;
                if(s[j]>'z')s[j]='a';
            }
            last=now=0;
            while(last<s.size()){
                while(now<s.size()&&'a'<=s[now]&&s[now]<='z')now++;
                if(now-last==3){
                    if(s[last]=='t'&&s[last+1]=='h'&&s[last+2]=='e')found=true;
                }
                else if(now-last==4){
                    if(s[last]=='t'&&s[last+1]=='h'){
                        if(s[last+2]=='i'&&s[last+3]=='s')found=true;
                        else if(s[last+2]=='a'&&s[last+3]=='t')found=true;
                    }
                }
                if(found)break;
                now++;
                last=now;
            }
            if(found)break;
        }
        cout<<s<<endl;
    }
}


Measured memory_bytes: 2992
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define chmax(x,y) x = max(x,y)
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, a, cnt[200005] = {}, ans[200005] = {};
set<ll> cntX[200005] = {};
multiset<ll> sa, sb;
queue<ll> ind[200005] = {};

ll chooseAny(ll num, ll x) {
	ll res;
	if (num == 0) {
		res = *sa.begin();
		if (res == x)res = *sa.rbegin();
	}
	else {
		res = *sb.begin();
		if (res == x)res = *sb.rbegin();
	}
	cntX[cnt[res]].erase(res);
	cntX[cnt[res] - 1].insert(res);
	return res;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a;
		a--;
		cnt[a]++;
		sa.insert(a);
		ind[a].push(i);
	}
	rep(i, n) {
		cin >> a;
		a--;
		cnt[a]++;
		sb.insert(a);
		if (cnt[a] > n) {
			cout << "No" << endl;
			return 0;
		}
	}
	rep(i, n)cntX[cnt[i]].insert(i);
	rep(i, n) {
		ll x, y;
		switch (sz(cntX[n - i])) {
		case 0:
			x = chooseAny(0, -1);
			y = chooseAny(1, x);
			break;
		case 1:
			x = *cntX[n - i].begin();
			cntX[n - i].erase(x);
			cntX[n - i - 1].insert(x);
			if (sa.find(x) != sa.end()) {
				y = chooseAny(1, x);
			}
			else {
				y = x;
				x = chooseAny(0, y);
			}
			break;
		case 2:
			x = *cntX[n - i].begin();
			cntX[n - i].erase(x);
			cntX[n - i - 1].insert(x);
			if (sa.find(x) != sa.end()) {
				y = *cntX[n - i].begin();
				cntX[n - i].erase(y);
				cntX[n - i - 1].insert(y);
			}
			else {
				y = x;
				x = *cntX[n - i].begin();
				cntX[n - i].erase(x);
				cntX[n - i - 1].insert(x);
			}
		}
		ans[ind[x].front()] = y + 1;
		ind[x].pop();
		cnt[x]--;
		cnt[y]--;
		sa.erase(sa.find(x));
		sb.erase(sb.find(y));
	}
	cout << "Yes" << endl;
	rep(i, n)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 180100
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n,k = nm()
p = nl()
p = sorted(p)
res = 0
for i in range(k):
    res += p[i]
print(res)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const ll mod = 1000000007;

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int d;
  string str;
  cin >> str >> d;
  int n = str.size();
  vector<vector< vector<ll> > > dp(n+5, vector<vector<ll> >(2, vector<ll>(d+5, 0)));
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(j,d) {
      rep(k,10) { //i桁目がN未満 -> i+1がN未満
        dp[i+1][1][(j+k) % d] += dp[i][1][j];
        dp[i+1][1][(j+k) % d] %= mod;
      }
      int x = str[i]-'0';
      rep(k,x) { //i桁目がNと同じ -> i+1がN未満
        dp[i+1][1][(j+k) % d] += dp[i][0][j];
        dp[i+1][1][(j+k) % d] %= mod;
      }
      //i桁目がNと同じ -> i+1がNと同じ
      dp[i+1][0][(j+x) % d] = dp[i][0][j];
      dp[i+1][0][(j+x) % d] %= mod;
    }
  }
  cout << (dp[n][1][0] + dp[n][0][0] - 1 + mod) % mod << endl;
  return 0;
}

Measured memory_bytes: 17664