akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int x=sc.nextInt();
		int k=x/500;
		x-=k*500;
		int o=x/5;
		
		pw.println(k*1000l+o*5);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

Measured memory_bytes: 21076
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        
        if( a == 0 && b == 0)
            break;
        
        if(a>b)
        {
            temp = a;
            a = b;
            b = temp;
        }

        cout << a << " " << b << endl;
    }
    
}


Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

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


  int q;
  cin >> q;
  int type[q];
  vector<ll> a;
  vector<ll> b;

  rep(i,q){
    cin >> type[i];
    if(type[i]==1){
      ll ina,inb;
      cin >> ina >> inb;
      a.pb(ina);b.pb(inb);
    }
  }
  ll sumb=0;
  ll cou1=0;
  ll lsum=0;
  ll usum=0;
  priority_queue<long long> small;
  priority_queue<long long, vector<long long>, greater<long long> > large;
  rep(i,q){
    if(type[i]==1){
      sumb+=b[cou1];
      if(i==0){
	small.push(a[i]);
	lsum+=a[i];
      }
      else{
	if(large.size()==0){
	  ll com=small.top();small.pop();
	  lsum-=com;
	  if(com < a[cou1]){
	    small.push(com);
	    large.push(a[cou1]);
	    lsum+=com;usum+=a[cou1];
	  }
	  else{
	    small.push(a[cou1]);
	    large.push(com);
	    lsum+=a[cou1];usum+=com;
	  }
	}
	else{
	  ll sm=small.top();small.pop();
	  ll la=large.top();large.pop();
	  lsum-=sm;usum-=la;
	  vector<ll> so;
	  so.pb(sm);	  so.pb(la);	  so.pb(a[cou1]);
	  sort(so.begin(),so.end());
	  if(small.size()==large.size()){
	    small.push(so[0]);
	    small.push(so[1]);
	    large.push(so[2]);
	    lsum+=so[0]+so[1];usum+=so[2];
	  }
	  else{
	    small.push(so[0]);
            large.push(so[1]);
            large.push(so[2]);
	    lsum+=so[0];usum+=so[1]+so[2];
	  }	 
	}
      }
      cou1++;
    }
    else{
      ll xans = small.top();      
      ll ans=sumb+usum-(lsum-xans);
      if(cou1%2==0) ans -= xans;
      //      cout << "sumb usum -lsum+xans " << sumb << " " << usum << " " << -lsum+xans << endl;
      cout << xans <<" "  <<   ans << endl;
    }
  }
  
  //  cout << endl << endl;
  //  cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << "s"<<endl;
  return 0;
    

}


