akhauriyash/Code-Regression huggingface dataset:
/*
Written By mafailure
*/
//In the name of God
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long 
//#define int long long 
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define frr(i,init,final) for(int i=init;i>=final;i--)
#define Fr(i,final) for(int i=0;i<final;i++)
#define Frr(i,first) for(int i=first;i>=0;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;
#define setb __builtin_popcount
#define lsone(n) (n&(-n))
#define rlsone(n) (n&(n-1))

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set; 
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int power(int x, int y)
{ 
	if(y==0)return 1;
	int u=power(x,y/2);
	u=(u*u)%mod;
	if(y%2)u=(x*u)%mod;
	return u;
    
}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{
	
	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int n; cin>>n ; vi a(n);
	int maxd=0;
	int ans=0;
	fr(i,0,n) cin>>a[i],maxd=max(maxd,a[i]),ans+=(maxd-a[i]);
	cout<<ans<<endl;
	
}



Measured memory_bytes: 4780
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        PriorityQueue<Integer> q=new PriorityQueue<>();
        
        int n=sc.nextInt();
        int e[]=sc.nextIntArray(n);
        int d[]=new int[n+1];
        if(e[0]!=0)ret("0");
        for (int i = 0; i < n; i++) {
			d[e[i]]++;
		}
		if(d[0]!=1)ret("0");

		int w=0;
        long a=1;
        for (int i = 0; i < d.length; i++) {
			w+=d[i];
			if(w==n)break;
			for (int j = 0; j < d[i+1]; j++) {
				a*=d[i];
				a%=998244353L;
			}
		}

        out.println(a);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


class P {
	int x, y, d;
	P(int  x, int y, int d) {
	  this.x=x;
	  this.y=y;
	  this.d=d;
	}
}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return p.a-a;//des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 34436
#include <bits/stdc++.h>
#define P 1000000007
#define ll long long
#define ld long double
#define pii pair<int, int>
#define F first
#define S second

using namespace std;



ld dp[303][303][303];
bitset<303> v[303][303];
int n, h[3];


ld rec(int a, int b, int c){

	if(v[a][b][c]) return dp[a][b][c];

	v[a][b][c] = 1;

	ld fa = a, fb = b, fc = c, fn = n;

	ld tot = 0.0;

	if(a>0) tot += fa*(rec(a-1, b, c)+1);
	if(b>0) tot += fb*(rec(a+1, b-1, c)+1);
	if(c>0) tot += fc*(rec(a, b+1, c-1)+1);

	tot /= (fa+fb+fc);
	tot += (fn-fa-fb-fc)/(fa+fb+fc);

	dp[a][b][c] = tot;

	return tot;
	
}

