akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
using namespace std;
const long long mod=1e9+7;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> oks(n+1,true);
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    oks[a]=false;
  }
  
  vector<long long int> dp(n+1);
  dp[0]=1;
  for(int now=0;now<n;now++){
    for(int next=now+1;next<=min(n,now+2);next++){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  int cc=1<<30;
  int res;
  cin >> n >> t >> a;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
    int d=(t*1000-6*h[i])-a*1000;
    if(d<0)d=-d;
    if(cc>d)cc=d,res=i;
  }
  cout << res+1 << endl;
}


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

#define ff first
#define ss second
#define ins insert
#define ll long long
#define ld long double
#define vl vector<ll>
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define trv(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while(t--)
#define rep(i,a,n) for(ll i = a; i < n; ++i)
#define per(i,a,n) for(ll i = n-1; i >= a; --i)
#define godspeed cin.tie(0) -> sync_with_stdio(0)

int main() {
    godspeed;
    ll n; cin >> n;
    vl v;


    while(n--) {
    	ll a, b; cin >> a >> b;
    	(a == b) ? v.push_back(1) : v.push_back(0);
    }

    rep(i,0,sz(v)) {
    	if(v[i] + v[i+1] + v[i+2] == 3) {cout << "Yes"; return 0;}
    }

    cout << "No";
}

Measured memory_bytes: 3648
n = int(input())
 
M = 0
A = 0
R = 0
C = 0
H = 0
 
res = 0
 
for i in range(n):
    char = input()[0]
    if char == "M":
        M += 1
    elif char == "A":
        A += 1
    elif char == "R":
        R += 1
    elif char == "C":
        C += 1
    elif char == "H":
        H += 1

res += M * A * R;
res += M * A * C;
res += M * A * H;
res += M * R * C;
res += M * R * H;
res += M * C * H;
 
res += A * R * C;
res += A * R * H;
res += A * C * H;
 
res += R * C * H;
 
print(res)

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        String s=scan.next();
        if(s.charAt(1)=='B'){
            System.out.println("ARC");
        }
        else{
            System.out.println("ABC");
        }
    }
}


Measured memory_bytes: 35640
def main():
    a,b,c = map(int,input().split())
    cnt = 0
    if a == b == c:
        print(0)
        return
    ary = [a,b,c]
    while True:
        ary.sort()
        if ary[0] == ary[1] == ary[2]:
             print(cnt)
             return
        elif ary[1] == ary[0] :
            cnt += ary[2] - ary[0]
            print(cnt)
            return


        ary[0] += 2
        cnt += 1



if __name__ =='__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n,m;cin>>n>>m;
	string s;cin>>s;
	int cnt1=0,cnt2=0,ans=0;
	rep(i,s.size()-1){
		if(s[i]==s[i+1])ans++;
	}
	bool a=true;
	rep(i,s.size()-1){
		if(s[i]=='L'&&s[i+1]=='R'&&a){a=false;}
		if(s[i]=='R'&&s[i+1]=='L'&&!a){
			cnt1++;
			a=true;
		}
	}
	bool b=true;
	rep(i,s.size()-1){
		if(s[i]=='R'&&s[i+1]=='L'&&b)b=false;
		if(s[i]=='L'&&s[i+1]=='R'&&!b){
			cnt2++;
			b=true;
		}
	}
	if(cnt1>=m||cnt2>=m){ans+=m*2;}
    else ans=n-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
import bisect

N, H=map(int, input().split())
a=[0]*N
b=[0]*N
for i in range(N):
  a[i], b[i]=map(int, input().split())
  