Measured memory_bytes: 7140
#include<iostream>
#include<cstdio>
int c[4][4];
int main() {
    for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) scanf("%d",c[i]+j);
    bool ok=true;
    int a=c[1][2]-c[1][1],b=c[1][3]-c[1][2];
    if(c[2][2]-c[2][1]!=a||c[2][3]-c[2][2]!=b||c[3][2]-c[3][1]!=a||c[3][3]-c[3][2]!=b) ok=false;
    a=c[2][1]-c[1][1],b=c[3][1]-c[2][1];
    if(c[2][2]-c[1][2]!=a||c[3][2]-c[2][2]!=b||c[2][3]-c[1][3]!=a||c[3][3]-c[2][3]!=b) ok=false;
    printf("%s\n",ok?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
//package ABC171;
import java.util.*;
import java.io.*;
class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		
		long ans=0;
		for(int i=0;i<k;i++)
		{
			ans+=a[i];
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 38868
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n;cin>>n;
        if(n%5==0){cout<<"-1";return 0;}
        if(n%2==0){
            cout<<"-1";
        }
        else{
            ll sum=0,curr=7;
            while(1){
                if(curr%n==0){
                break;}
                curr=(curr*10)%n;
                curr=(curr+7)%n;
                sum++;
            }
            std::cout << sum+1 << "\n";
        }


}


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	if(0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 2616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    if(n % 2 != 0){
        cout << ans << endl;
    }else{
        ll div = 10;
        ll cnt = 1;
        while(n/div != 0){
            ans += (n/div);
            div *= 5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string S; cin >> S;
    if(S == "Sunny") Out("Cloudy");
    if(S == "Cloudy") Out("Rainy");
    if(S == "Rainy") Out("Sunny");

    return 0;
}


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

#define long long long int

using namespace std;

// @author: pashka

bool cmp(const pair<long, long> &q, const pair<long, long> &w) {
    if (q == w)
        return false;
    if (q == make_pair(0ll, 0ll))
        return true;
    if (w == make_pair(0ll, 0ll))
        return false;
    bool side1 = (q.second > 0 || q.second == 0 && q.first < 0);
    bool side2 = (w.second > 0 || w.second == 0 && w.first < 0);

    if (side1 != side2) {
        return side1 < side2;
    }

    long vp = q.first * w.second - q.second * w.first;
    return vp > 0;
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<long, long>> a(2 * n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
        a[i + n].first = -a[i].first;
        a[i + n].second = -a[i].second;
    }

    long y0 = 0;
    long x0 = 0;
    for (int i = 0; i < n; i++) {
        long x = a[i].first;
        long y = a[i].second;
        if (y > 0 || (y == 0 && x < 0)) {
            x0 += x;
            y0 += y;
        }
    }

    sort(a.begin(), a.end(), cmp);

    double res = 0;

    for (int i = 0; i < 2 * n; i++) {
        long x = a[i].first;
        long y = a[i].second;
        x0 += x;
        y0 += y;
        res = max(res, hypot(x0, y0));
    }
    cout << setprecision(20) << res;

    return 0;
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	vector<pii> v(n);
	for(auto& el : v) cin >> el.se >> el.fi;
	SORT(v);
	
	ll t = 0;
	for(auto& el : v)
	{
		t += el.se;
		if(t > el.fi)
			dier("No");
	}
	
	die("Yes");

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main()
{
    char s[52][53];
    int a,b;
    int i,j;
    scanf("%d%d",&a,&b);
    memset(s,0,sizeof(s));
    getchar();
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
            scanf("%c",&s[i][j]);
        }
        getchar();
    }
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
            if(s[i][j]=='.')
            {
                s[i][j]=48;
            }
        }
    }
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b+1;++j)
        {
            if(j==b+1)
            {
                continue;
            }
            if(s[i][j]=='#')
            {
                if(s[i][j-1]!='#')
                {
                    s[i][j-1]++;
                }
                if(s[i][j+1]!='#')
                {
                    s[i][j+1]++;
                }
                if(s[i-1][j]!='#')
                {
                    s[i-1][j]++;
                }
                if(s[i-1][j-1]!='#')
                {
                    s[i-1][j-1]++;
                }
                if(s[i-1][j+1]!='#')
                {
                    s[i-1][j+1]++;
                }
                if(s[i+1][j]!='#')
                {
                    s[i+1][j]++;
                }
                if(s[i+1][j+1]!='#')
                {
                    s[i+1][j+1]++;
                }
                if(s[i+1][j-1]!='#')
                {
                    s[i+1][j-1]++;
                }
            }
        }
    }
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
            printf("%c",s[i][j]);
        }
        printf("\n");

    }
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  ll sum = 1;
  vector<ll> A(N);
  ll m = 1000000000000000000;
  bool t = true;

  rep(i, N) {
    cin >> A[i];
  }
  sum = A[0];
  for(int i = 1; i < N; i++) {
    if (A[i] == 0) {
      sum = 0;
      t = true;
    }
    if (sum != 0) {
      if (m / sum < A[i])
        t = false;
      else
        sum *= A[i];
    }
  }
  if (t)
    cout << sum << endl;
  else
    cout << "-1" << endl;
}


Measured memory_bytes: 3988
module Main where

import Data.Functor

main :: IO ()
main = do
  { [a,b,c] <- getInts
  ; let result = junban (a,b,c)
  ; putStrLn result
  }

junban :: (Int,Int,Int) -> String
junban (x,y,z)
  | x < y && y < z = "Yes"
  | otherwise      = "No"

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)9e18;
int H, W;
vector<string> S(50);
bool node[50][50] = {};
int score[50][50] = {};