int main(){

	cin >> n;

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

	v[0][0][0] = 1;
	dp[0][0][0] = 0;

	cout << setprecision(12) << rec(h[0], h[1], h[2]) << endl;
	
	return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n, d, x;
	cin >> n >> d >> x;

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

	int res = x;
	rep (i, 0, n) {
		int j = 1;
		while (j < d + 1) {
			res++;
			j += a[i];
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [0 for _ in range(N)]

    for i in range(1, N):
        tmp = [dp[j]+abs(h[i]-h[j]) for j in range(max(0, i-K), i)]

        dp[i] = min(tmp)

    print(dp[-1])

main()


Measured memory_bytes: 13928
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();
ll dfs(ll i, ll sum);

ll n;
ll s[110];

int main() {
  cin >> n;
  rep(i, n) cin>> s[i];


  solve();

  return 0;
}

void solve() {
  ll sum = 0;
  rep(i, n) sum += s[i];

  sort(s, s+n);

  if(sum%10!=0) {
    cout << sum << endl;
    return;
  }

  rep(i, n) {
    if(s[i]%10!=0) {
      cout << sum-s[i] << endl;
      return;
    }
  }

  cout << 0 << endl;

  return;
}

Measured memory_bytes: 256
n = int(input())
d = {}
for i in range(n):
  a = int(input())
  if a in d:
    if d[a] <= 0:
      d[a] += 1
    else:
      d[a] -=1
  else:
    d[a] = 1
cnt = 0
for i in d.values():
  if i > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 15076
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/


int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       int n;
       cin>>n;
       vi v(n);
       vi b(n);
       map<int,int>M;
       M[1]=1;
       M[0]=1;
       M[2]=2;
       M[3]=6;
       M[4]=24;
       M[5]=120;
       M[6]=720;
       M[7]=5040;
       ll x=0,y=0;
       ll k=n-1;
       for(int i=0;i<n;i++)cin>>v[i];
       for(int i=0;i<n;i++)cin>>b[i];
        vector<bool>vis1(9,false);
        vector<bool>vis2(9,false);
       for(int i=0;i<n;i++){
          for(int j=1;j<v[i];j++){
               if(!vis1[j])x+=M[k];
          }
          vis1[v[i]]=true;
          for(int j=1;j<b[i];j++){
               if(!vis2[j])y+=M[k];
          }
          vis2[b[i]]=true;
          k--;
       }
     //  cout<<x<<endl;
      // cout<<y<<endl;
       cout<<abs(x-y)<<endl;
    }
}















Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string letter;
    cin >> letter;

    if (letter == "a" 
        || letter == "e"
        || letter == "i" 
        || letter == "o" 
        || letter == "u") 
    {
       cout << "vowel" << endl;
    }
    
    else
    {
        cout << "consonant" << endl;
    }
    
}

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 rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    string s; cin >> s;
    int aa = 0;
    int bb = 0;
    rep(i,n){
        int flag = 0;
        if(s[i]=='a'){
            if(aa+bb<a+b){
                flag = 1;
                aa++;
            }
        }
        if(s[i]=='b'){
            if(aa+bb<a+b&&bb<b){
                flag = 1;
                bb++;
            }
        }
        if(flag==1)yn;
    }

    return 0;
}
 
 


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

class DisjointSet {
 public:
  std::vector<unsigned> parent;
  std::vector<unsigned> rank;
  DisjointSet(unsigned size)
      : parent(size),
        rank(size, 0u) {
    for (unsigned i = 0; i < size; ++i) { parent[i] = i; }
  }
  unsigned find(unsigned index) {
    if (parent[index] != index) { return parent[index] = find(parent[index]); }
    else { return index; }
  }
  void merge(unsigned index_a, unsigned index_b) {
    auto parent_a = find(index_a);
    auto parent_b = find(index_b);
    if (parent_a == parent_b) { return; }
    if (rank[parent_a] < rank[parent_b]) { parent[parent_a] = parent_b; }
    else if (rank[parent_b] < rank[parent_b]) { parent[parent_b] = parent_a; }
    else {
      ++rank[parent_a];
      parent[parent_b] = parent_a;
    }
  }
};