a=max(a)
b.sort()
tmp=bisect.bisect_right(b, a)
if tmp==N:
  print((H-1)//a+1)
  exit()

b=b[tmp:]
b=b[::-1]
ans=0
for i in range(len(b)):
  H-=b[i]
  ans+=1
  if H<=0:
    print(ans)
    exit()
ans+=(H-1)//a+1
print(ans)

Measured memory_bytes: 16592
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>


using namespace std;

int main()
{
   int a,b,c,tmp;
   cin >>a >>b>>c;
    
   tmp=a;
   a=b;
   b=tmp;
   tmp=a;
   a=c;
   c=tmp;
   cout <<a<<" "<<b<<" "<<c;
   
}






Measured memory_bytes: 256
A,B,K=map(int,raw_input().split())

ary=[]

min_num=min(A,B)

for i in range(min_num):
    div_num=i+1
    if A%div_num == 0 and B%div_num == 0:
        ary.append(div_num)

ary.reverse()

#print ary
print ary[K-1]


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct Node{
  size_t cnt;
  Node *p,*l,*r;
  Node():cnt(0){p=l=r=nullptr;}
  Node(Node* p):cnt(0),p(p){l=r=nullptr;}
};
  
template<typename T,size_t X>
struct BinaryTrie{
  T acc;
  Node *root;
  Int ptr=0;
  static vector<Node> vs;
  BinaryTrie():acc(0),ptr(0){
    if(vs.empty()) vs.resize(3e6);
    root=emplace(nullptr);
  }
  
  inline Node* emplace(Node* p){
    return &(vs[ptr++]=Node(p));
  }

  inline size_t count(Node* a){
    return a?a->cnt:0;
  }
  
  void add(const T b,size_t k=1){
    const T nb=b^acc;
    Node* a=root;
    for(Int i=X-1;i>=0;i--){
      bool f=(nb>>i)&1;
      if(!f&&!a->l) a->l=emplace(a);
      if( f&&!a->r) a->r=emplace(a);
      a=f?a->r:a->l;
    }
    a->cnt+=k;    
    while((a=a->p)) a->cnt=count(a->l)+count(a->r);    
  }

  inline void update(const T b){acc^=b;}

  size_t order_of_key(const T b){
    Node *a=root;
    size_t res=0;
    for(Int i=X-1;i>=0;i--){      
      Node *l=a->l,*r=a->r;
      if((acc>>i)&1) swap(l,r);
      bool f=(b>>i)&1;
      if(f) res+=count(l); 
      a=f?r:l;
      if(!a) break;
    }
    return res;
  }
};
template<typename T, size_t X>
vector<Node> BinaryTrie<T, X>::vs;

signed main(){
  Int n,k;
  scanf("%lld %lld",&n,&k);
  k=n*(n+1)/2-k;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) scanf("%lld",&a[i]);

  auto calc=
    [&](Int x)->Int{
      Int res=0;
      BinaryTrie<Int, 20> bt;
      bt.add(0);
      for(Int i=0;i<n;i++){
        bt.update(a[i]);
        res+=bt.order_of_key(x);
        bt.add(0);
      }
      return res;
    };
  
  Int l=0,r=1<<20;
  while(l+1<r){
    Int m=(l+r)>>1;
    if(calc(m)<=k) l=m;
    else r=m;
  }

  printf("%lld\n",l);
  return 0;
}


Measured memory_bytes: 97340
N = int(input())
A = list(map(int, input().split()))

from itertools import combinations

num = 10**9 + 7
ans = 0

B = []
b = 0
for i in reversed(A[1:]):
    b += i
    B.append(b)
B.reverse()
for x, y in zip(A[:-1], B):
    ans += x*y
    ans %= num
print(ans)


Measured memory_bytes: 104836
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <set>
#include <map>

int N;
std::map<int64_t, int64_t> m;

