akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,m);
  Vi A(m);
  Vi B(m);
  REP(i,m){
    IN2(A[i],B[i]);
  }
  bool ok = true;
  //１桁目が0
  if(n>1){
    REP(i,m){
      if(A[i]==1 && B[i] == 0) ok = false; 
    }
  }
  //違うやつ
  M mp;
  REP(i,9){
    mp[i] = -1;
  }
  REP(i,m){
    if(mp[A[i]] == -1) mp[A[i]] = B[i];
    else {
      if(mp[A[i]] != B[i]) ok = false;
    }
  }

  if(!ok) {
    OUT(-1);
    return 0;
  }
  int ans = 0;
  for(auto p: mp){
    if(p.second == -1) continue;
    ans += p.second * pow(10,(n - p.first));
  }
  if(mp[1] == -1){
    ans += pow(10, (n-1));
  }
  if(m==0 && n==1) ans = 0;
  OUT(ans);
}

Measured memory_bytes: 256
using Yorukatsu045.Questions;
using Yorukatsu045.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu045.Questions
{
    /// <summary>
    /// ABC144 C
    /// </summary>
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadLong();
            var div = GetMaxDivisior(n);
            var another = n / div;
            yield return div + another - 2;
        }

        long GetMaxDivisior(long n)
        {
            for (long i = (long)Math.Sqrt(n) + 1; i >= 0; i--)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return 1;
        }
    }
}


namespace Yorukatsu045
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu045.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu045.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

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

    int N, C;
    cin >> N >> C;

    int record_programs[N][3];
    int program_imos[100010][C];
    for (int i = 0; i < 100010; ++i) {
        for (int j = 0; j < C; ++j) {
            program_imos[i][j] = 0;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> record_programs[i][j];
        }

        record_programs[i][2]--;

        program_imos[record_programs[i][0] - 1][record_programs[i][2]]++;
        program_imos[record_programs[i][1]][record_programs[i][2]]--;
    }

    for (int i = 0; i < 100010; ++i) {
        for (int j = 0; j < C; ++j) {
            if (i) {
                program_imos[i][j] += program_imos[i - 1][j];
            }
        }
    }

    int ans = 0;

    for (int i = 0; i < 100010; ++i) {
        int res = 0;
        for (int j = 0; j < C; ++j) {
            if (program_imos[i][j] > 0)
                res++;
        }

        ans = max(ans, res);
    }

    cout << ans << endl;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
const int N=5050;
int n,m,c[N],f[N],ans;
int main(){
    scanf("%d%d",&n,&m);f[0]=1;
    for(int i=3,j=n;i<=j;i++,j--)c[i]=c[j]=i-2;
    for(int i=2;i<=n;i++)
        for(int j=c[i]+1;j<=n;j++)(f[j]+=f[j-c[i]-1])%=m;
    for(int i=0;i<n;i++)ans=(ans+1ll*f[i]*(n-i))%m;
    printf("%d\n",ans);
    return 0;
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll ok[N], fact[N];
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("test.txt", "r", stdin);
        ll n;
        cin >> n;
        fact[0] = 1;
        for (int i = 1; i <= n; i++){
                ok[i] = 1;
                fact[i] = fact[i - 1] * i;
        }
        ll cnta = 0;
        for (int i = 1; i <= n; i++){
                ll a;
                cin >> a;
                ll cnt = 0;
                for (int j = 1; j < a; j++){
                        if (ok[j] == 1){
                                cnt++;
                        }
                }
                ok[a] = 0;
                cnta += cnt * fact[n - i];
        }
        ll cntb = 0;
        for (int i = 1; i <= n; i++) ok[i] = 1;
        for (int i = 1; i <= n; i++){
                ll a;
                cin >> a;
                ll cnt = 0;
                for (int j = 1; j < a; j++){
                        if (ok[j] == 1){
                                cnt++;
                        }
                }
                ok[a] = 0;
                cntb += cnt * fact[n - i];
        }
        cout << abs(cnta - cntb);
}


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