int main() {
  unsigned N;
  std::cin >> N;
  using pu = std::pair<std::pair<unsigned, unsigned>, unsigned>;
  std::vector<pu> town(N);
  DisjointSet disjointSet(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> town[i].first.first >> town[i].first.second;
    town[i].second = i;
  }
  std::sort(town.begin(), town.end(),
            [](pu i, pu j) -> bool {
              return i.first.first < j.first.first
                  || (i.first.first == j.first.first && i.first.second < j.first.second);
            });
  for (unsigned i = 0; i < N - 1; ++i) {
    if (town[i].first == town[i + 1].first) {
      disjointSet.merge(town[i].second, town[i + 1].second);
    }
  }
  std::vector<pu> horiz(N - 1);
  for (unsigned i = 0; i < N - 1; ++i) {
    horiz[i].second = town[i + 1].first.first - town[i].first.first;
    horiz[i].first.first = town[i].second;
    horiz[i].first.second = town[i + 1].second;
  }
  std::sort(horiz.begin(), horiz.end(), [](pu i, pu j) -> bool { return i.second < j.second; });
  std::sort(town.begin(), town.end(),
            [](pu i, pu j) -> bool {
              return i.first.second < j.first.second
                  || (i.first.second == j.first.second && i.first.first < j.first.first);
            });
  std::vector<pu> vert(N - 1);
  for (unsigned i = 0; i < N - 1; ++i) {
    vert[i].second = town[i + 1].first.second - town[i].first.second;
    vert[i].first.first = town[i].second;
    vert[i].first.second = town[i + 1].second;
  }
  std::sort(vert.begin(), vert.end(), [](pu i, pu j) -> bool { return i.second < j.second; });
  unsigned long long cost = 0;
  auto ph = horiz.begin();
  auto pv = vert.begin();
  while (ph < horiz.end() || pv < vert.end()) {
    if (ph < horiz.end() && (pv >= vert.end() || ph->second < pv->second)) {
      if (disjointSet.find(ph->first.first) != disjointSet.find(ph->first.second)) {
        cost += ph->second;
        disjointSet.merge(ph->first.first, ph->first.second);
      }
      ++ph;
    } else {
      if (disjointSet.find(pv->first.first) != disjointSet.find(pv->first.second)) {
        cost += pv->second;
        disjointSet.merge(pv->first.first, pv->first.second);
      }
      ++pv;
    }
  }
  std::cout << cost;
  return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
const int N=1001;
vector<int> G[N*N];
int id[N][N], indegree[N*N];

int toId(int i, int j) {
    if ( i>j ) swap(i,j);
    return id[i][j];
}


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<VI> a(n, VI(n-1));
    REP(i,n) REP(j,n-1) {
        cin >> a[i][j];
        a[i][j]--;
    }
    int V=0;
    REP(i,n) REP(j,n) {
        if ( i<j ) {
            id[i][j]=V++;
        }
    }
    REP(i,n) {
        REP(j,n-1) {
            a[i][j]=toId(i,a[i][j]);
        }
        REP(j,n-2) {
            G[a[i][j]].push_back(a[i][j+1]);
            indegree[a[i][j+1]]++;
        }
    }
    VI q;
    REP(i,V) if ( indegree[i]==0 ) q.push_back(i);
    int day=0;
    while ( q.size() ) {
        day++;
        VI nq;
        for ( int i:q ) {
            for ( int u:G[i] ) {
                indegree[u]--;
                if ( indegree[u]==0 ) nq.push_back(u);
            }
        }
        q=nq;
    }
    REP(i,V) {
        if ( indegree[i]!=0 ) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << day << '\n';
    return 0;
}

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

const int N = 3;
char s[N];
int price;

void solve() {
  price = 700;
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'o') price += 100;
  }
  cout << price << endl;
}

int main() {
  cin >> s;
  solve();
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long int ll;
const int MOD=1e9+7;
const int N=1e3+10;
ll fac[N];
ll pow(ll a,ll t){
    if(t==0)return 1;
    ll temp=pow(a,t/2);
    temp*=temp;
    temp%=MOD;
    if(t&1){
        temp*=a;
        temp%=MOD;
    }
    return temp;
}
ll rev(ll n){return pow(n,MOD-2);}
ll C(int n,int k){return (fac[n]*((rev(fac[k])*rev(fac[n-k]))%MOD))%MOD;}
void init(){
    fac[0]=fac[1]=1;
    for(int i=2;i<N;i++)fac[i]=(fac[i-1]*i)%MOD;
    return ;
}
int main(){
    int n,k,now=1;
    ll ans=0;
    scanf("%d%d",&n,&k);
    if(n<k)printf("0\n");
    else{
        init();
        for(int i=0;i<k;i++){
            ans+=now*((pow(k-i,n)*C(k,i))%MOD);
            ans%=MOD;
            now=-now;
        }
        ans+=MOD;
        ans%=MOD;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 2736
import java.util.Scanner;

// https://atcoder.jp/contests/abc166/tasks/abc166_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();


		if(s.equals("ABC")) {
			System.out.println("ARC");
		}else {
			System.out.println("ABC");
		}

	}
}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int k;
ll ans=0;
ll gcd(int a,int b,int c)
{
	while(b!=0)
	{
		a%=b;swap(a,b);
	}
	while(c!=0)
	{
		a%=c;swap(a,c);
	}
	return a;
}
int main()
{
	cin>>k;
	rep(i,k)
	rep(j,k)
	rep(l,k)
	{
		ans+=gcd(i,j,l);
	}
	re(ans)
	return 0;}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T &a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T &a, T b) {
	a = std::min(a, b);
}

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)
			return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)
		return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i;
		res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m = mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)
		return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod ;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int> engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/