int main(){
  scanf("%d", &N);
  int64_t s = 0;
  m.insert(std::make_pair(0, 1));
  int64_t sum = 0;
  for(int i = 0; i < N; i++){
    int tmp;
    scanf(" %d", &tmp);
    sum += tmp;
    auto it = m.find(sum);
    if(it == m.end()) {
      m.insert(std::make_pair(sum, 1));
    } else {
      it->second++;
    }
  }
  int64_t count = 0;
  for(auto& kv : m) {
    //printf("%d %d\n", kv.first, kv.second);
    count += (kv.second * (kv.second - 1)) / 2;
  }
  printf("%lld\n", count);
  return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
 
int main(void)
{
	char num[1000];
    int count,tmp,sum;
    while(1){
		scanf("%s", num);
		if(num[0]=='0') break;
		count=0;
		sum=0;
		while(1){
			if(num[count]=='\0') break;
			tmp=(int)num[count++]-48;
			sum+=(tmp%10)+(tmp/10);
		}
		printf("%d\n",sum);
	}
    return 0;   
}   

Measured memory_bytes: 536
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n;
    cin>>n;
    int arr[n];
    map<int,int>mt,mm;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        mm[arr[i]]++;
    }
    sort(arr,arr+n);
    int cnt=0;
    bool ok=1;
    for(int i=0;i<n;i++){
        //cout << mt[arr[i]] << " "<< arr[i] << endl;
        ok=1;
        if(mm[arr[i]]>1){ok=0;}
        for(int j=arr[i];j<=arr[n-1];j+=arr[i]){
           // cout << j <<endl;
            mm[j]++;
        }
        if(ok)cnt++;
    }
    cout << cnt << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 67360
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> a(m);
	for (int i = 0; i < m; i++)
		cin >> a[i].first >> a[i].second;
	a.erase(unique(a.begin(), a.end()), a.end());
	vector<int> c(n + 1, 0);
	for (int i = 0; i < a.size(); i++) {
		if (a[i].first == 1)
			c[a[i].second]++;
		if (a[i].second == n)
			c[a[i].first]++;
	}
	for (int i = 1; i <= n; i++)
		if (c[i] == 2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(){
  int a,b,c,zero=0;
  scanf("%d %d %d",&a,&b,&c);
  if(c<(a-b)){
    printf("%d\n",zero);
  }
  else
    printf("%d\n",c-a+b);
  
  return 0;
}
  


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int H, W;
	int i, j;
	
	while(1)
	{
		scanf("%d %d", &H, &W);
		if ((H != 0) && (W != 0))
		{
			for (i = 0;i < H;i++)
			{
				for (j = 0;j < W;j++)
				{
					printf("#");
				}
				printf("\n");
			}
		}
		else
		{
			break;
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2044
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static long gcd(long a, long b){
		if(b != 0) return gcd(b, a % b);
		else return a;
	}

	public static long lcm(long a, long b, long g){
		long v = a / g;
		long w = b / g;
		long l = v * w * g;
		return l;
	}

	public static void main(String[] args){

		while(scan.hasNext()){
			long a = scan.nextLong();
			long b = scan.nextLong();
			long g = gcd(a, b);
			long l = lcm(a, b, g);
			System.out.printf("%d %d\n", g, l);
		}
	}
}

Measured memory_bytes: 25864
//gauravsinghh
#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;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define MAXI (1<<32)
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define SIZ 1000005
#define SIZE 200005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair<ll,ll>&a,const pair<ll,ll>&b){
	return a.ss < b.ss;
}

//ll p[20000005]={0};
//vector<ll>ans;
/*void sieve(){
    ll i,j;
    p[0]=p[1]=1;
    for(i=2;i*i<=20000005;i++){
        if(!p[i]){
            for(j=2*i;j<20000005;j+=i){
                p[j]=1;
            }
        }
    }
    fo(i,2,20000005){
        if(!p[i]){
            ans.pb(i);
        }
    }
}*/

signed main(){ 
    IOS
    //io_set();
    string a, b;
    cin >> a >> b;
    sort(all(a));
    sort(b.rbegin(),b.rend());
    if(a < b){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int n,maxx,max2,a[200005];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]>=a[maxx]) max2=maxx,maxx=i;
		else if(a[i]>a[max2]) max2=i;
	}
	for(int i=1;i<=n;i++){
		if(maxx==i) printf("%d\n",a[max2]);
		else printf("%d\n",a[maxx]);
	}
}


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

int main(){
    int s,w;
    cin >> s >> w;
    if(s > w) cout << "safe" << endl;
    else cout << "unsafe" << endl;
}

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