int main() {
  int N, K;
  cin >> N >> K;
  int a[55];
  for(int i = 0; i < N; ++i) {
    cin >> a[i]; 
  }
  sort(a, a + N, greater<int>());
  int sum = 0;
  for(int i = 0; i < K; ++i){
    sum += a[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    // 数値の配列を作る
//    const numList1 = input[0].split(' ').map(x => parseInt(x, 10));
    const strList = input[0].split(' ');
    const SCharList = strList[0];
    const length = SCharList.length;

    var cnt = 0;
    for (var i = 0; i < length; i++) {
        var c = SCharList[i];
        // 010101...の方基準で考える
        if (i % 2 === 0 && c === '0') {
            cnt++;
        } else if (i % 2 === 1 && c === '1') {
            cnt++;
        }
    }

    // 0101010...と10101010...どちらに近いか
    cnt = Math.min(cnt, length - cnt);
    console.log(cnt);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
#define MAX 2147483647
#define NMAX 100001


int find(int A[],int x,int y){
int i;
int min=MAX;

for(i=x;i<=y;i++){
 if(A[i]<=min){min=A[i];}
}

return min;
}



int main(){
int n,q,i;
int com,x,y;
int A[NMAX];
int C[NMAX];
scanf("%d %d",&n,&q);

for(i=0;i<n;i++)A[i]=MAX;
for(i=0;i<q;i++)C[i]=-1;

for(i=0;i<q;i++){
 scanf("%d %d %d",&com,&x,&y);
 switch(com){
  case 0:A[x]=y;
         break;
  case 1:C[i]=find(A,x,y);
         break;
 }
}


for(i=0;i<q;i++){if(C[i]!=-1){printf("%d\n",C[i]);}}

return 0;
}


Measured memory_bytes: 2544
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = Integer.parseInt(sc.nextLine());
			List<Integer> list = new ArrayList<Integer>();

			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				int count = 0;
				while (true) {
					if (a % 2 == 0) {
						a = a / 2;
						count++;
					} else {
						break;
					}
				}
				if (count == 0) {
					// 0の場合はすでに最小のため残りは処理不要
					System.out.println(0);
					return;
				}
				// listに入力値を割れる回数を格納
				list.add(count);
			}
			Collections.sort(list);
			System.out.println(list.get(0));

		} finally {
			sc.close();
		}
	}
}

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