void bfs(int sy,int sx){
	queue<pair<int, int>> q;
	q.push({sy,sx});
	node[sy][sx] = false;

	while(!q.empty()){
		int y = q.front().first;
		int x = q.front().second;
		//cout << y << " " << x << endl;
		q.pop();

		if (y == H - 1 && x == W - 1) return;
			
		if(y != 0 && S[y - 1][x] == '.' && node[y - 1][x]){
			node[y - 1][x] = false;
			score[y - 1][x] = score[y][x] + 1;
			q.push({ y - 1,x });
		}
		if (y != H - 1 && S[y + 1][x] == '.' && node[y + 1][x]) {
			node[y + 1][x] = false;
			score[y + 1][x] = score[y][x] + 1;
			q.push({ y + 1,x });
		}
		if (x != 0 && S[y][x - 1] == '.' && node[y][x - 1]) {
			node[y][x - 1] = false;
			score[y][x - 1] = score[y][x ] + 1;
			q.push({ y,x  - 1});
		}
		if (x != W - 1 && S[y][x + 1] == '.' && node[y][x + 1]) {
			node[y][x + 1] = false;
			score[y][x + 1] = score[y][x] + 1;
			q.push({ y,x + 1});
		}		
	}
}



int main() {
	
	cin >> H >> W;
	
	REP(i, H) cin >> S[i];
	REP(i, 50)REP(j, 50) node[i][j] = true;
	score[0][0] = 1;
	bfs(0, 0);
	int white = 0;
	REP(i, H)REP(j, W)if (S[i][j] == '.')white++;



	if (score[H - 1][W - 1] == 0) cout << -1 << endl;
	else cout << white - score[H - 1][W - 1] << endl;
	//cin >> H >> W;
 
	
	
	return 0;
}


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


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    ll N;
    cin>>N;
    v A(N);
    map<ll,ll> sum;
    rep(i,0,N)cin>>A[i];

    rep(i,0,N)sum[A[i]]++;
    ll ans = 0;
    rep(i,0,N+1){
        ans +=  sum[i]*(sum[i]-1)/2;
    }

    rep(i,0,N){
        cout<<ans-sum[A[i]]*(sum[A[i]]-1)/2+(sum[A[i]]-1)*(sum[A[i]]-2)/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;
long long mod(const long long &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
int mod(const int &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
long long modpow(long long a, long long b) {//mod(a^b)を求める
	if (!b)
	{
		return 1;
	}
	if (b < 0) {
		long long ret = 1;
		b = mod(-b);
		ret = modpow(a, MOD - 1 - b);
		return ret;
	}
	long long ret = 1;
	vector<long long> mem(100);//a^(2^k)をメモる
	mem[0] = a;
	for (int i = 1; i < 100; i++)
	{
		mem[i] = mod(mem[i - 1] * mem[i - 1]);
	}
	int now = 0;
	while (b) {
		if (b & 1)
		{
			ret = mod(ret*mem[now]);
		}
		b >>= 1;
		now++;
	}
	return ret;
}
long long fact(long long a) {
	long long ret = 1;
	for (int i = 1; i <= a; i++)
	{
		ret = mod(ret*i);
	}
	return ret;
}
long long combi(long long a, long long b) {//a C bをmodの条件下で求める
	long long ret = fact(a);
	ret = mod(ret * modpow(mod(fact(a - b)*fact(b)), MOD - 2));
	return ret;
}



int n, m;
string s;

int main() {
	cin >> m >> n;
	//(k-1)C(i-1)
	VLL k1(n);
	VLL nk1(n + 1);
	VLL powa(n+1);//iのmod-2乗
	for (int i = 0; i <= n; i++)
	{
		powa[i] = modpow(i, MOD - 2);
	}
	k1[0] = 1;
	for (int i = 0; i < n-1; i++)
	{
		k1[i + 1] = mod(k1[i] * mod((n-1-i)*powa[i + 1]));
	}
	nk1[0] = 1;
	for (int i = 0; i < n; i++)
	{
		nk1[i+1]= mod(nk1[i] * mod((m - n + 1 - i)*powa[i + 1]));
	}
	for (int i = 0; i < n; i++)
	{
		cout << mod(k1[i] * nk1[i + 1])<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, a;
	int k[101];
	long long int dp[101][21];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 21; j++)
		{
			dp[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		cin >> k[i];
	}
	dp[0][k[0]] = 1;
	for (int i = 1; i < n - 1; i++)
	{
		for (int j = 0; j <= 20; j++)
		{
			if (k[i] + j <= 20)
			{
				dp[i][j + k[i]] += dp[i - 1][j];
			}
			if (k[i] <= j)
			{
				dp[i][j - k[i]] += dp[i - 1][j];
			}
		}
	}
	cout << dp[n - 2][k[n - 1]] << endl;
	getchar();
	getchar();
	return 0;
}



Measured memory_bytes: 3108
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize){n;list:#});
    let mut list = list.into_iter()
        .map(|x| {
            let mut v = x.chars().collect::<Vec<_>>();
            v.sort();
            v
        })
        .collect::<Vec<_>>();

    let mut res = Vec::new();
    for c in 'a' as u8..('z' as u8 + 1) {
        let c = c as char;

        while list.clone().into_iter().all(|x| x.len() != 0)
            && list.clone().into_iter().any(|x| x[0] == c)
        {
            if list.clone().into_iter().all(|x| x[0] == c) {
                for i in 0..list.len() {
                    list[i].remove(0);
                }
                res.push(c);
            } else {
                for i in 0..list.len() {
                    if list[i][0] == c {
                        list[i].remove(0);
                    }
                }
            }
        }
    }

    res.into_iter().collect::<String>()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3\ncbaa\ndaacc\nacacac" => "aac",
    test2: "3\na\naa\nb" => "",
}


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

#define MAX 100

int main()
{
    int N;
    scanf("%d",&N);

    int l[MAX];
    int ans=0;

    for(int i=0;i<N;i++){ 
        scanf("%d", &l[i]);
    }

    for(int i=0;i<N;i++){ 
        if((i+1)%2==1 && l[i]%2==1)
            ans++;
    }

    printf("%d",ans);
}

Measured memory_bytes: 1724
n = int(input())
seq =[list(map(int,input().split()))]
ans = 0
while seq:
    L = seq.pop()
    ans += min(L)
    S = [n-min(L) for n in L]
    K = []
    for i in S:
        if i!= 0:
            K.append(i)
        else:
            if K:
                seq.append(K)
                K = []
    else:
        if K:
            seq.append(K)
else:
    print(ans)
    

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

static const int INFTY = (1<<21);

int n, M[100][100];

void BFS(void) {
	queue<int> Q;
	int d[100];
	REP(i, n) d[i] = INFTY;
	d[0] = 0;

	Q.push(0);//?§???????0

	int u;
	while (!Q.empty()) {
		u = Q.front(); Q.pop();
		REP(i, n) {
			if (M[u][i]) {
				if (d[i] == INFTY) {
					d[i] = d[u] + 1;
					Q.push(i);
				}
			}
		}
	}

	REP(i, n) {
		cout << i + 1 << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
	cin >> n;

	REP(i, n) {
		REP(j, n) M[i][j] = 0;
	}

	int u, k, v;
	REP(i, n) {
		cin >> u >> k;
		REP(j, k) {
			cin >> v;
			M[u - 1][v - 1] = 1;//0-origin
		}
	}

	BFS();

	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>

int main()
{
  int i, n, rank;
  int card[4][14] = {0, 0, 0, 0, 0};
  char id;
/*
  for( i = 0 ; i <= 3 ; i++ )
  {
    for( rank = 0 ; rank <= 13 ; rank++ )
      card[i][rank] = 0;
  }
*/
  scanf("%d", &n);

  for( i = 0 ; i < n ; i++ )
  {
    scanf("%c", &id);
    scanf("%c %d", &id, &rank);
    if( id == 'S' )
      card[0][rank] = 1;
    else if( id == 'H' )
      card[1][rank] = 1;
    else if( id == 'C' )
      card[2][rank] = 1;
    else if( id == 'D' )
      card[3][rank] = 1;
  }

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



Measured memory_bytes: 2028
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    cout << (x / 11 * 2) + ((x % 11) ? ((x % 11 > 6) ? 2 : 1) : 0) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int p = s.length();
        if(s.charAt(p-1)=='s')
            System.out.println(s+"es");
        else
            System.out.println(s+"s");
    }
}


Measured memory_bytes: 38440
N=int(input())
s=input()

B=[0]*N
W=[0]*N

if s[0]=="#": W[0]=1
else: B[0]=1

for i in range(1,N):
    if s[i]=="#":
        B[i]=min(B[i-1],W[i-1])
        W[i]=W[i-1]+1

    else:
        B[i]=min(B[i-1],W[i-1])+1
        W[i]=W[i-1]

print(min(B[N-1],W[N-1]))

Measured memory_bytes: 12776
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main(){
    double r;
	cin>>r;
	double a,b;
	a=r*r*3.14159265358979;
	b=r*2*3.14159265358979;
	cout<<fixed<<setprecision(10)<<a<<endl;
	cout<<fixed<<setprecision(10)<<b<<endl;
	return 0;
}

Measured memory_bytes: 1284
n = int(input())
s = input()

count = [0] * n
last = -1

for c in range(26):
    c = chr(ord("a")+c)
    last = -1
    for i in range(n):
        if s[i] == c:
            if last == -1:
                count[i] += 1
            last = i
    count[last] -= 1
 
ans = count[0]
for i in range(1, n):
    count[i] += count[i-1]
    ans = max(ans, count[i])

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
  long long int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0;
  cin >> H;
  long long int count1=0;
  long long int count2=1;
  while(H!=0){
    H=H/2;
    count1++;
    count2=count2*2;
  }
  cout << count2-1 <<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int a = (int)(s[0] - '0');
  int b = (int)(s[1] - '0');
  int c = (int)(s[2] - '0');
  int d = (int)(s[3] - '0');
  if(a+b+c+d==7){
    printf("%d+%d+%d+%d=7\n",a,b,c,d);
  }else if(a+b+c-d==7){
    printf("%d+%d+%d-%d=7\n",a,b,c,d);
  }else if(a+b-c+d==7){
    printf("%d+%d-%d+%d=7\n",a,b,c,d);
  }else if(a+b-c-d==7){
    printf("%d+%d-%d-%d=7\n",a,b,c,d);
  }else if(a-b+c+d==7){
    printf("%d-%d+%d+%d=7\n",a,b,c,d);
  }else if(a-b+c-d==7){
    printf("%d-%d+%d-%d=7\n",a,b,c,d);
  }else if(a-b-c+d==7){
    printf("%d-%d-%d+%d=7\n",a,b,c,d);
  }else if(a-b-c-d==7){
    printf("%d-%d-%d-%d=7\n",a,b,c,d);
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int H, W, M;
int h[300005], w[300005];


int main() {
	cin >> H >> W >> M;
	rep (i, M) cin >> h[i] >> w[i];

	map<P, bool> mp;
	rep (i, M) mp[{h[i], w[i]}] = true;

	V<int> cntH(300005, 0), cntW(300005, 0);
	rep (i, M) cntH[h[i]]++, cntW[w[i]]++;

	int h_id = max_element(rng(cntH)) - cntH.begin();
	int w_id = max_element(rng(cntW)) - cntW.begin();


	vector<int> max_h, max_w;
	rep (i, 300005) {
		if (cntH[i] == cntH[h_id]) max_h.pb(i);
		if (cntW[i] == cntW[w_id]) max_w.pb(i);
	}

	int x = 0;
	bool ok = false;
	rep (i, max_h.size()) rep (j, max_w.size()) {
		x++;
		if (x >= 3 * TEN(5) + 2) {
			cout << cntH[h_id] + cntW[w_id] - !ok << endl;

			return 0;
		}
		if (!mp[{max_h[i], max_w[j]}]) {
			ok = true;
		}
	}


	cout << cntH[h_id] + cntW[w_id] - !ok << endl;

	return 0;
}

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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;

/* function */
//  - none - 


/* code */
int main (void) 
{

  /* Variable_Proclamation */
  int H, W;    // input
  string ans;  // output

  int i, j;    // subscript
  int target_cnt, achieve_cnt;

  int right, bottom;


  /* Input, Array_Proclamation */
  cin >> H >> W;
  vector< vector<char> > s    (H+1, vector<char>(W+1, '.'));
  vector< vector<bool> > board(H+1, vector<bool>(W+1, false));


  for(i=0; i<H; i++)
  {
    for(j=0; j<W; j++)
    {
      cin >> s.at(i).at(j);
    }
  }


  /* Initialize */
  target_cnt  = 0;
  achieve_cnt = 0;


  /* Calculation */
  for(i=0; i<H; i++)
  {
    for(j=0; j<W; j++)
    {
      if( s.at(i).at(j) == '#' )
      {

        target_cnt++;
        right  = i+1;
        bottom = j+1;
        
        if( s.at(right).at(j) == '#' && s.at(i).at(bottom) == '#' )
        {

          achieve_cnt += 3;

          if(board.at(i).at(j) == true)
          {
            achieve_cnt--;
          }
          if(board.at(right).at(j) == true)
          {
            achieve_cnt--;
          }
          if(board.at(i).at(bottom) == true)
          {
            achieve_cnt--;
          }

          board.at(i).at(j)      = true;
          board.at(right).at(j)  = true;
          board.at(i).at(bottom) = true;

        }
        else if( s.at(right).at(j) == '#' )
        {
          achieve_cnt += 2;

          if(board.at(i).at(j) == true)
          {
            achieve_cnt--;
          }
          if(board.at(right).at(j) == true)
          {
            achieve_cnt--;
          }

          board.at(i).at(j)      = true;
          board.at(right).at(j)  = true;

        }
        else if( s.at(i).at(bottom) == '#' )
        {
          achieve_cnt += 2;

          if(board.at(i).at(j) == true)
          {
            achieve_cnt--;
          }
          if(board.at(i).at(bottom) == true)
          {
            achieve_cnt--;
          }

          board.at(i).at(j)      = true;
          board.at(i).at(bottom) = true;

        }

      }
    }
  }

  if(target_cnt == achieve_cnt)
  {
    ans = "Yes";
  }
  else
  {
    ans = "No";
  }
  

  /* Output */
  cout << ans << endl;


  return 0;

}


/* entity */
//  - none -




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Ms(a,b) memset(a,b,sizeof a);
#define db(x) cout<<#x<<"="<<x<<endl;
using namespace std;
int n,d;
int main() {
	scanf("%d%d",&n,&d);
	printf("%d\n",n/(2*d+1)+(n%(2*d+1)!=0));
	return 0;
}


Measured memory_bytes: 256
//CSP2020 J/S RP++
#include <cstdio>
#include <iostream>
using namespace std;

string s;

int main(void){
	cin>>s;
	if(s=="SUN")puts("7");
	if(s=="SAT")puts("1");
	if(s=="FRI")puts("2");
	if(s=="THU")puts("3");
	if(s=="WED")puts("4");
	if(s=="TUE")puts("5");
	if(s=="MON")puts("6");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6;

bool p[N];
vector<int> v;

void sieve(){
    for(int i = 2; i < 55556; i++){
        if(!p[i]){
            if(i%5 == 1)v.push_back(i);
            //cout << i << endl;
            for(int j = i+i; j < 55556; j+=i){
                p[j] = 1;
            }
        }
    }
}



int main(){
    int n, x;

    sieve();
    cin >> n;
    for(int i = 0; i < n; i++){
        cout << v[i] << " ";
    }

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IN(a) scanf("%d",&a);
#define OUT(a) printf(a);
#define REP(i,n) for (i=0;i<(n);i++)
#define BR break;

using namespace std;

int main(){
	int inputcase[10000],i,j;
	for (i=0;i<10000;i++){
		IN(inputcase[i])
		if (inputcase[i]==0)
			BR
	}
	for (j=0;j<i;j++){
		printf("Case %d: %d\n",j+1,inputcase[j]);
	}
	return 0;
 }

Measured memory_bytes: 1224
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define hh putchar(10)
#define gc getchar()
#define ll long long
using namespace std;
#define mtm(a) memset(a,0x3f3f3f3f,sizeof a)
#define mt1(a) memset(a,-1,sizeof a)
#define mt0(a) memset(a,0,sizeof a)
#define fup(i,a,b) for(int i=a,i##e=b;i<=i##e;++i)
#define debug(a) cout<<#a<<'='<<a<<endl

class FIO
{
public:
    template<typename T>FIO& operator >>(T& x){_R(x);return *this;}
    template<typename T>FIO& operator <<(T x){_W(x);return *this;}
private:
    int f,c,a[24],i;
    template<typename T> inline void _R(T& x) {
        for(f=0;(c=getchar())<48;c==45&&(f=1));
        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));
        if(f)x=-x;
    }
    template<typename T> inline void _W(T x) {
        if(sizeof(x)==1){putchar(x);return;}
        if(x<0)putchar(45),x=-x;
        if(x>99) {
            for(i=0;x;x/=10)a[i++]=x%10;
            while(i--)putchar(a[i]+48);
        } else if (x>9)putchar(x/10+48),putchar(x%10+48);
        else putchar(x+48);
    }
}io;


int a[100005],b[100005];
int cnt;
int main()
{
    int n;
    io>>n;
    ll ans=0;
    for(int i=0;i<n;++i) {
        io>>a[i];
        if(a[i]<0)++cnt;
        b[i]=abs(a[i]);
        ans+=b[i];
    }
    sort(b,b+n);
    if(cnt&1)io<<ans-b[0]-b[0];
    else io<<ans;
    return 0;
}





Measured memory_bytes: 4372
// 再提出

#include <stdio.h>
 
char s[100001];
 
int main(void) {
	int len;
 
	scanf("%s%n", s, &len);
 
	int ans = 0;
	for (int l = 0, r = len - 1; l <= r; ) {
		if (s[l] == s[r]) {
			l++;
			r--;
		} else if (s[l] == 'x') {
			l++;
			ans++;
		} else if (s[r] == 'x') {
			r--;
			ans++;
		} else {
			puts("-1");
			return 0;
		}
	}
 
	printf("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
//temmie_のsnippet

#define N 100009

int n,a[N],b[N],c[N];
LL ans=0;

int compA(int x,int y){return a[y]>=x?1:0;}
int compC(int x,int y){return c[y]<=x?1:0;}
LL BS(int x,int n,char c){
	int O=n,X=-1,mid=n/2;
	while(O-X>1){
		mid=(O+X)/2;
		if(c=='a')compA(x,mid)?(O=mid):(X=mid);
		else compC(x,mid)?(O=mid):(X=mid);
	}
	return O;
}

int main(){
	scanf("%d", &n);
	rep(i,n)scanf("%d",a+i);
	qsort(a,n,sizeof(int),acs);
	rep(i,n)scanf("%d",b+i);
	qsort(b,n,sizeof(int),acs);
	rep(i,n)scanf("%d",c+i);
	qsort(c,n,sizeof(int),des);
	rep(i,n)ans+=BS(b[i],n,'a')*BS(b[i],n,'c');
	printf("%lld",ans);
}

Measured memory_bytes: 3276
#!/usr/bin/env python3
import sys,heapq
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10**9+7
ans = 0 ;count = 0 ;pro = 1


def disktra(g,s):
    n=len(g)
    dist = [inf]*n
    dist[s] = 0
    hq=[]
    heapq.heappush(hq,(dist[s],s))
    while hq:
        cost,u =heapq.heappop(hq)
        if dist[u] < cost:
            continue
        for v,c in g[u]:
            if dist[v] <= dist[u] +c:
                continue
            dist[v] = dist[u] + c
            heapq.heappush(hq,(dist[v],v))
    return dist

n,m=map(int,input().split())
g=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    g[a].append((b,1))
    g[b].append((a,1))

dist = disktra(g,0)
if dist[n-1]<=2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

int main(){
        int i, k, len;
        char s[101], str[101];

        scanf("%d %s", &k, s);

        len=strlen(s);
        if(len<=k){
                printf("%s", s);
        }else{
                //strncat(str, s, k);
                for(i=0; i<k; i++){
                        printf("%c",  s[i]);
                }
                printf("...");
        }

        return 0;
}


Measured memory_bytes: 2112
using System;

class Program
{
    static void Main()
    {
        var nt = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        long ans = nt[0] * nt[1];
        for (int i = 0; i < nt[0] - 1; i++) ans -= Math.Max(nt[1] - (inp[i + 1] - inp[i]), 0);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 26592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, x, y;
    cin >> n;
    vector<ll> a, b;
    rep1(i, n){
        cin >> x >> y;
        a.push_back(x+y);
        b.push_back(x-y);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll ans = max(abs(a[0]-a[n-1]), abs(b[0]-b[n-1])); 
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 6636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main(){
 int n; ll ans=0; string s; cin>>n>>s; 
   rep(a,10){
    rep(b,10){
     rep(c,10){
         bool A=false,B=false,C=false;
      rep(i,n){
       if(s[i]-'0'==a&&!A){
         A=true;
         continue;
       }
       if(A&&s[i]-'0'==b&&!B){
         B=true; 
         continue;
       }
       if(B&&s[i]-'0'==c){
         C=true;
         continue;
       }
     }
        if(A&&B&&C){
          ans++;
        }
    }
   }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
"""

連続でない部分列問題…
中央値問題でよくあるのは、その数字以上の数がいくつ出てくるかで二分探索

部分問題：N個ある数列Aから1つ以上取って総和がK以上になる取り方はいくつあるか
→普通にdpするとできるがO(N^2*A)で無理(つーかほぼ答え)

中央値と平均値の関係は？
→今回はすべてのAが1/2の確率で選ばれるので、Aの総和/2 が全てのSの平均値となる
→だからなに・・・


=======解説をみた=======

Aのすべての合計をTとすると、前半はT/2以下で、後半はT/2以上(補集合の関係から)
求めるのは後半の一番小さい数字→T/2以上で登場する最小値

boolのDPになった！
bitsetを使えばオーダーレベルの改善になる
https://w.atwiki.jp/vivid_turtle/pages/40.html
ここに書かれている例に帰着する
"""
import sys

N = int(input())

A = list(map(int,input().split()))

asum = sum(A)

now = 1

for i in range(N):

    now = (now<<A[i]) | now

for i in range((asum+1)//2 , asum+1):

    if (1<<i) & now > 0:
        print (i)
        sys.exit()


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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] p = sc.next().toCharArray();
		boolean okay = false;

		here: for(int i = 0; i < s.length; ++i){
			for(int j = 0; j < p.length; ++j){
				int idx = (i + j) % s.length;
				if(s[idx] != p[j])
					continue here;
			}
			okay = true;
		}
		System.out.println(okay ? "Yes" : "No");
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24448
def main():
    S = input()
    akiba = "kihbr".upper()+"?"
    a = [1, 0, 0, 1, 1, 1]

    ind = 0
    a_num = []
    cnt = 0
    for s in S:
        if s == "A":
            cnt += 1
            continue
        if s != akiba[ind]:
            return "NO"
        if s == akiba[ind]:
            ind += 1
            a_num.append(cnt)
            cnt = 0
    else:
        a_num.append(cnt)

    if len(a_num) < len(a):
        return "NO"
    for x, y in zip(a, a_num):
        if y > x:
            return "NO"

    return "YES"


if __name__ == "__main__":
    print(main())


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

const int margin = 2;

bool check(int i, int j, char c, char table[128][128]) {
	if(table[i + margin][j + margin] != c || c == 0) {
		return false;
	}

	table[i + margin][j + margin] = 0;
	check(i + 1, j, c, table);
	check(i - 1, j, c, table);
	check(i, j + 1, c, table);
	check(i, j - 1, c, table);

	return true;
}

int main() {
	int H, W;

	while(cin >> H >> W, H | W) {
		char in[128][128] = {0};
		int ans = 0;
		for(int i = 0; i < H; i++) {
			scanf("%s", in[i + margin] + margin);
		}

		for(int i = 0; i < H; i++)
			for(int j = 0; j < W; j++) {
				if(check(i, j, in[i + margin][j + margin], in))
					ans++;
			}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define t(x) cerr<<#x<<":"<<x<<'\n';
#define t2(a,n) { cerr<<#a<<" = "; for(int i=0; i<n; ++i){ cerr << a[i] << ' '; } ; cerr <<'\n'; }
#define t3(a){ cerr<<#a<<" = "; for(auto i: a){ cerr<<i<<" "; } cerr<<'\n'; }
const int N = 1e5+5;
vector<pair<pair<int,int>,ll>> data;
typedef pair<ll,int> pi;
vector<pi> adj[N];
int no,m;

void Prims(){
  for(int i=0; i<data.size(); ++i){
    int a,b; ll w;
    a = data[i].first.first;
		b = data[i].first.second;
		w = data[i].second;
    a--; b--;
    adj[a].push_back({w,b});
    adj[b].push_back({w,a});
  }
  ll ans = 0;
  priority_queue<pi, vector<pi>, greater<pi>> pq;
  set<int> done;
  for( auto i : adj[0] ){
    pq.push(i);
  }
  done.insert(0);
  while(!pq.empty()){
    auto x = pq.top(); pq.pop();
    if( done.find(x.second) == done.end() ){
      ans += x.first;
      for(auto j : adj[x.second] ){
        pq.push(j);
      }
      done.insert(x.second);
    }
  }
  cout<<ans<<'\n';
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<pair<pair<ll,ll>,int>> pts,pt2;
	for(int i=0; i<n; ++i){
		ll x,y;cin>>x>>y;
		pts.push_back({{x,y},i+1});
		pt2.push_back({{y,x},i+1});
	}
	sort(pts.begin(),pts.end());
	sort(pt2.begin(),pt2.end());
	ll ans = 0;
	ll ans2=0;
	for(int i=1; i<n; ++i){
		int a1 = pts[i].second;
		int a2 = pts[i-1].second;
		data.push_back({ {a1,a2}, (ll)abs(pts[i].first.first- pts[i-1].first.first) });
		a1 = pt2[i].second;
		a2 = pt2[i-1].second;
		data.push_back({ {a1,a2}, (ll)abs(pt2[i].first.first- pt2[i-1].first.first) });
	}
	Prims();



	#ifdef LOL
	    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}


Measured memory_bytes: 29088