int main(){
  int H,W;
  cin>>H>>W;
  char a[H+2][W+2];

  
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      a[i][j]='#';
    }
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>a[i+1][j+1];
    }
  }

  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout<<a[i][j];
    }
    cout<<endl;
  }
  
}

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

#define MaxN 505

using namespace std;

int N,M;
char Mat[MaxN][MaxN],A[MaxN][MaxN],B[MaxN][MaxN];

int main()
{
    cin>>N>>M;
    for(int i=1;i<=N;i++)
        scanf("%s",Mat[i]+1);
    memcpy(A,Mat,sizeof A);
    memcpy(B,Mat,sizeof B);
    for(int i=1;i<=N;i++)
        A[i][1]='#',B[i][M]='#';
    for(int i=1;i<=N;i++)
    {
        if(i%2)
        {
            for(int j=1;j<M;j++)
                A[i][j]='#';
        }
        else
        {
            for(int j=2;j<=M;j++)
                B[i][j]='#';
        }
    }
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=M;j++)
            cout<<A[i][j];
        cout<<'\n';
    }
    cout<<'\n';

    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=M;j++)
            cout<<B[i][j];
        cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 1536
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;

bool app[256];

int32_t main() {
    fastIO();
    
    int n, a, b;
    cin >> n >> a >> b;
    
    if (a > b or (n == 1 and a != b)) cout << 0 << "\n";
    else if (n == 1) cout << 1 << "\n";
    else cout << (n-2) * (b-a) + 1 << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    vector<ll> cnt(N + 1);
    for(int i = 0;i < N;i++) {
        cnt.at(vec.at(i))++;
    }
    ll ret = 0;
    for(int i = 1;i < N + 1;i++) {
        ret += cnt.at(i) * (cnt.at(i) - 1) / 2;
    }
    for(int i = 0;i < N;i++) {
        ll cnt2 = cnt.at(vec.at(i));
        cout << ret - (max(0ll,cnt2 * (cnt2 - 1) / 2) - max(0ll,(cnt2 - 1) * (cnt2 - 2) / 2)) << endl;
    }
}

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

public class Main{
  public static void main(String[] args)throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try{
      String[] S = br.readLine().split(" ");
      long N = Long.parseLong(S[0]);
      long M = Long.parseLong(S[1]);
      
      long mod = N%M;
      System.out.println(Math.min(mod, Math.abs(M-mod))); 
    }catch(Exception e){
    }
  }
}


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

 
int main()
{ 
    ll t;
    t=1;
    while(t--)
    {
       ll a;
       cin>>a;
       cout<<a + pow(a,2) + pow(a,3)<<endl;
    }
           
        
 return 0;
}

Measured memory_bytes: 4144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
   double N;
    cin >> N;
    vector <double> X(N);
    rep(i,N) cin >> X[i];
    double sum = 0;
    rep(i,N) sum += X[i];
    double p = sum/N;
    double r = p - floor(p);
    if(r >= 0.5) p = ceil(p);
    else p = floor(p);
    int ans = 0;
    rep(i,N) ans +=(X[i]-p)*(X[i]-p);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    private int prime[] = { 2, 3, 5, 7 };
    private int target[] = { 2, 4, 14, 24, 74 };

    public void main(Scanner sc) {
        int n = sc.nextInt();

        // 9! までは七五数がない
        if (n < 10) {
            System.out.println(0);
            return;
        }

        // n! を素因数分解
        List<Integer> list = new ArrayList<>();
        for (int i = 2; i <= n; i++) {
            int tmp = i;
            for (int j = 0; j < 4; j++) {
                if (tmp % prime[j] == 0) {
                    while (tmp % prime[j] == 0) {
                        list.add(prime[j]);
                        tmp /= prime[j];
                    }
                }
            }
            if (tmp != 1) {
                list.add(tmp);
            }
        }

        // 各素因数の出現回数を統計
        Map<Integer, Long> map =
            list.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting()));

        // 2,4,14,24,74 個以上出現した素因数の数をカウント
        int tmp[] = new int[5];
        for (Long cnt : map.values()) {
            for (int i = 0; i < 5; i++) {
                if (cnt >= target[i]) {
                    tmp[i]++;
                }
            }
        }

        int ans = 0;
        // p^74 のパターン
        ans += tmp[4];

        // p^2*q^24 のパターン
        if (tmp[3] > 0) {
            ans += (tmp[0] - tmp[3]) * tmp[3];
            ans += tmp[3] * (tmp[3] - 1);
        }

        // p^4*q^14 のパターン
        if (tmp[2] > 0) {
            ans += (tmp[1] - tmp[2]) * tmp[2];
            ans += tmp[2] * (tmp[2] - 1);
        }

        // p^2*q^4*r^4 のパターン
        if (tmp[1] >= 2) {
            ans += (tmp[0] - tmp[1]) * tmp[1] * (tmp[1] - 1) / 2;
            ans += tmp[1] * (tmp[1] - 1) * (tmp[1] - 2) / 2;
        }

        System.out.println(ans);
    }

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().main(sc);
        } catch (Exception e) {
            throw e;
        }
    }
}