int main(){

int N, K, a;
  cin >> N >> K;
  vector<int> v(N, 0);
  for(int i = 0;i < N;i++){
    cin >> a;
    v.at(a - 1)++;
  }
  
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  int cnt, sum = 0;

  for(int i = 0;i < N;i++){
    if(v.at(i) > 0) cnt++; 
    else break;
  }

  if(K >= cnt) cout << 0 << endl;
  else{
  for(int i = K;i < N;i++){
  if(v.at(i) > 0) sum += v.at(i);
  else break;  
  }
    cout << sum << endl;
  }

  return 0;
  
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long 

int tr[1000006],po[26],n;

void build() {
	for(int i=n-1;i>0;i--)
		tr[i] = tr[i*2]|tr[i*2+1];
}

int query(int l,int r) {
	int ans=0;
	l+=n,r+=n;
	while(l<r) {
		if(l&1) {
			ans |= tr[l];
			l++;
		}
		if(r&1) {
			r--;
			ans |= tr[r];
		}
		l/=2;
		r/=2;
	}
	int finans=0;
	while(ans) {
		if(ans%2)
			finans++;
		ans/=2;
	}
	return finans;
}

void update(int ind,char val) {
	ind+=n;
	tr[ind] = po[val-'a'];
	ind/=2;
	while(ind) {
		tr[ind] = tr[ind*2]|tr[ind*2+1];
		ind/=2;
	}
}

int main() {
	po[0] = 1;
	int i,j,k,l,m,q;
	for(i=1;i<26;i++)
		po[i] = po[i-1]*2;

	string s;
	char c;
	cin>>n>>s>>q;
	for(i=0;i<n;i++)
		tr[i+n] = po[s[i]-'a'];
	build();

	while(q--) {
		cin>>j>>k;
		if(j==2) {
			cin>>l;
			cout<<query(k-1,l)<<endl;
		}
		else {
			cin>>c;
			update(k-1,c);
		}
	}
	return 0;
}


Measured memory_bytes: 4868
#include <stdio.h>
#include <stdlib.h>
void quicksort(int data[],int left,int right); 
int main()
{
    	int n,h,i,j=0,ans=0,amax=0,flag=0;
    int a[1000000],b[1000000];
    	scanf("%d %d",&n,&h); 
    	for(i=0;i<n;i++)
    	{
        scanf("%d",&(a[i]));
        scanf("%d",&(b[i]));
        if(amax<a[i])amax=a[i];
    }
    quicksort(b,0,n-1);
    while(h>0&&j<n)
    {
        if(b[j]<amax)
        {
            flag=1;
            break;
        }
        h-=b[j];
        ans++;
        j++;
    }
    if(j==n||flag)
    {
        while(h>0)
        {
            h-=amax;
            ans++;
        }
    }
    printf("%d",ans);
}
void quicksort(int data[],int left,int right)
{
    int i,j;
    int std,work;
    	if(left<right)
    {
        i=left,j=right;
        std=data[(i+j)/2];//基準
        do
        {
            while(data[i] > std)i++;
            while(data[j] < std)j--;
            	if(i<=j)
            {
                if(i<j)
                {
                    work=data[i];
                    data[i]=data[j];
                    data[j]=work;
                 }
                i++; j--;
            }
      }while(i<=j); 		if(left<j)quicksort(data,left,j); 		if(i<right)quicksort(data,i,right);
    }
}


Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()



int main() {
    int N,M,X,Y;
    cin>>N>>M>>X>>Y;
    vector<int> x(N);
    vector<int> y(M);
    for(int i=0;i<N;i++)
        cin>>x.at(i);
    for(int j=0;j<M;j++)
        cin>>y.at(j);
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for(int k=X+1;k<=Y;k++){
        if(x.at(x.size()-1)<k&&y.at(0)>=k){
            cout<<"No War"<<endl;
            return 0;
        }
    }
    cout<<"War"<<endl;
}

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

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

    if (a + b >= c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;

void solve()
{
    // ll n; cin>>n;
    // vector<ll>v(n);
    // rep(i,n) cin>>v[i];
    ll n; cin>>n;
    ll d; cin>>d;
    ll ans=0;
    rep(i,n)
    {
        ll x,y; cin>>x>>y;
        if(ceil(sqrt(x*x+y*y))<=d) ans++;
    }
    cout<<ans<<"\n";

}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
   //cin>>t;
    while(t--)
        {solve();}
    return 0;
}

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

void solve() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    string S; cin >> S;
    
    set<long long> B;
    for (int i = N-1; i >= 0; i--) {
        if (S[i] % 2) {
            auto it = B.rbegin();
            while (it != B.rend()) {
                A[i] = min(A[i], A[i] ^ *it);
                it++;
            }
            if (A[i] != 0) {
                cout << 1 << "\n";
                return;
            }
        } else {
            auto it = B.rbegin();
            while (it != B.rend()) {
                A[i] = min(A[i], A[i] ^ *it);
                it++;
            }
            B.emplace(A[i]);
        }
    }
    cout << 0 << "\n";
    return;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    string  s,t;
    cin>>s>>t;
    bool f=true;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
            f=false;
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";

}



Measured memory_bytes: 3628
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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

const int MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int ans[502][502];

void solve(vector<int>v,int base) {
	if (v.size() == 1)return;
	REP(i, v.size()) {
		for (int j = i + 1; j < v.size(); j += 2) {
			ans[v[i]][v[j]] = base;
		}
	}
	vector<int>v1, v2;
	REP(i, v.size()) {
		if (i % 2 == 0) {
			v1.pb(v[i]);
		}
		else {
			v2.pb(v[i]);
		}
	}
	solve(v1, base + 1);
	solve(v2, base + 1);
}

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

	int N; cin >> N;
	vector<int>v;
	REP(i, N) {
		v.pb(i);
	}
	solve(v, 1);

	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			pe(ans[i][j]);
		}cout << endl;
	}
}


Measured memory_bytes: 2432
n = int(input())
a_list = list(map(int, input().split()))

is_even = 1
n_operation = 0
while(is_even):
    a_list = [a/2 for a in a_list if a % 2 == 0]
    if len(a_list) < n:
        is_even = 0
    else:
        n_operation += 1
        