int n, m, a[100005];
int sum[100005];
signed main() {
	cin >> n >> m;
	REP(i,n+1)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	REP(i,n+1)
	{
		sum[i] += a[i];
		sum[i + 1] += sum[i];
	}
	int ok = inf, ng = 0;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		int sum = 0;
		REP(i,n+1)
		{
			int ko = lower_bound(a+1, a + n+1, mid - a[i])-a;
			sum+=n-ko+1;
		}
		if(sum<=m)ok=mid;
		else ng=mid;
	}
	vector<int>v;
	int all=0;
	int ans=0;
	REP(i,n+1){
		int ko=lower_bound(a+1,a+n+1,ok-a[i])-a;
		all+=n-ko+1;
		ans+=sum[n]-sum[ko-1];
		ans+=a[i]*(n-ko+1);
		if(ko!=1){
			v.push_back(a[i]+a[ko-1]);
		}
	}
	sort(all(v),greater<>());
	ans+=(m-all)*(ok-1);
	cout<<ans<<endl;
}


Measured memory_bytes: 2936
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long nums[] = new long[n];
		long dp[] = new long[n];		
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for(int i = 0 ; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			if(i + 1 < n)
				dp[i+1] = Math.min(dp[i+1],  Math.abs(nums[i] - nums[i+1]) + dp[i]);
			if(i + 2 < n)
				dp[i+2] = Math.min(dp[i+2],  Math.abs(nums[i] - nums[i+2]) + dp[i]);
		}
		System.out.println(dp[n-1]);
	}
}


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

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

#define loop(i, n) for(int i = 0;i < n;i++)
#define IINF 2e9
#define MOD 1e9+7

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int wdx[5] = {-2, -1, 0, 1, 2};
int wdy[5] = {-2, -1, 0, 1, 2};

int h, w;
int ch, cw, dh, dw;
vector<string> field;


void bfs(vector<vector<int>> &check, queue<P> &que, queue<P> &next){
    while(!que.empty()){
        P q = que.front(); 
        next.push(que.front());
        que.pop();

        loop(i, 4){
            int ny = q.first + dy[i];
            int nx = q.second + dx[i];

            if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
            if(field[ny][nx] == '.' && check[ny][nx] == IINF){
                que.push(P(ny, nx));
                next.push(P(ny, nx));
                check[ny][nx] = check[q.first][q.second];
            }
        }
    }
}

void bfsNext(vector<vector<int>> &check, queue<P> &que, queue<P> &next){
    while(!next.empty()){
        P q = next.front(); next.pop();
        // cout << "q.first" << q.first << " q.second:" << q.second << endl;

        loop(i, 5){
            loop(j, 5){
                int ny = q.first + wdy[i];
                int nx = q.second + wdx[j];
                if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
                if(field[ny][nx] == '.' && check[ny][nx] == IINF){
                    // cout << "ny:" << ny << " nx:" << nx << endl;
                    que.push(P(ny, nx));
                    // next.push(P(ny, nx));
                    check[ny][nx] = check[q.first][q.second] + 1;
                }
            }
        }
    }
}

int main(void){

    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;

    loop(i, h){
        string x; cin >> x;
        field.push_back(x);
    }

    vector<vector<int>> check(h, vector<int>(w, IINF));
    queue<P> que;
    queue<P> next;

    bool first = true;

    check[ch][cw] = 0;
    que.push(P(ch, cw));
    next.push(P(ch, cw));

    do{
        if(first == false) bfsNext(check, que, next);
        bfs(check, que, next);
        first = false;
        // bfsNext(check, que, next);
        if(check[dh][dw] != IINF) break;
    }while(!next.empty());

    cout << (check[dh][dw] == IINF ? -1 : check[dh][dw]) << endl;

    // loop(i, h){
    //     loop(j, w){
    //         cout << check[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    return 0;
}

Measured memory_bytes: 8704
#include "bits/stdc++.h"
using namespace std;

int h[220][220];
int u[220][220];
int ans[7];
void init(){
    for(int i = 1; i <= 6; i++)ans[i] = 0;
    for(int i = 0; i < 220; i++){
        for(int j = 0; j < 220; j++){
            ans[u[i][j]]++;
            u[i][j] = 0;
            h[i][j] = 0;
        }
    }

}