Measured memory_bytes: 28748
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> 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

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#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 deba(x) cout<< #x << " = " << x <<endl


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;
}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; 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,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
ll table[500005];
char s[500005],t[500005];
//bool used[500005];
bool flag,dame;

void dfs(ll v,ll p){
	table[v] = z[num];
	num++;
	for(int i=0;i<G[v].size();i++){
		if(G[v][i] == p)continue;
		dfs(G[v][i],v);
	}
	return ;
}


int main(){
	cin >> n;
	for(i=0;i<n-1;i++){
		cin >> x[i] >> y[i];
		G[x[i]].pb(y[i]);
		G[y[i]].pb(x[i]);
	}
	for(i=0;i<n;i++){
		cin >> z[i];
	}
	sort(z,z+n);
	reverse(z,z+n);
	dfs(1,-1);
	ans = 0;
	for(i=0;i<n-1;i++){
		ans += min(table[x[i]],table[y[i]]);
	}
	p(ans);
	for(i=1;i<=n;i++){
		pe(table[i]);
	}
	el;
	return 0;
}

Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
using d = double;
  
int main(){
  int n;
  cin >> n;
  ll ans=0;
  for(int i=1;i<=n;++i){
    if(i%3==0 || i%5==0) continue;
    else ans+=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());

  if(a[0]+1<a[n-1]){
    cout<<"No"<<endl;
    return 0;
  }
  
  Int x=0;
  while(x<n&&a[0]==a[x]) x++;

  if(x==n-1){
    cout<<"No"<<endl;
    return 0;
  }
  
  if(x==n){
    cout<<(a[0]==n-1||a[0]*2<=n?"Yes":"No")<<endl;
    return 0;
  }
  
  cout<<((a[n-1]-x)>0&&(a[n-1]-x)*2<=n-x?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int inf = 1e5;

typedef pair<int, int> P;
typedef pair<int, P> Q;

int n, m;
Q g[4950];

int ufp[100];
int ufr[100];
int ufc[100];

void uf_init(){
	rep(i, n){
		ufp[i] = i;
		ufr[i] = 0;
		ufc[i] = 1;
	}
}

int uf_find(int x){
	return ufp[x] == x ? x : ufp[x] = uf_find(ufp[x]);
}

int uf_unite(int x, int y){
	int p = uf_find(x);
	int q = uf_find(y);
	
	if(p == q){
		return ufr[p];
	}

	if(ufr[p] > ufr[q]){
		ufp[q] = p;
		return ufc[p] += ufc[q];
	}
	else{
		ufp[p] = q;
		if(ufr[p] == ufr[q]){
			++ufr[q];
		}
		return ufc[q] += ufc[p];
	}
}

int main(){
	while(scanf("%d%d", &n, &m), n){
		rep(i, m){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			g[i] = Q(c, P(a - 1, b - 1));
		}

		sort(g, g + m);

		int ans = inf;
		rep(i, m){
			uf_init();

			for(int j = i; j < m; ++j){
				Q e = g[j];
				int a = e.second.first;
				int b = e.second.second;
				int c = e.first;

				if(uf_unite(a, b) == n){
					ans = min(c - g[i].first, ans);
					break;
				}
			}
		}
		printf("%d\n", ans != inf ? ans : -1);
	}
	return 0;
}

Measured memory_bytes: 1088
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    import numpy as np
    dp = np.zeros(s+1, dtype=int)
    mod = 998244353
    ans = 0
    for i in range(n):
        dp[0] += 1
        dp[a[i]:] += dp[:-a[i]]
        dp%= mod
        ans += dp[-1]
        ans %= mod
    print(ans)



if __name__ == '__main__':
    main()

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  ll ans = 0;
  rep(i,n) ans += a[i]-1;

  cout << ans << endl;

}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.buffer.readline


def bfs():
    dp[sup_v][0] = 1
    q1 = deque([sup_v])
    q2 = deque([0])
    while q1:
        v1 = q1.popleft()
        v2 = q2.popleft()
        for tmp in graph[v1 * OFFSET + v2]:
            nxt_v1, nxt_v2 = divmod(tmp, OFFSET)
            if nxt_v1 == -1:
                cost = 1
            else:
                cost = 0
            if nxt_v1 not in dp:
                dp[nxt_v1] = {}
            if nxt_v2 not in dp[nxt_v1]:
                dp[nxt_v1][nxt_v2] = dp[v1][v2] + cost
                if cost == 0:
                    q1.appendleft(nxt_v1)
                    q2.appendleft(nxt_v2)
                else:
                    q1.append(nxt_v1)
                    q2.append(nxt_v2)
            elif dp[v1][v2] + cost < dp[nxt_v1][nxt_v2]:
                dp[nxt_v1][nxt_v2] = dp[v1][v2] + cost
                if cost == 0:
                    q1.appendleft(nxt_v1)
                    q2.appendleft(nxt_v2)
                else:
                    q1.append(nxt_v1)
                    q2.append(nxt_v2)
    
n, m = map(int, input().split())
INF = 10 ** 18
OFFSET = 10 ** 6


sup_v = -1
graph = {sup_v * OFFSET: []}
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    if c * OFFSET + a not in graph:
        graph[c * OFFSET + a] = []
        graph[c * OFFSET + a].append(sup_v * OFFSET + a)
    if c * OFFSET + b not in graph:
        graph[c * OFFSET + b] = []
        graph[c * OFFSET + b].append(sup_v * OFFSET + b)
    if sup_v * OFFSET + a not in graph:
        graph[sup_v * OFFSET + a] = []
    if sup_v * OFFSET + b not in graph:
        graph[sup_v * OFFSET + b] = []

    graph[c * OFFSET + a].append(c * OFFSET + b)
    graph[c * OFFSET + b].append(c * OFFSET + a)
    graph[sup_v * OFFSET + a].append(c * OFFSET + b)
    graph[sup_v * OFFSET + b].append(c * OFFSET + a)


dp = {sup_v: {}}
bfs()
ans = INF
for i in dp:
    for j in dp[i]:
        if j == n - 1:
            ans = min(dp[i][j], ans)   
if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 234776
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};