print(n_operation)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H, W, K;
  cin >> H >> W >> K;
  int map[6][6];
  for (int h = 0; h < H; h++) {
    getchar();
    for (int w = 0; w < W; w++)
      map[h][w] = (getchar() == '#');
  }
  int count = 0;
  for (int hc = 0; hc < (1 << H); hc++) {
    bitset<6> hs(hc);
    for (int wc = 0; wc < (1 << W); wc++) {
      bitset<6> ws(wc);
      int hashs = 0;
      for (int a = 0; a < H; a++)
        for (int b = 0; b < W; b++)
          hashs += map[a][b] * hs[a] * ws[b];
      count += (int)(hashs == K);
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int even[] = {1,2,4,8,16,32,64};
    int ans = 0;
    for(auto i: even){
        if(i<=N)    ans = i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
N = int(input())
a = list(map(int,input().split()))
def brick(a):
    n = 1
    for i in range(0,len(a)):
        if a[i] == n:
            n = n + 1
    if n == 1:
        return -1
    else:
        return (len(a) + 1 - n)
print(brick(a))

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

bool b[1000010];

int main(){
    ll K;
    ll t = 7;
    ll c = 1;
    cin >> K;
    t = t % K;
    while(true){
        if(t == 0) break;
        if(b[t]){
            cout << -1 << endl;
            return 0;
        }
        b[t] = true;
        t *= 10;
        t += 7;
        t %= K;
        c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 4528
#include<iostream>
using namespace std;
int n;
bool is_prime(int m) {
  if(m==1)return false;
  for(int i=2;i*i<=m;i++){
    if(m%i==0)return false;
  }
  return true;
}
int main(void){
  cin>>n;
  for(int i=31;i<=55555;i+=5) {
    if(is_prime(i)==true) {
      if(i!=31)cout<<" ";
      cout<<i;
      n--;
    }
    if(n==0)break;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver2.1.7
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(Z,0,a.size()-1)cout<<a[Z]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lW,0,a.size()){Vout(a[lW]);}
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
 
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
 
signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,0,h) cin >> a[i];
  
  vector<Vi> yoko(h,Vi(w)),tate(h,Vi(w));
  //VVout(a);
  int s,g,now = 0;
  
  rep(i,0,h){
    s=0;
    rep(j,0,w){
      if(a[i][j]=='.') now++;
      if(a[i][j]=='#') {
        rep(k,s,j) yoko[i][k]=now;
        now = 0;
        s = j+1;
      }
      if(j==w-1 && now > 0){
        rep(k,s,j+1) yoko[i][k]=now;
        now = 0;
        s = j+1;
      }
    }
  }
  
  now = 0;
  
  rep(j,0,w){
    s=0;
    rep(i,0,h){
      if(a[i][j]=='.') now++;
      if(a[i][j]=='#') {
        rep(k,s,i) tate[k][j]=now;
        now = 0;
        s = i+1;
      }
      if(i==h-1 && now > 0){
        rep(k,s,i+1) tate[k][j]=now;
        now = 0;
        s = i+1;
      }
    }
  }
  
  //VVout(tate);
  
  int ans = 0;
  rep(i,0,h){
    rep(j,0,w){
      ans = max(ans,yoko[i][j]+tate[i][j]);
    }
  }
  ans--;
  cout << ans << endl;
  return 0;
}

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

int main() {
    
    int k,s,cnt=0;
    cin>>k>>s;
    for(int i=0;i<=k;i++)
    	for(int j=0;j<=k;j++)
    	{
    		int a = s-i-j;
    		if(a>=0&&a<=k)
    			cnt++;
    	}
    cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int
main(){
	int n;
	while(true){
		cin>>n;
		if(!n)break;
//		cout<<"n:"<<n<<endl;
		int count=0;
		for(int i=2;i<n;i++){
			//ô
		//	cout<<"    i:"<<i<<endl;
			if(!(i%2)){
				double tmp=(double)n/(double)i;
				double tmp2=(int)tmp;
				if(tmp-tmp2==0.5000){
				//	cout<<tmp2<<endl;
				//	cout<<tmp2-i/2<<endl;
					if(tmp2-i/2<0||(tmp2+1)+i/2>n)continue;
					count++;
				}
			}
			//ï
			else{
				if(n%i==0){
					int tmp=n/i;
					if(tmp-i/2<1||tmp+i/2>=n)continue;
					count++;
				}
			}
		}
		cout<<count<<endl;
	}



	return 0;

}

Measured memory_bytes: 0
use std::io;


fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut am = (0..n).collect::<Vec<usize>>();
    let mut path = vec![vec![false; n]; n];
    for _ in 0..m {
        let i = read::<usize>();
        let (a, b) = (i[0] - 1, i[1] - 1);
        path[a][b] = true;
        path[b][a] = true;
    }

    let mut ans = 0;
    loop {
        if am[0] == 0 { // needs scope to borrow as mutable
            let mut one = am.windows(2)
                .map(|e| path[e[0]][e[1]]);
            if one.all(|flg| flg) { ans += 1; }
        }
        if !next_permutation(&mut am) { break; }
    }
    println!("{}", ans);
}


#[allow(dead_code)]
/// https://github.com/bluss/permutohedron/blob/master/src/lexical.rs
fn next_permutation<T>(list: &mut [T]) -> bool
where T:
    ::std::cmp::PartialOrd
{
    let mut i = list.len() - 1;
    while i > 0 && list[i - 1] >= list[i] { i -= 1; }
    if i <= 0 { return false; }

    let mut j = list.len() - 1;
    while list[j] <= list[i - 1] { j -= 1; }

    list.swap(i - 1, j);
    list[i..].reverse();
    true
}



#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split(' ')
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    ll n, k;
    cin >> n >> k;
    ll r1 = abs(n - k * (n / k));
    ll r2 = abs(n - k * (n / k + 1));
    cout << min(r1, r2);
}



Measured memory_bytes: 256
def gcd(a, b):
    while b: a, b = b, a%b
    return a

n = int(input())
if n == 2:
    a, b = map(int, input().split())
else:
    a, b, c = map(int, input().split())
    a = gcd(a, c)
m = gcd(a, b)
for i in range(1, m+1):
    if m % i == 0:
        print(i)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<v<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

template <typename T>
T manhattan(T x1,T y1,T x2,T y2){
    ll a=x1-x2,b=y1-y2;
    return max(a,-a)+max(b,-b);
}


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll H;
    cin >> H;
    ll W;
    cin >> W;
    ll D;
    cin >> D;
    vector<vector<ll>> A(H, vector<ll>(W, 0));
    for(ll i=0;i<H;++i)
        for(ll j=0;j<W;++j)cin>>A[i][j];
    vector<ll> wherex(H*W+1,0);
    vector<ll> wherey(H*W+1,0);
    for(ll i=0;i<H;++i)
        for(ll j=0;j<W;++j){
            wherex[A[i][j]]=i;
            wherey[A[i][j]]=j;
        }
    ll Q;
    cin >> Q;
    vector<ll> L(Q,0);
    vector<ll> R(Q,0);
    for(ll i=0;i<Q;++i)cin>>L[i]>>R[i];
    vector<ll> d(H*W+1,INF);
    for(ll i=1;i<=D;++i){
        ll k=i;ll l=0;
        while(1){
            d[k]=l;
            k+=D;
            if(k>H*W)break;
            l+=manhattan(wherex[k-D],wherey[k-D],wherex[k],wherey[k]);
        }
    }
    for(ll i=0;i<Q;++i){
        prt(d[R[i]]-d[L[i]])
    }


    return 0;
}


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

int main() {
  int N, K, h;
  std::cin >> N >> K;
  std::vector<int> heights;
  for (int i = 0; i < N; ++i) {
    std::cin >> h;
    heights.push_back(h);
  }
  std::sort(heights.begin(), heights.end());
  int min = INT32_MAX;
  for (int i = K-1; i < heights.size(); ++i) {
    if (heights[i] - heights[i-(K-1)] < min)
      min = heights[i] - heights[i-(K-1)];
  }
  std::cout << min << std::endl;
}


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

int main()
{
	int n, q, S[100000], T, res = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
	}
	sort(S, S + n);
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> T;
		if (binary_search(S, S + n, T))
			res++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3392
#(44)科目選択
a=[]
for i in range(10):
     n=int(input())
     a.append(n)
a.sort(reverse=True)
b=[]
for j in range(10):
     m=int(input())
     b.append(m)
b.sort(reverse=True)
W=0
K=0
for k in range(3):
     W+=a[k]
     K+=b[k]
print(W,K)



Measured memory_bytes: 5600
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');
const line = input[0].split(' ')
const A = +line[0]
const B = +line[1]
const C = +line[2]
const K = +line[3]

// console.log(`A=${A}`)
// console.log(`B=${B}`)
// console.log(`C=${C}`)
// console.log(`K=${K}`)

if (K <= A) {
    // console.log('A <= K')
    console.log(K)
} else if (K <= A + B) {
    // console.log('A + B <= K')
    console.log(A)
} else {
    const effectiveC = K - (A + B);
    console.log(A - effectiveC)
}


Measured memory_bytes: 29840
/**
 * author: stein
 * created: 2020.08.23 20:03:48
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  long long res = 0;
  for (auto c : s) res += atoi(&c);

  puts((res % 9 == 0) ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[4];
    int cnt=0,temp=0;
   for(int i=0;i<3;i++)
   {
       cin>>a[i];
       if(a[i]==5)
       {
           cnt++;
       }
      else if(a[i]==7)
       {
           temp++;
       }
   }
    if(cnt==2 && temp==1)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }

}


Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 3001
ll arr[MAXN][MAXN];
ll dp[MAXN][MAXN][4];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N,M,K; cin>>N>>M>>K;
    for(ll k=0;k<K;++k)
    {
        ll i,j,v; cin>>i>>j>>v;
        i--; j--;
        arr[i][j] = v;
    }
    
    for(ll i=0;i<N;++i)
    {
        for(ll j=0;j<M;++j)
        {
            if(i == 0 && j == 0) //base case
            {
                dp[0][0][0] = 0;
                dp[0][0][1] = arr[0][0];
                dp[0][0][2] = -1;
                dp[0][0][3] = -1;
                continue;
            }
            
            for(ll k=0;k<=3;++k)
            {
                dp[i][j][k] = -1;
                
                if(j > 0)
                {
                    dp[i][j][k] = dp[i][j - 1][k];
                    if((k > 0) && (dp[i][j - 1][k - 1] != -1))
                        dp[i][j][k] = max(dp[i][j][k],dp[i][j - 1][k - 1] + arr[i][j]);
                }
            }
            
            ll mx = -1;
            for(ll k=0;k<=3;++k)
            {
                if(i > 0)
                    mx = max(mx,dp[i - 1][j][k]);
            }
            
            dp[i][j][0] = max(dp[i][j][0],mx);
            
            if(mx != -1)
                dp[i][j][1] = max(dp[i][j][1],mx + arr[i][j]);
        }
    }
    
    
    ll ans = 0;
    for(ll k=0;k<=3;++k)
        ans = max(ans,dp[N - 1][M - 1][k]);
    cout<<ans<<endl;
}

Measured memory_bytes: 355348
#include <cstdio>
#include <algorithm>
#include <vector>
 
using namespace std;
 
const int N_ = 200500;
 
int X[N_];
long long S[N_];
 
int main()
{
    int N, A; scanf("%d%d", &N, &A);
    for(int i = 1; i <= N; i++) scanf("%d", &X[i]);
 
		for(int i = 1; i <= N; i++) {
			S[i] = S[i-1] + X[i];
		}
 
		long long ans = 1e18;
		for(int k = 1; k <= N; k++) {
			// x_1 + 4x_1 + (9-4) x_2 + (16-9)x_3 + (25-16) x_4....
			// 5x_1 + 5x_2 + 7x_3 + 9x_4 + ...
			long long cur = (long long)A * (k + N);
			for(int i = N, c = 1; i > 0; i -= k, c += 1) {
				cur += (S[i] - S[max(i-k, 0)]) * (c == 1 ? 5 : 2 * c + 1);
              if(cur >= ans) break;
			}
			ans = min(ans, cur);
		}
 
		printf("%lld\n", ans);
 
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int n,m,k,a;
    cin >> n >> m;
    vector<int> ki(m,0);
    rep(i,n) {
        cin >> k;
        rep(j,k) {
            cin >> a;
            ki[a-1]++;
        }
    }
    int count = 0;
    rep(i,m) {
        if(ki[i]==n) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
lit = [list(map(int, input().split(' '))) for i in range(Q)]

comb_list = itertools.combinations_with_replacement([i for i in range(1, M+1)], N)

ans = 0
for c in comb_list:
    ans_tmp = 0
    for l in lit:
        if c[l[1]-1] - c[l[0]-1] == l[2]:
            ans_tmp += l[3]

    if ans < ans_tmp:
        ans = ans_tmp

print(ans)


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

int main() {
  int A,B,C,D;
  int t,a;
  cin >> A >> B >> C >> D;
  t = C/B;
  a = A/D;
  if(C%B != 0){
    t = t+1;
  }
  if(A%D != 0){
  	a = a+1;
  }
  if(t <= a){
  cout << "Yes" << endl;
  }else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>

int main(void){
    char S[100005];
    int i;

    scanf("%s",S);

    int N=strlen(S);
    int f[N];

    for(i=0;i<N;i++){
        f[i]=1;
    }

    for(i=0;i<N-2;i++){
        if(S[i]=='R' && S[i+1]=='R'){
            f[i+2]+=f[i];
            f[i]=0;
        }else if(S[i]=='R' && S[i+1]=='L'){

        }
    }
    for(i=N-1;i>=2;i--){
        if(S[i]=='L' && S[i-1]=='L'){
            f[i-2]+=f[i];
            f[i]=0;
        }else if(S[i]=='L' && S[i-1]=='R'){

        }
    }

    for(i=0;i<N;i++){
        printf("%d ",f[i]);
    }
    return 0;
}

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


#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i) // ROF(i,n,0)
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;

signed main(){
  int n, m; cin >> n >> m;

  vvi d(m);
  rep(i,n){
    int a, b; cin >> a >> b;
    if(m - a >= 0)
      d[m-a].push_back(b);
  }
  priority_queue<int> q;
  int ans = 0;
  ROF(i,m,0){
    for(auto a : d[i])
      q.push(a);
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}

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

int main() {
	int K, X;
	cin >> K >> X;
	for (int i = 0; i < (2*K - 1); i++) {
		if ((X + 1 - K + i) >= -1000000 && (X + 1 - K + i) <= 1000000)cout << X + 1 - K + i << " ";
	}
	cout << endl;
}

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

int main(){
	int n;
  	cin >> n;
  	vector<long> x(n);
  	vector<long> memo(n+1);
  	vector<long> cnt(n+1);
  	for(int i = 0; i < n; i++) {
    	cin >> x[i];
      	cnt[x[i]]++;
      	memo[i+1] = -1;
    }
  	long k = 0;
	for(int i = 1; i <= n; i++) {
		memo[i] = cnt[i] * (cnt[i]-1) / 2;
      	k += memo[i];
    }
  	for(int i = 0; i < n; i++) {
    	k -= memo[x[i]]; 
	      	cout << k + (cnt[x[i]] - 1) * (cnt[x[i]] - 2) / 2 << endl;      
      	k += memo[x[i]];
    }
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

int N, K;
int a[5000];
int dp[5000][5000];

int func(int n, int k) //nまで使ったとき総和をkにできるか
{
	if (dp[n][k] >= 0)
	{
		return dp[n][k];
	}

	if (n == 0)
	{
		return (a[0] == k) ? 1 : 0;
	}

	int res = 0;
	if (func(n - 1, k) == 1)
	{
		res = 1;
	}
	if (k >= a[n])
	{
		if (func(n - 1, k - a[n]) == 1)
		{
			res = 1;
		}
	}
	dp[n][k] = res;
	return res;
}

bool is_need(int m)
{
	int temp = a[m];
	a[m] = 0;
	memset(dp, -1, sizeof(dp));
	bool found = false;
	for (int j = MAX(0, K - temp); j < K; j++)
	{
		if (func(N - 1, j) == 1)
		{
			found = true;
			break;
		}
	}
	a[m] = temp;
	return found;
}

signed main()
{
	cin >> N >> K;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	ARY_SORT(a, N);

	if (is_need(0))
	{
		cout << 0 << endl;
		return 0;
	}
	if (!is_need(N - 1))
	{
		cout << N << endl;
		return 0;
	}

	int l = 0;
	int r = N - 1;
	while (l + 1 < r)
	{
		int mid = ((r - l) / 2) + l;
		if (is_need(mid))
		{
			r = mid;
		}
		else
		{
			l = mid;
		}
	}

	cout << r << endl;
}


Measured memory_bytes: 195840
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P = pair<int,int>;

int main(){
    int n,m,cnt=0;
    cin >> n >>m;
    cnt = (n*(n-1))/2;
    cnt += (m*(m-1))/2;
cout << cnt << endl;
    return 0;
}

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

int main(){
    int n; cin >> n;
    map<string,priority_queue<pair<int,int> > > mp;
    rep(i,n){
        string t; int p;
        cin >> t >> p;
        mp[t].push(make_pair(p,i+1));
    }
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        while(!itr->second.empty()){
            cout << itr->second.top().second << endl;
            itr->second.pop();
        }
    }
    return 0;
}

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

int main() {
	long long int n,i;
	cin>>n;
	
	for(i=sqrt(n);i>=1;i--)
	  {
	  	if(n%i==0)
	  	   break;
	  }
	 //cout<<i; 
	i=n/i; 
	int count1=0;  
	while(1)
	   {
	   		if(i/10!=0)
	   		  {
	   		  	++count1;
	   			i/=10;
	   		  	
	   		  }	
	   		else
	   		   break;
	   }
	  cout<<count1+1<<'\n'; 
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.size();
    if(N == 26){
        if(S == "zyxwvutsrqponmlkjihgfedcba"){
            print(-1);
            return 0;
        }else{
            string t = S;
            next_permutation(t.begin(), t.end());
            rep(i,0,N){
                if(S[i] == t[i]){
                    cout << S[i];
                }else{
                    cout << t[i] << endl;
                    return 0;
                }
            }
            
        }

    }else{
        map<ll,ll> mp;
        rep(i,0,N){
            mp[S[i]]++;
        }
        cout << S;
        rep(i,0,26){
            if(mp[i+'a'] == 0){
                char c = i + 'a';
                cout << c<< endl;
                return 0;
            }
        }
    }

 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;
 
vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}
 
//#define DEBUG
 
ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S;
 
bool field[1000][1000];
 
int main()
{
    cin >> N >> M >> K;
    
    for (int n = 0; n <= N; ++n) {
        for (int m = 0; m <= M; ++m) {
            ll cnt = 0;
            cnt += n * M;
            cnt += m * N;
            cnt -= 2*n*m;
            //cnt -= (M-m) * (N-n);
            //cerr << n << " " << m << " " << cnt << endl;
            if (cnt == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
 
    cout << "No" << endl;
 
    return 0;
}

Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]

total = 0
ans = 0

for i in range(N):
  a = A[i]
  for j in range(M):
    total += a[j] * B[j]
  total = total + C
  if total > 0:
    ans += 1
  total = 0
  
print(ans)

Measured memory_bytes: 3064
from copy import deepcopy
import numpy as np


nk = input().split()
n = int(nk[0])
k = int(nk[1])
ajs = input().split()
ajs = np.log([int(aj) for aj in ajs])
ajs = ajs / ajs.max()

ak_current = ajs[:k].cumsum()[-1]

for i in range(k, n):
  ak_tmp = deepcopy(ak_current)

  ak_tmp =  ak_tmp - (ajs[i-k]) + (ajs[i])
  
  if ak_tmp > ak_current:
    print('Yes')
  else:
    print('No')
    
  ak_current = ak_tmp

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

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
//const------------------------------------------------------------------------------------------------------------------------
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
//global-----------------------------------------------------------------------------------------------------------------------
double ave;
int n, a, b, c, d = 0;
VI toping;
VLL prime_number;
//#define DEBUG
//function-------------------------------------------------------------------------------------------------------------------
int main() {
	scanf( "%d", &n );
	scanf( "%d %d", &a, &b );
	scanf( "%d", &c );
	d += a;
	ave += c;
	rep( i, n ) {
		scanf( "%d", &c );
		toping.PB( c );
	}
	sort( toping.rbegin(), toping.rend() );
	rep( i, n ) {
		if ( ave / d < ( ave + toping[ i ] ) / ( d + b ) ) {
			d += b;
			ave += toping[ i ];
		}
		else {
			break;
		}
	}
	printf( "%d\n", ( int ) ave / d );
	return 0;
}

Measured memory_bytes: 1216