int dice[6];

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
void rot(int a){
    int tmp[6];
    for(int i = 0; i < 6; i++)tmp[i] = dice[i];
    if(a == 0){
        dice[0] = tmp[3];
        dice[1] = tmp[0];
        dice[5] = tmp[1];
        dice[3] = tmp[5];
    }
    if(a == 1){
        dice[0] = tmp[4];
        dice[2] = tmp[0];
        dice[4] = tmp[5];
        dice[5] = tmp[2];
    }
    if(a == 2){
        dice[0] = tmp[1];
        dice[1] = tmp[5];
        dice[5] = tmp[3];
        dice[3] = tmp[0];
    }
    if(a == 3){
        dice[0] = tmp[2];
        dice[2] = tmp[5];
        dice[4] = tmp[0];
        dice[5] = tmp[4];
    }
}

int calc[7][7] = {
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 3, 5, 2, 4, 0},
    {0, 4, 0, 1, 6, 0, 3},
    {0, 2, 6, 0, 0, 1, 5},
    {0, 5, 1, 0, 0, 6, 2},
    {0, 3, 0, 6, 1, 0, 4},
    {0, 0, 4, 2, 5, 3, 0}
};

void drop(int t, int f){
    dice[0] = t;
    dice[1] = f;
    dice[2] = calc[t][f];
    dice[3] = 7 - dice[1];
    dice[4] = 7 - dice[2];
    dice[5] = 7 - dice[0];
    for(int x = 100, y = 100, cnt = 0;cnt < 5;cnt++){
        // cout << x << ", " << y << endl;
        int idx = 0;
        int val = 0;
        for(int i = 1; i <= 4; i++){
            if(h[y][x] > h[y + dy[i-1]][x + dx[i-1]]){
                if(val < dice[i]){
                    idx = i;
                    val = dice[i];
                }
            }
        }
        if(val < 4){
            h[y][x]++;
            u[y][x] = dice[0];
            break;
        }
        else{
            rot(idx - 1);
            y += dy[idx - 1];
            x += dx[idx - 1];
        }
    }
}
int main(){

    for(int n; cin >> n, n; ){
        for(int i = 0; i < n; i++){
            int t, f;
            cin >> t >> f;
            drop(t, f);
            // for(int y = 99; y <= 101; y++){
            //     for(int x = 99; x <= 101; x++){
            //         cout << u[y][x];
            //     }
            //     cout << endl;
            // }
            // cout << endl;
        }
        init();
        for(int i = 1; i <= 6; i++){
            cout << ans[i];
            if(i == 6)cout << endl;
            else cout << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 3444
import std.algorithm;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto n = readln.strip.to!( int );
	auto as = readln.split.to!( int[] );
	writeln( solve( as ) );
}

auto solve( in int[] as )
{
	auto mi = as.reduce!( min );
	auto ma = as.reduce!( max );
	return ma - mi;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pub push_back
#define pob pop_back
#define M 1000000007
#define pii pair<ll,ll>
#define mp make_pair
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    ll n,i,z[30]={0},x=0,ans=0;
    string s;
    cin>>n;
    cin>>s;
    for(i=0;i<n;i++)
    {
    	z[s[i]-97]++;
    }
    
    for(i=0;i<26;i++)
    {
      if(z[i]==0)continue;
      x=z[i]*(1+ans);
      x%=M;
      ans+=x;
      ans%=M;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	char a[26];
	a[0] = 'a';
	int x[26];
	int flag = 0;
	string s;
	for (int i = 0;i < 26;i++)
	{
		x[i] = 0;
		a[i + 1] = a[i] + 1;
	}
	cin >> s;
	for (int i = 0;i < s.length();i++)
	{
		for (int j = 0;j < 26;j++)
		{
			if (s[i] == a[j])
				x[j]++;
		}
	}
	for (int i = 0;i < 26;i++)
	{
		if (x[i] % 2 != 0)
			flag = 1;
	}
	if (flag == 1)
		cout << "No";
	else
		cout << "Yes";
}

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

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

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

    int n;
    cin >> n;

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

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

    if (n % 2 == 0) {
        for (int i = 0; i < n; i++) {
            if (a[i] != (i / 2) * 2 + 1) {
                cout << 0 << endl;
                return 0;
            }
        }

    } else {
        if (a[0] != 0) {
            cout << 0 << endl;
            return 0;
        }
        for (int i = 1; i < n; i++) {
            if (a[i] != ((i + 1) / 2) * 2) {
                cout << 0 << endl;
                return 0;
            }
        }
    }

    long long int sum = 1;
    for (int i = 0; i < a.size() / 2; i++) {
        sum *= 2;
        sum %= 1000000007;
    }

    cout << sum << endl;
}

Measured memory_bytes: 640
//
//AtCoder Beginner Contest 134
//A - Dodecagon
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int h,w;
  for(int i=0; i<10000; i++) {
      cin >> h >> w;
      if(h==0&&w==0) {
          return 0;
      }
      for(int j=0; j<h; j++) {
          for(int k=0; k<w; k++) {
              if(j%2==0&&k%2==0) {
                  cout << "#";
              }
              else if(j%2==0&&k%2!=0) {
                  cout << ".";
              }
              else if(j%2!=0&&k%2==0) {
                  cout << ".";
              }
              else {
                  cout << "#";
              }
          }
          cout << endl;
      }
      cout << endl;
  }
}


Measured memory_bytes: 3080
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 479001599;
const int maxn = 3e6 + 111;
        
using namespace std;          

string s;

void solve(){
	cin >> s;

	for (int i = 0; i < sz(s); i++)
		cout << 'x';
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

    boost;
    
    int q = 1;
 
    //cin >> q;
    
    while (q--){
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}

constexpr ll LNF = 1LL<<50;

constexpr int INF = 1e9+7;

const long double PI=3.14159265358979323846;


vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};

/* template */

ll Pow(ll x, ll n){
    ll res = 1;
    while(n>0){
        if(n&1) res = res *x;
        x = x*x;
        n>>=1;
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    ll x = 0;
    rep(i,0,n){
        cin >> a[i];
        x ^= a[i];
    }
    rep(i,0,n){
        ll ans = x^a[i];
        cout << ans << endl;
    }
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	string s; cin >> s;
	for(int i = 0; i < s.size(); i++){
		int cnt = 0;
		for(int j = 0;j < n; j++){
			if(s.at(i) == 'Z') s.at(i) = 'A';
			else s.at(i)++;
		}
	}
	cout << s << endl;
} 

Measured memory_bytes: 256
n = int(input())
list_x = list(map(int, input().split()))

def cost_calc(list_x, p):
  cost = 0
  for x in list_x:
    cost += (x - p)**2
  return cost

cost = 10**20
for _ in range(min(list_x),max(list_x)+1):
  tmp = cost_calc(list_x, _)
  if tmp < cost:
    cost = tmp
print(cost)

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

void checkCircleOnRectangle(int w, int h, int x, int y, int r)
{
    bool isOn = ((0 <= x - r && x + r <= w) && 
                 (0 <= y - r && y + r <= h));
    cout << (isOn ? "Yes" : "No") << endl;
}

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    checkCircleOnRectangle(w, h, x, y, r);
    
    return 0;
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
 
public class D {
    public static void Main(){
        string[] line = Console.ReadLine().Split(' ');
        int N = int.Parse(line[0]);
        int K = int.Parse(line[1]);
        line = Console.ReadLine().Split(' ');
        List<int> p = new List<int>();
        List<double> average = new List<double>();
        for (int i=0;i<line.Length;i++)
        {
            p.Add(int.Parse(line[i]));
            average.Add(GetAverage(p[i]));
        }

        double maxsum = 0.0;
        double tempsum = 0.0;
        for (int i=0;i<K;i++)
        {
            maxsum += average[i];
        }
        tempsum = maxsum;
        for (int i=0;i<p.Count-K;i++)
        {
            tempsum = tempsum - average[i];
            tempsum += average[i+K];
            if (tempsum > maxsum)
            {
                maxsum = tempsum;
            }
        }
        Console.WriteLine(maxsum);
    }
    
    // 期待値
    private static double GetAverage(int p)
    {
        double avg = 0.0;
        for (int i=1;i<=p;i++)
        {
            avg += (double)i;
        }
        return (double)(avg / p);
    }
}

Measured memory_bytes: 31452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> res(26, 0);
  rep(i, n) {
    string s;
    cin >> s;
    vector <ll> tmp(26, 0);
    rep(j, s.size()) {
      ll num = s.at(j) - 'a';
      tmp.at(num)++;
    }
    rep(j, 26) {
      if (i) {
        res.at(j) = min(res.at(j), tmp.at(j));
      } else {
        res.at(j) = tmp.at(j);
      }
    }
  }
  rep(i, 26) {
    rep(j, res.at(i)) {
      char c = 'a' + i;
      cout << c;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  ll N;
  cin>>N;
  vector<tuple<ll,ll,ll>> t(N);
  for (int i(0);i<N;i++) {
    ll a,b;
    cin>>a>>b;
    t[i] = make_tuple(a+b,a,b);
  }
  sort(t.rbegin(),t.rend());
  ll ta(0),ao(0);
  for (int i(0);i<N;i++){
    if (i%2==0){
      ta += get<1>(t[i]);
    }else{
      ao += get<2>(t[i]);
    }
  }
  cout<< ta - ao << endl;
  return 0;
}


Measured memory_bytes: 2560
module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector.Unboxed as V

main :: IO ()
main = do
  [a, x] <- map read . words <$> getLine
  as <- replicateM a readLn
  let s = sum as
  print $ length as + ((x - s) `div` (minimum as))

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll x;
    cin>>x;
    long double y;
    cin>>y;
    ll z=x*y;
    cout<<z<<endl;
    return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>
int max(int a,int b){
    if(a<b){
        return b;
    }
    else{
        return a;
    }
}
int min(int a,int b){
    if(a<b){
        return a;
    }
    else{
        return b;
    }
}
int main(int argc, char *argv[]){
    int A,B,C,ans;
    scanf("%d %d %d",&A,&B,&C);
    ans=max(max(A,B),C)-min(min(A,B),C);
    printf("%d",ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
using namespace std;
string s[8];
int dx[8]={1,1,1,0,-1,-1,-1,0};
int dy[8]={1,0,-1,-1,-1,0,1,1};
char turn[2]={'o','x'};
typedef pair<int, int> pii;

bool inMap(int x, int y){
  if(0 <= x && x < 8 &&
     0 <= y && y < 8)
    return true;
  return false;
}

int count(int x, int y, int t){
  if(s[y][x] != '.')return 0;
  
  int length[8] = {0};
  int r,res = 0;
  int nt = (t + 1)&1;
  for(int i = 0; i < 8; i++){
    r = 0;

    while(inMap(x + (r + 1)*dx[i], y + (r + 1)*dy[i]) &&
	  s[y + (r + 1)*dy[i] ][x + (r + 1)*dx[i] ] == turn[nt]){
      length[i]++;
      r++;
    }

    if(!inMap(x + (r + 1)*dx[i], y + (r + 1)*dy[i]) ||
      s[y + (r + 1)*dy[i] ][x + (r + 1)*dx[i] ] != turn[t]){
      length[i] = 0;
    }
  }

  for(int i = 0; i < 8; i++){
    res += length[i];
  }
  //cout << res << endl;
  return res;
}


void update(int x, int y, int t){
  int r;
  int nt = (t + 1)&1;
  s[y][x] = turn[t];
  for(int i = 0; i < 8; i++){
    r = 0;
    while(inMap(x + (r + 1)*dx[i], y + (r + 1)*dy[i]) &&
	  s[y + (r + 1)*dy[i] ][x + (r + 1)*dx[i] ] == turn[nt]){
      r++;
    }


    if(inMap(x + (r + 1)*dx[i], y + (r + 1)*dy[i]) &&
       s[y + (r + 1)*dy[i] ][x + (r + 1)*dx[i] ] == turn[t]){
      while(0 < r){
	s[y + r*dy[i] ][x + r*dx[i] ] = turn[t];
	r--;
      }
    }

  }
}


int main(){
  for(int i = 0; i < 8; i++)cin>>s[i];
  int greatest = -1, t = -1;
  pii pos;
  int pass = 0;
  while(pass < 2){
    greatest = 0;
    t++;
    t = t&1;
    //cout << turn[t] << endl;
    pos = pii(-1, -1);
    for(int i = 0; i < 8; i++){
      for(int j = 0; j < 8; j++){
	int tmp = count(j, i, t);
	//cout << tmp << endl;
	if(t){
	  if(greatest <= tmp){
	    //cout << "f" << endl;
	    greatest = tmp;
	    pos = pii(j, i);
	    // cout << greatest << endl;
	    // cout << pos.first << " " << pos.second << endl;
	  }
	}else{
	  if(greatest < tmp){
	    greatest = tmp;
	    pos = pii(j, i);
	    // cout << greatest << endl;
	    // cout << pos.first << " " << pos.second << endl;
	  }
	}
      }
    }

    if(greatest != 0){
      // cout << "x:" << pos.first << " y:" << pos.second << endl;
      // cout << greatest << endl;
      update(pos.first, pos.second, t);
    }
    if(greatest == 0)pass++;
    else pass = 0;

  }
    for(int i = 0; i < 8; i++){
      cout << s[i] << endl;
    }
    //cout << endl;

}

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

using namespace std;

int main() {

    string a, b;
    cin >> a >> b;

    int sol = 0;

    for(int i = 0; i < 3; i++) {
        if(a[i] == b[i]) sol++;
    }

    cout << sol << endl;

    return 0;
}

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

using namespace std;

int64_t modpow(int64_t a, int64_t b, int64_t MOD) {
	int64_t ret = 1;
	while (b > 0) {
		if (b & 1) { (ret *= a) %= MOD; }
		(a *= a) %= MOD;
		b >>= 1;
	}
	return ret % MOD;
}

Int comb(Int a, Int b, Int mod) {
	Int x = 1, y = 1;
	for (Int i = 0; i < b; ++i) {
		(x *= (a - i)) %= mod;
	}
	for (Int i = 1; i <= b; ++i) {
		(y *= i) %= mod;
	}
	return x * modpow(y, mod - 2, mod) % mod;
}

int main() {
	const Int MOD = 1e9 + 7;
	Int N, a, b;
	cin >> N >> a >> b;

	Int ans = (modpow(2, N, MOD) + MOD - 1) % MOD;
	ans = (ans + MOD - comb(N, a, MOD)) % MOD;
	ans = (ans + MOD - comb(N, b, MOD)) % MOD;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
int n,m,s,ne[4][2]={0,1,0,-1,1,0,-1,0};
char mmp[1003][1003];
bool vis[1003][1003];
class qaq
{
public:
    int x,y,step,strength;
    qaq():x(0),y(0),step(0){};
};
queue<qaq> que;
int bfs(int x,int y)
{
    qaq q,p;
    q.x=x;
    q.y=y;
    q.step=0;
    q.strength=1;
    vis[x][y]=true;
    que.push(q);
    while(!que.empty()){
        q=que.front();
        que.pop();
        if(q.strength==s+1)
            return q.step;
        for(int i=0;i<4;i++){
            p.x=q.x+ne[i][0];
            p.y=q.y+ne[i][1];
            if(p.x<0||p.x>=n||p.y<0||p.y>=m||vis[p.x][p.y])
                continue;
            if(mmp[p.x][p.y]=='.'){
                p.step=q.step+1;
                p.strength=q.strength;
                vis[p.x][p.y]=true;
                que.push(p);
            }
            else if(q.strength==mmp[p.x][p.y]-'0'){
            	mmp[p.x][p.y]='.';
                p.step=q.step+1;
                p.strength=q.strength+1;
                memset(vis,0,sizeof(vis));
                while(!que.empty()) que.pop();
                que.push(p);
                break;
            }
            else if(mmp[p.x][p.y]!='X'){
            	p.step=q.step+1;
                p.strength=q.strength;
                vis[p.x][p.y]=true;
                que.push(p);
			}
        }
    }
}
int main()
{
    int startx,starty;
    while(scanf("%d %d %d",&n,&m,&s)!=EOF){
        while(!que.empty()) que.pop();
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++){
            scanf("%s",&mmp[i]);
            for(int j=0;j<m;j++){
                if(mmp[i][j]=='S'){
                    startx=i;
                    starty=j;
                    mmp[i][j]='.';
                }
            }
        }
        int ans=bfs(startx,starty);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4580