akhauriyash/Code-Regression huggingface dataset:
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N, K;
        cin >> N >> K;
        vector<int> B(N + 1, 0);
        set<int> se;

        rep(i, N)
        {
                int a;
                cin >> a;
                B[a--]++;
        }

        sort(all(B));
        // rep(i, N + 1)
        // {
        //         cout << B[i] << ' ';
        // }
        // cout << endl;

        int ans = 0;
        rep(i, N - K + 1)
            ans += B[i];

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int i;
	int n = 0;
	int x[3000];
	int y[3000];

	for (i = 0; i < 3000; i++) {
		scanf("%d %d\n", &x[i], &y[i]);
		n++;

		if (x[i] == 0 && y[i] == 0) {
			break;
		}
	}

	for (i = 0; i < n-1; i++) {
		if (x[i] <= y[i]) {
			printf("%d %d\n", x[i], y[i]);
		} else {
			printf("%d %d\n", y[i], x[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 628
#include <stdio.h>

int main(void) 
{
 int a, b, c;

 scanf("%d %d %d", &a, &b, &c);

 	if(a < b && b < c
){
 		
 			printf("Yes\n");
 		
 	}
 		else{
 			printf("No\n");
 		}
 
 		return 0;
 	}
 	


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n;
ll s[405];
ll f[405][405];

int main(){
	scanf("%d",&n);
	fore(i,0,n){
		ll a;
		scanf("%lld",&a);
		s[i+1]=s[i]+a;
	}
	fore(l,2,n+1)fore(i,0,n-l+1){
		int j=i+l;
		f[i][j]=1LL<<60;
		fore(k,i+1,j)f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
		f[i][j]+=s[j]-s[i];
	}
	printf("%lld\n",f[0][n]);
	return 0;
}

Measured memory_bytes: 1536
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s,t;
  cin >> s >> t;

  cout << t << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int main(){
    int n=gi(),cnt=0,s;
    for (int i=1; i<=n; ++i)
	s=gi(),cnt+=s&1;
    puts(cnt&1?"NO":"YES");
    return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int AA[SIZE],an,N;
void test(int v){
    int cnt=0;
    REP(i,N){
        if(AA[i]%v==0)cnt++;
    }
    if(cnt>=N-1)an=max(an,v);
}
int main(){
    R(N);
    REP(i,N)R(AA[i]);
    REP(i,2){
        for(int j=1;j*j<=AA[i];j++){
            if(AA[i]%j==0){
                test(j);
                test(AA[i]/j);
            }
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 640
t=input()

new=""
for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        if new=="":
            new+=t[i]
        elif new[-1]=="P":
            new+="D"
        else:
            new+=t[i]

t=new
new=""

for i in reversed(range(len(t))):
    if t[i] != "?":
        new=t[i]+new
    else:
        if new=="":
            new=t[i]+new
        elif new[0]=="D":
            new="P"+new
        else:
            new=t[i]+new

t=new
new=""

for i in range(len(t)):
    if t[i] != "?":
        new+=t[i]
    else:
        new+="D"


print(new)

Measured memory_bytes: 9736
N = int(input())

d = {0: 1, 1: 2}

def f(n):
  if n in d:
    return d[n]
  d[n] = (f(n // 2) + f((n - 1) // 2) + f((n - 2) // 2)) % (10**9 + 7)
  return d[n]

print(f(N))

Measured memory_bytes: 3060
def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10**9+7
    ans = 0
    tmp = 0
    for i in range(n-1, -1, -1):
        ans = (ans+a[i]*tmp) % mod
        tmp = (tmp+a[i]) % mod
    print(ans)


main()


Measured memory_bytes: 31436
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define enter "\n"

typedef long long ll;



int atcoder(){
    //入力
    string s;
    int k;
    cin >> s >> k;
    set<string> st;
    
    //処理
    REP(i,s.size()){
        REP(j,6){
            st.insert(s.substr(i,j));
        }
    }
    
    //出力
    auto itr = st.begin();
    REP(i,k) ++itr;
    cout << *itr << enter;
    return 0;
}

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


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;
const int INF = INT_MAX;
const int SIZE = 100;
vector<vector<int> > d(SIZE, vector<int>(SIZE, INF));

int h, w;
int sx, sy;
int gx, gy;
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

vector<string> maze(SIZE);

int bfs(){
  int ans = -1;

  queue<pair<int, int> > q;
  rep(i, h){
    rep(j, w){
      d[i][j] = INF;
    }
  }
  q.push(make_pair(sx, sy));
  d[sx][sy] = 0;
  
  while(!q.empty()){
    pair<int, int> p = q.front();
    q.pop();
    ans = max(d[p.first][p.second], ans);
    rep(i, 4){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(0 <= nx && nx < h && 0 <= ny && ny < w && maze[nx][ny] == '.' && d[nx][ny]== INF){
        q.push(make_pair(nx, ny));
        d[nx][ny] = d[p.first][p.second] + 1;
     }
    }
  }
  return ans;

}

int main(){
  
  cin >> h >> w;
  
  int count = 0;

  rep(i, h){
    cin >> maze[i];
    }

  

  int res = -1;

  rep(i, h){
    rep(j, w){
      sx = i;
      sy = j;
      if(maze[sx][sy] == '#') continue;
      res = max(res, bfs());
    }
  }

  cout << res << endl;


}

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

const int sz=3000;
vector < int > x[sz];
int vis[sz];
map < pair < int , int > , int > mp;
set < int > st,all;

void dfs(int u)
{
    st.insert(u);
    vis[u]=1;
    for(auto i : x[u])
    {
        if(!vis[i] && (!mp[{u,i}] ||!mp[{i,u}]))
        {
            dfs(i);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,m,u,v;
    vector < pair < int , int >> vp;
    cin>>n>>m;
    while(m--)
    {
        cin>>u>>v;
        vp.push_back({u,v});
        x[u].push_back(v);
        x[v].push_back(u);
        all.insert(u),all.insert(v);
    }
    int cnt=0;
    for(auto i : vp)
    {
        memset(vis,0,sizeof vis);
        u=i.first,v=i.second;
        mp.clear();
        st.clear();
        mp[{u,v}]=1;
        mp[{v,u}]=1;
        for(int i=1;i<=n;i++)
        {
            if(i!=u && i!=v)
            {
                dfs(i);
                break;
            }
        }
        if(st.size()!=all.size())cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7

#define MOD (LONG)(10e8 + 7)




int main(void) {
	ULONG N, K;
	cin >> N >> K;
	vector<ULONG> A(N+1);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	bool flgRes = true;
	for (int k = K + 1; k <= N; k++) {
		if (A[k] > A[k - K]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  
  vector<int> c(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  
  vector<vector<int>> s(D, vector<int>(26));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }

  vector<int> last(26,0);
  int score = 0;
  for(int i=0; i<D; i++){
    int kaisai = 0;
    int tmp = 0;
    for(int k=0; k<26; k++){ // i日目にk thの問題
      int add = s.at(i).at(k);
      int before = last.at(k);
      last.at(k) = i+1;
      for(int j=0; j<26; j++){
        add -= c.at(j)*(1 + i - last.at(j));
      }
      last.at(k) = before;
      if(tmp < add){
        tmp = add;
        kaisai = k;
      }
	}
    
    score += tmp;
    last.at(kaisai) = i+1;
    //cout << kaisai+1 << ", score: " << score << endl;
    cout << kaisai+1 << endl;
  }
  
  return 0; 
}


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

int main() {
  int N;
  cin >> N;
  string ans = ":(";
  
  int X_ceil = ceil( ((double)100*N) / 108);
  //int X_floor = floor( ((double)100*N) / 108);
  //cout << X_ceil << endl;
  //cout << X_floor << endl;
  
  int N_ceil = X_ceil * 1.08;
  //cout << N_ceil << endl;
  if(N_ceil == N){
    cout << X_ceil << endl;
    return 0;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int mx=0,cnt=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            cnt++;

        }
        else
        {

                mx=max(mx,cnt);

            cnt=0;
        }
    }
   mx=max(mx,cnt);
    cout<<mx<<endl;
}



Measured memory_bytes: 3620
import scala.io.Source.stdin

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for{
      i <- 3 to Math.sqrt(n).toInt by 2
      if primes(i) == 1
    }
      (i*i to n by i*2).foreach { primes(_) = 0 }

    for(i<-1 to n)
      primes(i) = primes(i)+primes(i-1)

    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(1000000)
    for(i <- stdin.getLines) {
      println(p(i.toInt))
    }
  }
}

Measured memory_bytes: 63644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pint pair<int,int>
#define vec vector<int>
#define vvec vector<vec>
#define pvec vector<vector<pint>>
#define tint tuple<int,int,int> 
#define mt make_tuple

int n,m,s;
vvec to;
pvec cost;

const int inf = 1LL << 60;

int dp[60][3000];
//その状態までにかかる時間
int c[60],d[60];

bool chmin(int &a, int b){ 
  if( a > b ){ 
    swap(a,b); return true;
  }
  else{
    return false;
  }
}

void Dijkstra(int a, int b){
  
  b = min(b,2999LL);
  
  dp[a][b] = 0;
  
  priority_queue<tint,vector<tint>,greater<tint>> Q;
  // {時間、位置、枚数}
  
  Q.push(mt(0,a,b));
  
  while(!Q.empty()){ 
    
    auto p = Q.top(); Q.pop();
    
    int time = get<0>(p);
    int pos = get<1>(p);
    int num = get<2>(p);
    
    if( time > dp[pos][num]){ continue;} 
    
    for(int i = 0; i < (int)to[pos].size(); i++){ 
      
      int length = cost[pos][i].second;
      int silver = cost[pos][i].first;
      
      int next = to[pos][i];
      
      int res = min(num+c[pos],2999LL);
      
      int res2 = num-silver;
      
      if(chmin(dp[pos][res],dp[pos][num]+d[pos])){ 
        Q.push(mt(dp[pos][res],pos,res));
      }
      
      if(res2 >= 0){ 
        if(chmin(dp[next][res2],dp[pos][num]+length)){ 
          Q.push(mt(dp[next][res2],next,res2));
          
        }
      }
      
    }//for-u
  }//while-Q
  
  return;
} 
    
    
        
            

signed main(void){ 
  
  cin >> n >> m >> s;
  to.resize(n);
  cost.resize(n);
  for(int i = 0; i < m; i++){ 
    int u,v,a,b; cin >> u >> v >> a >> b;
    u--; v--;
    to[u].push_back(v);
    to[v].push_back(u);
    cost[u].push_back({a,b});
    cost[v].push_back({a,b});
  
  }
  
  for(int i = 0; i < n; i++){ 
    cin >> c[i] >> d[i];
  }
  
  for(int i = 0; i < 60; i++){
    for(int j = 0; j < 3000; j++){ 
      dp[i][j] = inf;
    }
  }
  
  
  
  Dijkstra(0,s);
  
  int ans = inf;
  
  for(int i = 1; i < n; i++){ 
    int ans = inf;
    
    for(int j = 0; j < 3000; j++){ 
      
      ans = min(ans,dp[i][j]);
    }
    
    cout << ans << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 7848
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

def factorize(n: int):
    d = Counter()
    m= 2
    
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
            
        m += 1
        
    if n > 1:
        d[n] += 1
        
    return d

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod

# 重複組み合わせ
def nHr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if r<0 or n<0:
        return 0
    
    else:
        return nCr(n+r-1,r,mod,fac,facInv)
    
MOD = 10**9+7

n,m = li()

# 二項係数の準備
inv = inv_mod(n+100,MOD)
fac = fact(n+100,MOD)
fac_inv = fact_inv(n+100,inv,MOD)

primes = factorize(m)
ans = 1
for p in primes.values():
    ans = ans * nHr(n,p,MOD,fac,fac_inv) % MOD
    
print(ans)

Measured memory_bytes: 15392
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main(void){
    
    int N, K;
    cin >> N >> K;
    int ans = 1;
    
    while(N){
        if(N / K != 0) ans++;
        N /= K;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll gcd(ll a, ll b){
	return (b == 0 ? a : gcd(b, a % b));
}

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

	ll n;cin >> n;
	map<P, P> mp;
	ll key = 0;
	REP(i, n){
		ll a, b;cin >> a >> b;
		if(a == 0 && b == 0){
			key++;
		}
		else if(a == 0 || b == 0){
			if(mp.find(MP(0, 0)) == mp.end())mp[MP(0, 0)] = MP(0, 0);
			if(a == 0)mp[MP(0, 0)].FI++;
			else mp[MP(0, 0)].SE++;
		}
		else {
			ll seica = gcd(a, b);
			a /= seica;
			b /= seica;
			int tmp = 0;
			if(a < 0)tmp++;
			if(b < 0)tmp++;
			a = abs(a);
			b = abs(b);
			if(tmp % 2)swap(a, b);
			if(mp.find(MP(a, b)) == mp.end())mp[MP(a, b)] = MP(0, 0);
			if(tmp % 2)mp[MP(a, b)].FI++;
			else mp[MP(a, b)].SE++;
		}
	}

	ll ans = 1;
	for(auto node: mp){
		ll a = 1;
		ll b = 1;
		REP(i, node.SE.FI)a = (a * 2) % MOD;
		REP(i, node.SE.SE)b = (b * 2) % MOD;
		ans *= (a + b - 1 + MOD) % MOD;
		ans %= MOD;
	}

	cout << (ans + key - 1 + MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 19204
N = int(input())

count_ab = 0
S_tail_a_head_b = 0
S_tail_a = 0
S_head_b = 0
for _ in range(N):
    s = input()
    count_ab += s.count('AB')

    if s[0] != 'B' and s[-1] != 'A':
        continue

    if s[0] == 'B' and s[-1] == 'A':
        S_tail_a_head_b += 1
    elif s[0] == 'B':
        S_head_b += 1
    elif s[-1] == 'A':
        S_tail_a += 1

if S_tail_a_head_b == 0:
    count_ab += min(S_tail_a, S_head_b)
else:
    count_ab += S_tail_a_head_b - 1
    if S_tail_a + S_head_b >= 1:
        count_ab += min(S_tail_a, S_head_b) + 1

print(count_ab)


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

typedef long long ll;
ll p = (ll)1e9+7;

int main() {
  ll H, W, K;
  cin >> H >> W >> K;

  ll dp[111][9];
  for(ll i=0; i<111; i++) for(ll j=0; j<=8; j++) dp[i][j]=0;
  dp[0][0]=1;

  for(ll i=1; i<=H; i++){
    vector<ll> cnt_wm1(W,0), cnt_w(W,0), cnt_wp1(W,0);
    for(ll j=0; j<W; j++){
      for(ll bit=0; bit<(1<<W-1); bit++){
        // 隣り合うパターンの排除
        bool f=false;
        for(ll k=1; k<W; k++){
          if((bit & (1<<(k-1))) && (bit & (1<<k))){
            f=true;
          }
        }
        if(f) {
          continue;
        }
        //cout << bitset<5>(bit) << endl;

        if(bit & (1<<j)) cnt_wp1[j]++;
        else if(bit & (1<<(j-1))) cnt_wm1[j]++;
        else cnt_w[j]++;

        //cout << cnt_wm1[j] <<" "<< cnt_w[j] <<" "<< cnt_wp1[j] << endl;

      }
    }

    for(ll j=0; j<W; j++){
      //cout << cnt_wm1[j] <<" "<< cnt_w[j] <<" "<< cnt_wp1[j] << endl;
      if(j==0){
        dp[i][j] = dp[i-1][j]*cnt_w[j];       dp[i][j]%=p;
        dp[i][j] += dp[i-1][j+1]*cnt_wp1[j];  dp[i][j]%=p;
      }
        
      else if(j==(W-1)){
        dp[i][j] = dp[i-1][j-1]*cnt_wm1[j];   dp[i][j]%=p;
        dp[i][j] += dp[i-1][j]*cnt_w[j];      dp[i][j]%=p;
      }
      else {
        dp[i][j] = dp[i-1][j-1]*cnt_wm1[j];   dp[i][j]%=p;
        dp[i][j] += dp[i-1][j]*cnt_w[j];      dp[i][j]%=p;
        dp[i][j] += dp[i-1][j+1]*cnt_wp1[j];  dp[i][j]%=p;
      }
      
      //cout << i <<" "<< j <<" : "<< dp[i][j] << endl;
    }

  }

  cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
import copy
s=0
a=0
H,W,K=map(int,input().split())
L=[[0 for j in range(W)] for i in range(H)]
for i in range(H):
  c=list(input())
  L[i]=c
for i in range(2**(H+W)):
  c=bin(i)[2:]
  c=str(c)
  if len(c)<H+W:
    c=str((H+W-len(c))*"0"+c)
  T=copy.deepcopy(L)
  for k in range(H+W):
    if c[k]=="1":
      if k<H:
        T[k]=[0]*W
    if c[k]=="1" and k>=H:
      for n in range(H):
        T[n][k-H]=0
  for j in range(1,(H*W)+1):
    if j%W==0:
      if T[(j//W)-1][-1]=="#":
        a+=1
    else:
      if T[j//W][(j%W)-1]=="#":
        a+=1
  if a==K:
    s+=1
  a=0
print(s)

Measured memory_bytes: 9348
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 00:31:48 2019
//
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	for i, c := range s {
		if i%2 == 0 {
			fmt.Print(string(c))
		}
	}
	fmt.Println()
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include<algorithm>
#include<string>

using namespace std;


/*
    FILE *f=fopen("data.txt","w");
    fprintf(f,);
    fclose(f);
*/

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)
#define scan(a) scanf("%d",&a)
#define scanll(a) scanf("%lld",&a)
#define print(a) printf("%d\n",a)
#define printll(a) printf("%lld\n",a)
#define stll(a) stoll(a,nullptr,10)
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define EL printf("\n")
#define ff first
#define ss second

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll n,ans=0;
    string str;
    cin>>n;
    cin>>str;
    ans=1;
    for(int i=1;i<n;i++)
    {
        if(str[i]!=str[i-1])
            ans++;
    }
    cout<<ans<<endl;

}






Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n,m;
    cin >> n >> m;
    int flag = 0;
    vector<int> ship(n+10,0);
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        if(a == 1 || a == n) ship[b]++;
        if(b == 1 || b == n) ship[a]++;
        if(ship[a] == 2 || ship[b] == 2) flag = 1;
    }

    cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}

Measured memory_bytes: 1024
rr = lambda: input().strip()
rrm = lambda: list(map(int, rr().split()))

R, C = rrm()
Rx, Cx = rrm()
A = [[True] * C for _ in range(R)]
for r in range(Rx):
    A[r] = [False] * C
for c in range(Cx):
    for r in range(R):
        A[r][c] = False

print(+sum(sum(row) for row in A))


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 	int x, y;
 	cin >> x >> y;
 	for (int i = 0; i <= (y >> 1); ++i) {
 		if (2 * i + 4 * (x - i) == y) {
 			cout << "Yes";
 			return 0;
 		}
 	}
 	cout << "No";
	return 0;
}

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

int main() {
    string s1,s2;
	cin >> s1 >> s2;
	bool flag = false;
	for(int i = 0; i < s1.length(); i++){
	    if(s1[i] != s2[i]){
	        flag = true;
	    }
	}
	if(flag)
	    cout << "No" << endl;
	else
	    cout << "Yes" << endl;
 	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	//system("pause");
	return 0;
}

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

#define read(a) cin >> a
#define out(a)  cout << a
#define ull unsigned long long
#define ll long long
#define FOR(i, l, r) for (ll i = l; i <= r; i++)
#define FOD(i, l, r) for (ll i = l; i >= r; i--)
#define fast ios_base::sync_with_stdio(false);
#define mod 1000000007
#define ll long long

ll N, X, T;
ll d = 0, s = 0;
int main()
{
    cin >> N >> X >> T;
    FOR(i , 1, 1000)
    {
        d = X * i;
        s = T * i;
        if (d >= N)
        {
            cout << s;
            break;
        }
    }
}


Measured memory_bytes: 3568
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define int long long
using namespace std;
signed main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    if (B <= C) {
        cout << 0 << endl;
    }
    else if (D <= A) {
        cout << 0 << endl;
    }
    else if(A>=C&&B<=D){
        cout << B - A << endl;
    }
    else if (A <= C && B >= D) {
        cout << D - C << endl;
    }
    else if (A < D && C < B && D < B && C < A) {
        cout << D - A << endl;
    }
    else {
        cout << B-C << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <limits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>

using namespace std;
string s;
int q;

int main() {
    bool reversed = false;
    cin >> s;
    cin >> q;
    stack<char> front, back;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            reversed = !reversed;
        } else if (t == 2) {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (reversed) {
                    back.push(c);
                } else {
                    front.push(c);
                }
            } else if (f == 2) {
                if (reversed) {
                    front.push(c);
                } else {
                    back.push(c);
                }
            }
        }
    }
    string prefix, suffix;
    while (!front.empty()) {
        prefix += front.top();
        front.pop();
    }
    while (!back.empty()) {
        suffix += back.top();
        back.pop();
    }

    string ans;
    if (reversed) {
        reverse(prefix.begin(), prefix.end());
        reverse(s.begin(), s.end());
        ans = suffix + s + prefix;
    } else {
        reverse(suffix.begin(), suffix.end());
        ans = prefix + s + suffix;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4276
def default():
    maxi=1000000000000000000
    n=int(input())
    answer=1
    temp=input()
    temp=temp.split()
    flag=0
    for i in range(0,n):
        temp[i]=int(temp[i])
    temp.sort()
    for i in range(0,n):
        answer*=temp[i]
        if(answer>maxi):
            flag=1
            break
        if(temp[i]==0):
            flag==2
            break
    if(flag==1):
        print(-1)
    else:
        if(flag==2):
            print(0)
        else:
            print(answer)

if(__name__=="__main__"):
    default()


Measured memory_bytes: 19588
L, R = map(int, input().split())
def main(L, R):
  if R//2019 > L//2019:
    return 0
  L = L%2019
  R = R%2019
  r = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      r = min(r, (i*j)%2019)
  return r
print(main(L, R))


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
int main() {
  ll N=0;cin>>N;
  ll VAL=0;cin>>VAL;
  vector<vector<ll>> dp(N);
  ll tmpWeight=0,tmpVal=0;cin>>tmpWeight;cin>>tmpVal;
  for(ll j=0;j<=VAL;j++) {
	if(tmpWeight>j)dp[0].push_back(0);
    else dp[0].push_back(tmpVal);
  }
  for(ll i=1;i<N;i++) {
    ll tmpWeight=0,tmpVal=0;cin>>tmpWeight;cin>>tmpVal;
  	for(ll j=0;j<=VAL;j++) {
      if(j-tmpWeight>=0) {
        dp[i].push_back(max(dp[i-1][j-tmpWeight]+tmpVal,dp[i-1][j]));
      } else {
      	dp[i].push_back(dp[i-1][j]);
      }
    }
  }
  //for(ll i=0;i<N;i++){for(ll j=0;j<=VAL;j++)cout<<dp[i][j]<<" ";cout<<endl;}
  cout<<dp[N-1][VAL]<<endl;
  return 0;
}

Measured memory_bytes: 79352
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    H, W = map(int, readline().split())
    S = [readline().strip() for _ in range(H)]

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]

    for i in range(H):
        c = 0
        for j in range(W):
            if S[i][j] == '#':
                c = 0
            else:
                L[i][j] = c
                c += 1
        c = 0
        for j in range(W - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                R[i][j] = c
                c += 1

    for j in range(W):
        c = 0
        for i in range(H):
            if S[i][j] == '#':
                c = 0
            else:
                U[i][j] = c
                c += 1
        c = 0
        for i in range(H - 1, -1, -1):
            if S[i][j] == '#':
                c = 0
            else:
                D[i][j] = c
                c += 1

    ans = 0
    for i in range(H):
        l, r, u, d = L[i], R[i], U[i], D[i]
        for j in range(W):
            if ans < l[j] + r[j] + u[j] + d[j] + 1:
                ans = l[j] + r[j] + u[j] + d[j] + 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 198684
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main (string[] args) {

            string[] line = Console.ReadLine().Trim().Split(' ');
            int a = int.Parse(line[0]);
            int b = int.Parse(line[1]);
            string ans = string.Empty;
            
            if (a==1)
            {
                a = 14;
            }

            if (b==1)
            {
                b = 14;
            }

            if (a > b)
            {
                ans = "Alice";
            }
            else if (a < b)
            {
                ans = "Bob"; 
            }
            else
            {
                ans="Draw";
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#入力
D=int(input())
c=list(map(int,input().split()))
l=[0]*26
#リスト初期化
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
ans=[]
#変数初期化

for d in range(D):
  maxScore=-99999999
  maxI=0
  score=0
  sumdegScore=0
  for i in range(26):
    sumdegScore-=c[i]*((d+1)-l[i])
  for i in range(26):
    score=sumdegScore+c[i]*((d+1)-l[i])+s[d][i]
    if maxScore < score:
      maxScore=score
      maxI=i
  ans.append(maxI+1)
  l[maxI]=d+1

for i in range(D):
  print(ans[i])


Measured memory_bytes: 9256
s = input()
t = input()

n = len(s)
m = len(t)

if t in s:
    print(s.replace('?', 'a'))
else:
    ans = []
    for i in range(n - m + 1):
        bubun = s[i:i + m]
        flag = True
        for j in range(m):
            x = bubun[j]
            y = t[j]
            if x == y:
                continue
            elif x == '?':
                continue
            else:
                flag = False
                break

        if flag:
            ans.append((s[:i] + t + s[i + m:]).replace('?', 'a'))

    print(sorted(ans)[0]) if ans else print('UNRESTORABLE')


Measured memory_bytes: 3064
// Code for B - Judge Status Summary
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  int N;
  cin >> N;
  vector<string> S(N);

  REP(i, N) {
    cin >> S[i];
  }

  map<string, int> m;

  REP(i, N) {
    m[S[i]] += 1;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;

  return 0;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
#define mk make_pair
#define int long long
using namespace std;
main(){
  int n,t;
  cin>>n>>t;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
  int sum=0;
  for(int i=1;i<n;i++){
    if(a[i]-a[i-1]<t)sum+=abs(t-abs(a[i]-a[i-1]));
  }
  cout<<t*n-sum<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ll a, b, k;
	cin >> a >> b >> k;
	ll eat = min(a, k);
	a -= eat;
	k -= eat;
	if(k > 0){
		b -= min(b, k);
	}
	cout << a << " " << b <<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i<N; ++i) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    S[i] = s;
  }

  sort(S.begin(), S.end());
  lint c = 0;
  lint x = 1;
  for (int i=1; i<N; ++i) {
    if (S[i-1] == S[i]) {
      ++x;
    } else {
      c += x * (x - 1) / 2;
      x = 1;
    }
  }
  cout << c + x * (x - 1) / 2 << "\n";
}


Measured memory_bytes: 5760
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
var buff []byte
 
func nextString() string {
	sc.Scan()
	return sc.Text()
}
 
func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}
 
func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}
 
func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
 
var dy = []int32{0, 1, 0, -1}
var dx = []int32{1, 0, -1, 0}
var MAX = math.MaxInt64
 
func maxInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func minInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
 
type Pair struct {
	a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}
 
func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}
 
var inf uint32 = math.MaxUint32
 
type Point struct {
	x, y int32
}
 
var H, W, K int32
var i, j int32
 
func main() {
	// s := time.Now()
	H = int32(nextInt())
	W = int32(nextInt())
	K = int32(nextInt())
	var start, goal Point
	start.y = int32(nextInt() - 1)
	start.x = int32(nextInt() - 1)
	goal.y = int32(nextInt() - 1)
	goal.x = int32(nextInt() - 1)
	grid := make([]string, H)
	for i = 0; i < H; i++ {
		grid[i] = nextString()
	}
	step := make([][]uint32, H)
	for i = 0; i < H; i++ {
		step[i] = make([]uint32, W)
	}
	for i = 0; i < H; i++ {
		for j = 0; j < W; j++ {
			step[i][j] = inf
		}
	}
	step[start.y][start.x] = 0
	q := make([]*Point, 0)
	q = append(q, &start)
	idx := 0
	var next Point
	for idx < len(q) {
		now := q[idx]
		idx++
		for d := 0; d < 4; d++ {
			var k int32
			for k = 1; k <= K; k++ {
				next.x = now.x + dx[d]*k
				next.y = now.y + dy[d]*k
				if next.x < 0 || next.x >= W || next.y < 0 || next.y >= H {
					break
				}
				if grid[next.y][next.x] == '@' {
					break
				}
				if step[next.y][next.x] <= step[now.y][now.x] {
					break
				}
				if step[next.y][next.x] <= step[now.y][now.x]+1 {
					continue
				}
				step[next.y][next.x] = step[now.y][now.x] + 1
				q = append(q, &Point{x: next.x, y: next.y})
			}
		}
		// elapsed := time.Since(s)
		// if elapsed > 2900*time.Millisecond {
		// 	break
		// }
	}
	if step[goal.y][goal.x] == inf {
		fmt.Println("-1")
	} else {
		fmt.Println(step[goal.y][goal.x])
	}
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B, K;
  cin >> A >> B >> K;
  int k = 0;

  for (int i = 100; i >= 0; --i) {
    if (A % i == 0 && B % i == 0) {
      ++k;
    }
    if (K == k) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll a[200010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",a+i);
	sortdown(a,n);
	long long ans=0;
	for(int i=0;i<n-1;i++)ans+=a[(i+1)/2];
	printf("%lld",ans);
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int can;
    set<int> pcan;

    for (int i = 0; i < 3; ++i){
        cin >> can;
        pcan.insert(can);
    }
    cout << pcan.size() << endl;

}

Measured memory_bytes: 256
def modpow(a, n, mod):
    if n == 0:
        return 1
    else:
        if n % 2 == 0:
            return (modpow((a * a)%mod, n//2, mod)) % mod
        else:
            return ((a%mod) * modpow(a, n-1, mod)) % mod

# modが素であるとする
def modinv(a, mod):
    return modpow(a, mod-2, mod) % mod

def moddiv(a, b, mod):
    return ((a%mod) * modinv(b, mod)) % mod


N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9+7
sumA = sum(A)
result = (sumA * sumA) % mod
for i in range(N):
    result = result - (A[i]*A[i])%mod
print(moddiv(result, 2, mod))

Measured memory_bytes: 94200
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n,k int
	fmt.Scan(&n,&k)
	
	fruits := make([]int, n)
	
	for i := range fruits {
		fmt.Scan(&fruits[i])
	}
	
	sort.Ints(fruits)

	sum := 0
	for i := 0; i < k; i++ {
		sum += fruits[i]
	}
	fmt.Println(sum)
}

Measured memory_bytes: 1888
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int w[10], k[10];
    rep (i, 10) cin >> w[i];
    rep (i, 10) cin >> k[i];
    sort(w, w + 10);
    sort(k, k + 10);
    cout << w[9] + w[8] + w[7] << " " << k[9] + k[8] + k[7] << endl;
    return 0;
}


Measured memory_bytes: 3136
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -1000000000
for i in range(1, 1<<10):
	psum = 0
	for j in range(n):
		cnt = 0
		for k in range(10):
			if ((i>>k) & 1)==1 and f[j][k]==1:
				cnt += 1
		psum += p[j][cnt]
	ans = max(ans, psum)
print(ans)

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

int main(){
	int a, b, res;
	cin >> a >> b;
	
	if(a <= 5) res = 0;
	else if(a <= 12) res = b / 2;
	else res = b;
	
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    # ??????????????\???
    S_size = int(input())
    S = set([int(x) for x in input().split(' ')])
    T_size = int(input())
    T = set([int(x) for x in input().split(' ')])
    # S = [1, 2, 3, 4, 5, 1]
    # T = set([3, 4, 1])

    # ????????????
    U = S.intersection(T)

    # ???????????????
    print('{0}'.format(len(U)))

Measured memory_bytes: 18992
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
//#include <math.h>
using namespace std;

double getExpe() {
  int n, m;
  cin >> n >> m;
  double expe = 0;
  double sumR = 0;
  for (int i = 0; i < m; i++) {
    int v;
    double r;
    cin >> v >> r;
    expe += v*r;
    sumR += r;
  }
  return expe / sumR;
}

int main() {
  int t;
  cin >> t;
  double maxExpe = 0;
  for (int i = 0; i < t; i++) {
    double expe = getExpe();
    if(maxExpe < expe) maxExpe = expe;
  }
  cout << ((maxExpe >= getExpe() + 0.0000001) ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/


int binary_search(int* p, int n, int key,int num)
{
    int low, high, middle;

    low = 0;
    high = n - 1;

    while (low <= high)
    {
        middle = (low + high) / 2;
        if (gcd(num,p[middle])==1)
            return middle;
        else 
            high = middle - 1;
    }
}

int main()
{
    int N, L, M, K;
    int S, W;
    int A, B, C, D;
    int a[100000];

    scanf("%d%d%d%d", &A,&B,&C,&D);

    while (1)
    {
        C -= B;
        if (C <= 0)
        {
            printf("Yes");
            return 0;
        }
        A -= D;
        if (A <= 0)
        {
            printf("No");
            return 0;
        }
    }

}



Measured memory_bytes: 3736