#define int ll
signed main(){
    int n;
    cin>>n;
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        if(x<y)swap(x,y);
    int r=floor(sqrt(x*y));
    if(r*(r+1)<x*y)cout<<2*r-1<<endl;
    else if(r*r<x*y)cout<<2*r-2<<endl;
    else cout<<2*r-3+(r==x)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    const long long ub = 3500;
    long long n; cin >> n;
    for (long long x = 1; x <= ub; ++x) {
        for (long long y = 1; y <= ub; ++y) {
            long long p = n*x*y;
            long long q = 4*x*y - n*y - n*x;
            if ((q > 0) && (p % q == 0)) {
                long long z = p / q;
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    return -1;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
#define vec vector<int>
#define REP(i,a,b) for(i=a;i<b;i++)
using namespace std;
main()
{
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  ans+=l/d;
  if(l%d==0)
    ans--;
  int res=0;
  res+=r/d;
  cout<<res-ans<<"\n";
}


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

string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  char a, b;
  cin >> a >> b;
  string s, t;
  for (int i = 0; i < a - '0'; i++) s.push_back(b);
  for (int i = 0; i < b - '0'; i++) t.push_back(a);
  vector<string> x = {s, t};
  sort(x.begin(), x.end());
  cout << x.at(0) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int k;
  string s;
  cin>>k>>s;

  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    string sub=s.substr(0,k);
    sub+="...";
    cout<<sub<<endl;
  }

  return 0;
}




Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    
    cout << a1 * a2 *0.5<<endl;
}

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

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
using ll = long long;

int main(){
	fastIO;
	int n;
	double ans=0;
	cin >> n;
	vector<pair<string,string>> v(n);
	for(int i=0;i<n;++i){
		cin >> v[i].first >> v[i].second;
	}
	for(int i=0;i<n;++i){
		if(v[i].second == "JPY")
			ans+=stoi(v[i].first);
		else{
			ans+=stod(v[i].first)*380000.0;
		}
	}
	//cout.precision(4);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        String answer = answer(A, B);
        System.out.println(answer);
    }
    public static String answer(int A, int B) {
        if (A == 1) {
            A = 14;
        }
        if (B == 1) {
            B = 14;
        }
        if (A == B) {
            return "Draw";
        }
        if (A > B) {
            return "Alice";
        }
        return "Bob";
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1e9+7;
using namespace std;

int main(){
    ll x; cin >> x;
    ll ans = x/11; x -= ans*11;
    ans *= 2;
    if(x > 6) ans += 2;
    else if(x) ++ans;
    cout << ans << endl;
    return 0;
}


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

def abc161d(k):
    lunArr = [[] for _ in range(10)]
    lunArr[0] = [1, 2, 3, 4, 5, 6, 7, 8, 9,]

    for keta in range(1,10):
        for elem in lunArr[keta-1]:
            base = elem % 10
            if base == 0:
                lunArr[keta].append(elem * 10 + base)
                lunArr[keta].append(elem * 10 + base+1)
            elif base == 9:
                lunArr[keta].append(elem * 10 + base-1)
                lunArr[keta].append(elem * 10 + base)
            else:
                lunArr[keta].append(elem * 10 + base-1)
                lunArr[keta].append(elem * 10 + base)
                lunArr[keta].append(elem * 10 + base+1)

    target = k
    for keta in range(10):
        t_arr = lunArr[keta]
        if target < len(t_arr):
            return t_arr[target-1]
        else:
            target -= len(t_arr)
    else:
        print("k is too large")
        print(target)


###
# main
if(__name__ == '__main__'):
    # input
    k = int(input())
    
    ans = abc161d(k)
    
    # output
    print(ans)
# else:
    # do nothing


Measured memory_bytes: 11628
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  int x = (int)sqrt(N);
  
  for(int i = 1; i < 10; i++) {
    if(N % i == 0) {
      if((N / i) < 10) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 02.08.2020 13:31:43
**/

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

int main() {

    int n;
    int a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;

    bool rock=false;
    bool ans=true;

    for(int i=a; i<d; i++){
        if(s.at(i)=='#'){
            if(rock) ans=false;
            else rock=true;
        }
        if(s.at(i)=='.') rock=false;
        if(!ans) break;
    }

    if(c>d){
        int count=0;
        ans=false;
        for(int i=b-2; i<min(d+1,n); i++){
            if(s.at(i)=='.') count++;
            else count=0;
            if(count>=3){
                ans=true;
                break;
            }
        }
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll ZERO = 0;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

ll fac[1000010], finv[1000010], inv[1000010];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 1000010; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll N,K;
    cin >> N >> K;
    COMinit();
    for(int i = 1;i <= K;i++) {
        cout << COM(K - 1, i - 1) * COM(N - K + 1, i) % MOD << endl;
    }
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n; cin>>n;
    int ans=0;
    FOR(i,0,n){
        LLI a; cin>>a;
        while(a%2==0){
            ans++;
            a/=2;
        }
    }
    co(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int A[100000][3];
int F[100000][3];

int main() {
    int n, k;
    cin >> n;
    for (int i = 1; i < n + 1; ++i) {
        for (int j = 1; j < 4; ++j) {
            cin >> A[i][j];
        }
    }
    F[1][1] = A[1][1];
    F[1][2] = A[1][2];
    F[1][3] = A[1][3];
    for (int i = 2; i < n + 1; ++i) {
        F[i][1] = A[i][1] + max(F[i - 1][2], F[i - 1][3]);
        F[i][2] = A[i][2] + max(F[i - 1][1], F[i - 1][3]);
        F[i][3] = A[i][3] + max(F[i - 1][1], F[i - 1][2]);
    }
    int m = max(F[n][1], F[n][2]);
    m = max(m, F[n][3]);
    cout << m;
    return 0;
}

Measured memory_bytes: 2688
//                                               KEEP GRINDING
#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<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<"\n========================================\n"<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define fr first
#define sc second

#define MAXN 500000
#define INF 9223372036854775807
signed main(){
    fastio
    int n,ans=0;
    cin>>n;
    vector<int> a(n),v;
    map<int,int> map;
    f(i,0,n){
    	cin>>a[i];
    	map[ a[i] ]++;
	}
	if(map.count((int)1)){
	   cout<<( map[(int)1] > 1 ? 0 : 1 );
	   return 0;
	}
	f(i,0,a.size()){
		bool f=1;
		if(map[a[i]]>1)
		    continue;
		
		for(int j=2;j*j<=a[i] ;j++){
			if(a[i]%j==0 && ( map.count(j) || map.count(a[i]/j) ) ) {
				f=0;
				break;
			}
		}
		if(f)  ans++  ;
	}
	cout<<ans;
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<string,int> &a, 
              const pair<string,int> &b) 
{ 
	bool x = false;
	if( a.second > b.second  && a.first < b.first ) {
		x = true;
	}
    return x;
}
ll arr[102];
int main(){
	
	ll n;
	cin>>n;
	vector<pair<string,int>> v;
	string x = "";
	int y;
	for(int i = 0; i < 102; i++) arr[i] = 0;
	for(int i = 0; i < n; i++){
		cin>>x>>y;
		v.push_back({x,y});
		arr[y] = i+1;
	}
	sort(v.begin(),v.end());
	
	for(int i = 0; i < n; i++){
		if((i+1 < n) && v[i].first != v[i+1].first) { cout<<arr[v[i].second]<<"\n"; }
		else {
			vector<int> ans;
			while((i+1 < n) && v[i].first == v[i+1].first){
				ans.push_back(arr[v[i].second]);
				i++;
			}
			if(i < n) ans.push_back(arr[v[i].second]);
			reverse(ans.begin(),ans.end());
			for(auto cc : ans) cout<<cc<<"\n";
		}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

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

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

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

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,a;
  scanf("%d%d",&n,&a);

  n%=500;

  if(n<=a){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1644
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#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--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1e6 + 12; //check the limits, dummy


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

    string s;
    cin >> s;
    ll n = sz (s);

    ll ans = 0;
    FOR (i, 0, n / 2) {
        if (s[i] != s[n - i - 1]) ans++;
    }

    cout << ans << '\n';

    return  0;
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val sums = 2.to(999).scanLeft(1 -> 1) {
    case ((_, acc), r) => r -> (acc + r)
  }.toMap
  val a, b = sc.nextInt()
  println(sums.getOrElse(b - a, 0) - b)
}


Measured memory_bytes: 56044
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    double prop = 0;

    for (int i = 1; i <= n; ++i) 
    {
        double tmp = 1.0 / n;
        int now = i;
        while (now < k) {
            now *= 2;
            tmp /= 2;
        }
        prop += tmp;
    }

    cout << fixed << setprecision(12) << prop << endl;
}

Measured memory_bytes: 256