akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define CLR(A, X) memset(A, X, sizeof(A))
using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
int dcmp(double x) { if(fabs(x) < eps) return 0; return x>0?1:-1; }
const LL MOD = 1e9+7;
const int N = 2e5+5;
const int INF = 0x3f3f3f3f;

int d[2][N][32], a[2][N], pos[N];

void RMQ_init(int n, int v) {
    for(int i = 0; i < n; i++) d[v][i][0] = a[v][i];
    for(int j = 1; (1<<j) <= n; j++)
        for(int i = 0; i+(1<<j)-1 < n; i++)
            d[v][i][j] = min(d[v][i][j-1], d[v][i+(1<<(j-1))][j-1]);
}

int RMQ(int L, int R, int v) {
    int k = 0;
    while((1<<(k+1)) <= R-L+1) k++;
    return min(d[v][L][k], d[v][R-(1<<k)+1][k]);
}

struct node {
    int x, L, R;
    bool operator < (const node& A) const {
        return x > A.x;
    }
};

int main() {
    int n, x;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &x);
        a[i&1][i] = x;
        a[(i&1)^1][i] = INF;
        pos[x] = i;
    }
    RMQ_init(n, 0); RMQ_init(n, 1);
    priority_queue<node> Q;
    x = RMQ(0, n-1, 0);
    //cout<<x<<endl;
    Q.push({x, 0, n-1});
    while(!Q.empty()) {
        node x = Q.top(); Q.pop();
        int v1 = x.x, v2 = RMQ(pos[x.x]+1, x.R, (pos[x.x]&1)^1);
        printf("%d %d ", v1, v2);
        v1 = pos[v1], v2 = pos[v2];
        if(x.L != v1) Q.push({RMQ(x.L, v1-1, x.L&1), x.L, v1-1});
        if(v1+1 != v2) Q.push({RMQ(v1+1, v2-1, (v1+1)&1), v1+1, v2-1});
        if(v2 != x.R) Q.push({RMQ(v2+1, x.R, (v2+1)&1), v2+1, x.R});
    }
    return 0;
}

Measured memory_bytes: 54392
import java.util.Scanner;

public class Main {
    void run() {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        System.out.println((str.charAt(0)) + String.valueOf(str.length() - 2) + str.charAt(str.length()-1));
    }
    public static void main(String[] args) {
        new Main().run();
    }
}

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

int main(){
  	long long n;
    cin >> n;
    long long a[2000000];
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]-=i+1;
    }
    sort(a,a+n);
    int x=a[n/2];
    long long s=0,t=0,u=0;
    for(int i=0;i<n;i++){
        s+=abs(a[i]-x);
    }
    cout << s << endl;
}

Measured memory_bytes: 3328
<?php
    while ( ! feof(STDIN) ) {
        $id[] = trim(fgets(STDIN));
    }
    $input_num = $id[0];
    $search_num = $input_num + 1;
    $input_max = $search_num + $id[$search_num];
    $input_id = [];
    $i = 0;
    $lock = 0;
    while($i <= $input_num){
        $input_id[] = $id[$i];
        $i++;
    }
    $c = $search_num + 1;
    while($c <= $input_max){
        if(in_array($id[$c],(array)$input_id)){
            if($lock == 0){
                $lock = 1;
                echo "Opened by ".$id[$c] ."\n";
            }else{
                $lock = 0;
                echo "Closed by ".$id[$c] ."\n";
            }
        }else{
            echo "Unknown ".$id[$c] ."\n";
        }
        $c++;
    }


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

int H, W;
int fid[610][610], cmp[610][610];
long long ans;

int CMP(int i, int j)
{
    if(j < 0)return 0;
    return cmp[i][j];
}

void unit()
{
    memset(cmp, 0, sizeof(cmp));
    for(int i = 0; i < 610; i++)for(int j = 0; j < 610; j++)
    {
        if(j == 0)cmp[i][j] = fid[i][j];
        else cmp[i][j] = fid[i][j] + cmp[i][j - 1];
    }

    for(int i = 0; i < 610; i++)
    {
        for(int j = 0; j < 610; j++)
        {
            for(int k = j + 1; k < 610; k++)
            {
                if(fid[i][j] && fid[i][k])
                {
                    int d = k - j;
                    if(i + d < 610)ans += 2 * (CMP(i + d, k - 1) - CMP(i + d, j));
                    if(i - d >= 0)ans += 2 * (CMP(i - d, k - 1) - CMP(i - d, j));
                    if(i + d < 610 && fid[i + d][j])ans++;
                    if(i - d >= 0 && fid[i - d][j])ans++;
                    if(i + d < 610 && fid[i + d][k])ans++;
                    if(i - d >= 0 && fid[i - d][k])ans++;
                }
            }
        }
    }
    return;
}

int main()
{
    cin >> H >> W;
    for(int i = 0; i < H; i++)for(int j = 0; j < W; j++)
    {
        int x = i + j, y = i - j + 300;
        char c;
        cin >> c;
        fid[x][y] = (c == '#');
    }

    unit();

    int cpy[610][610] = {0};
    for(int i = 0; i < 610; i++)
    {
        for(int j = 0; j < 610; j++)
        {
            cpy[j][i] = fid[i][j];
        }
    }
    for(int i = 0; i < 610; i++)for(int j = 0; j < 610; j++)fid[i][j] = cpy[i][j];

    unit();

    cout << ans / 2 << endl;

    return 0;
}


Measured memory_bytes: 4608
n,k,q = map(int,input().split())
r = q-k
c = 1
l = [0 for _ in range(n)]
for _ in range(q):
    a = int(input())
    l[a-1] += 1
for x in l:
    if x <= r:
        print('No')
    else:
        print('Yes')
    c += 1


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

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i]; 
	}
	sort(a,a+n);
	int flag=0;
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			cout << "NO" << endl;
			flag=1;
			break;
		}
	}
	if(flag==0)
	cout << "YES" <<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------


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




int main(void)
{

	int n;
	cin >> n;

	vector<int> p(n);


	rep(i, n)
	{
		cin >> p[i];
	}

	int kmin = 20000000;

	int ans = 0;

	rep(i, n)
	{
		if (kmin > p[i]) 
		{
			ans++;
		}
		kmin = min(kmin, p[i]);
	}

	cout << ans << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int>uenodan(N);
    vector<int>shitanodan(N);
    for (int i=0; i < N; i++) {
        cin >> uenodan.at(i);
    }

    for (int i=0; i < N; i++) {
        cin >> shitanodan.at(i);
    }

    int sum = 0;
    for (int i=0; i < N; i++) {
        int count = 0;
        for (int j=0; j <= i; j++) {
            count += uenodan[j];
        }

        for (int k=i; k < N; k++) {
            count += shitanodan[k];
        }

        if (count > sum) {
            sum = count;
        }
    }

    cout << sum << endl;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef unordered_map<ll, ll> ump;

const ll mod = 1e9+7;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	REP(i, a){
		if (!(s[i]>='0' && s[i]<='9')){
			cout << "No" << endl;
			return 0;
		}
	}
	if (s[a]!='-'){
		cout << "No" << endl;
		return 0;
	}
	FOR(i, a+1, a+b+1){
		if (!(s[i]>='0' && s[i]<='9')){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


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

int main(){
	
	int num,ans[4]={};
	char a;
	string str;
	string match[4] = {
		"A","B","AB","O"
	};
	
	while( cin >> num >> a  ){
		if( cin.eof() ) break ;
		cin >> str;
		for( int i=0 ; i<4 ; i++ ){
			if( match[i] == str ) ans[i]++;
		}
	}
	
	for( int i=0 ; i<4 ; i++ ){
		cout << ans[i] << endl ;
	}
	
	return 0 ;
}

Measured memory_bytes: 1216
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=710;
const int INF=1e9+50;

bool ed[MAX][MAX];
int N, M;
int vx[MAX];
vi c1, c2;

bool dfs(int s, int c){
	vx[s]=c;
	rep(i,N)if(i!=s && !ed[s][i]){
		if(vx[i]==c) return false;
		if(vx[i]==0 && !dfs(i, -c)) return false;
	}
	return true;
}

bool dp[MAX][MAX];

int main(){
	cin>>N>>M;
	rep(_,M){
		int a, b;
		cin>>a>>b;
		a--;
		b--;
		ed[a][b]=true;
		ed[b][a]=true;
	}
	int ans=0;
	int co=1;
	rep(i,N){
		if(vx[i]==0){
			bool f=dfs(i, co);
			if(f) co++;
			else{
				ans=-1;
				break;
			}
		}
	}
	if(ans==-1){
		cout<<-1<<endl;
		return 0;
	}
	int ct1[MAX] ,ct2[MAX];
	rep1(i,co-1){
		ct1[i]=0;
		ct2[i]=0;
	}
	rep(i,N){
		int c=vx[i];
		if(c>0)ct1[c]++;
		if(c<0)ct2[-c]++;
	}
	dp[0][0]=true;
	rep1(i,co-1)rep(j,N+1){
		if(j-ct1[i]>=0 && dp[i-1][j-ct1[i]])dp[i][j]=true;
		if(j-ct2[i]>=0 && dp[i-1][j-ct2[i]])dp[i][j]=true;
	}
  	int tak;
	for(int j=N/2; j>=0; j--)if(dp[co-1][j]){
    	tak=j;
        break;
    }
  	int aok=N-tak;
  	ans=(tak*(tak-1))/2+(aok*(aok-1))/2;
  	cout<<ans<<endl;
}

Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	h, w, a, b := nextInt(), nextInt(), nextInt(), nextInt()

	str1, str2 := "", ""
	for wi := 0; wi < a; wi++ {
		str1 += "1"
		str2 += "0"
	}
	for wi := a; wi < w; wi++ {
		str1 += "0"
		str2 += "1"
	}

	for hi := 0; hi < b; hi++ {
		fmt.Println(str1)
	}
	for hi := b; hi < h; hi++ {
		fmt.Println(str2)
	}
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int H, W;
string S;
vi va, vb;
int field[30][30];

void input() {
  cin >> H >> W;
  rep(i, 1, H) {
    ;
    ;
    rep(j, 1, W) {
      char c;
      cin >> c;
      field[i][j] = (c == '#' ? 0 : 1);
      ;
    }
  };
  ;
}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0};
void solve() {
  // rep(i, 1, H) {
  //   rep(j, 1, W) { cout << field[i][j] << " "; }
  //   cout << endl;
  // };
  // 400 とおり？

  // wfs?
  int ans = -1;
  rep(sth, 1, H) {
    ;
    rep(stw, 1, W) {  // wfs
      // set<pii> st;
      if (!field[sth][stw]) continue;
      int table[23][23];
      rep(i, 0, 22) { rep(j, 0, 22) table[i][j] = -1; }
      queue<pii> q;
      q.push(pii(sth, stw));
      table[sth][stw] = 0;
      while (q.size()) {
        // debug(q.size());
        pii qq = q.front();
        q.pop();
        // pii qq = q1.first;
        // st.insert(qq);

        int nowh = qq.first, noww = qq.second;
        // int cnt = q1.second;
        // ans = max(ans, cnt);
        rep(i, 0, 3) {
          int nexth = nowh + dh[i];
          int nextw = noww + dw[i];
          if (table[nexth][nextw] != -1) {
            continue;
          }
          if ((nexth < 1) || (nextw < 1) || (nexth > H) || (nextw > W)) {
            continue;
          } else {
            if (field[nexth][nextw] && (table[nexth][nextw] == -1)) {
              table[nexth][nextw] = table[nowh][noww] + 1;
              q.push(pii(nexth, nextw));

            } else {
              continue;
            }
          }
        }
      }
      rep(i, 1, H) {
        rep(j, 1, W) {
          // debug(table[i][j]);
          chmax(ans, table[i][j]);
        }
      }
      // debug2(sth, stw);
      // debug(ans);
    }
  }
  cout << ans << endl;

  ;
}
signed main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>
#include <memory>
#include <cassert>

#include <map>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;

LL N, P;

LL go() {
    LL ret = 1ll, n = N;
    for (LL x = 2; x <= (LL) (sqrt (N)) && n > 1; ++x) {
        int c = 0;
        while(n % x == 0) {
            n /= x;
            ++c;
        }
        if (c / P >= 1) {
            for (int i = 1; i <= c/P; ++i) {
                ret *= x;
            }
        }
    }
    if (n > 1) {
        if (P == 1) ret *= n;
    }
    return ret;
}

int main() {
    cin >> P >> N;
    cout << go() << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#define N 200020
using namespace std;

int a[N];
vector<int> e[N];
int s[N], c[N];
long long o[N];

inline long long C2(int n)
{
    return (long long)n * (n + 1) / 2;
}

void DFS(int x, int p)
{
    int i, t, r;

    r = c[a[x]];
    s[x] = 1;
    for(i = 0; i < (signed)e[x].size(); i ++)
        if(e[x][i] != p)
        {
            t = c[a[x]];
            DFS(e[x][i], x);
            t = c[a[x]] - t;
            o[a[x]] -= C2(s[e[x][i]] - t);
            s[x] += s[e[x][i]];
        }
    c[a[x]] = r + s[x];

    return;
}

int main(void)
{
    int n, u, v;
    int i;

    scanf("%d", &n);
    for(i = 1; i <= n; i ++)
        scanf("%d", &a[i]);
    for(i = 1; i < n; i ++)
    {
        scanf("%d %d", &u, &v);
        e[u].push_back(v);
        e[v].push_back(u);
    }

    for(i = 1; i <= n; i ++)
        o[i] = C2(n);
    DFS(1, 1);
    for(i = 1; i <= n; i ++)
        printf("%lld\n", o[i] - C2(n - c[i]));

    return 0;
}


Measured memory_bytes: 37308
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int n;
	double money=100;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		money = money*1.05;
		money = ceil(money);
	}
	int a = money * 1000;
	cout << a<<endl;
	return 0;
}

Measured memory_bytes: 2988
N,X,Y = map(int,input().split())
d=[0]*(N-1)
 
for i in range(N-1):
	for j in range(i+1,N):
		d[min(j-i-1,abs(X-1-i)+abs(Y-1-j))]+=1
		
for i in range(N-1):
	print(d[i])

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int k, x;
  cin >> k >> x;
  for (int i=x-k+1; i<=x+k-1; i++){
      cout << i << " ";
  }
  return 0; 
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

    int N;

    cin >> N;

    cout << pow(N, 3) << endl;

}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int k, n;
    cin >> k >> n;

    vector<int> as(n);
    for (auto& a : as)
    {
        cin >> a;
    }
    sort(as.begin(), as.end());

    vector<int> ds;
    for (int i = 1; i < n; i++)
    {
        ds.push_back(as[i] - as[i - 1]);
    }
    ds.push_back(as[0] + k - as[n - 1]);
    sort(ds.begin(), ds.end());
    cout << (k - ds.back()) << endl;
}


Measured memory_bytes: 2168
import java.io.*;

class Main{
    public static void main(String args[]) throws IOException{

	int x=0;
	int syo=0;

	InputStreamReader i = new InputStreamReader(System.in);
	BufferedReader br = new BufferedReader(i);

	String buf = br.readLine();
	x = Integer.parseInt(buf);
	syo = (int)Math.pow(x,3);

	System.out.println(syo);
    }
}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  ll ans = 0;
  for(ll i=0;i<n-1;i++){
    ll j = (i+1)/2;
    ans += a.at(j);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, C[505], S[505], F[505];;
int main(){
    cin >> N;
    N--;
    REP(i, N) cin >> C[i] >> S[i] >> F[i];
    REP(i, N){
        int ans = 0;
        FOR(j, i, N){
            ans = max(ans, S[j]);
            int d = ans - S[j];
            if(d % F[j])
                d = F[j] - (d % F[j]);
            else
                d = 0;
            ans += d + C[j];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
    return 0;
}

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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int d,t,s;
  cin >> d >> t >> s;
  
  if(d%s==0){
    
  if(d/s>t){
  cout << "No" << endl;  
  }
  else{
    cout << "Yes" << endl;  
  }
    
  }
  else{
    if(d/s>=t){
  cout << "No" << endl;  
  }
  else{
    cout << "Yes" << endl;  
  }
  }
    
}

Measured memory_bytes: 3628
S = input()
l = len(S)

ans = [1]*l
for i in range(l-1):
  if S[i] == "R":
    if S[i+1] =="R":
      ans[i+2] += ans[i]
      ans[i] = 0

for i in range(l-1,0,-1):
  if S[i] == "L":
    if S[i-1] == "L":
      ans[i-2] += ans[i]
      ans[i] = 0

print(*ans)

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int h1 = Integer.parseInt(sc.next());
		int w1 = Integer.parseInt(sc.next());
		int h2 = Integer.parseInt(sc.next());
		int w2 = Integer.parseInt(sc.next());
		sc.close();

		long n1 = h1*w1, n2=h2*w2;

		System.out.println(n1>n2?n1:n2);
	}

}


Measured memory_bytes: 21716
using System;
class MainClass
{
    public static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        string[] input;
        input = new string[a];
        string ans = "Yes";
        string buf1;
        string buf2;
        int i = 0;
        int j = 0;

        for(i=0;i < a;i++)
        {
            input[i] =Console.ReadLine();
            if(i >=1)
            {
                buf1 = input[i - 1];
                buf2 = input[i];
                char[] Buf1 = buf1.ToCharArray();
                char[] Buf2 = buf2.ToCharArray();

                if(Buf1[Buf1.Length-1] == Buf2[0])
                {
                    for (j = 0; j < i; j++)
                    {
                        if (input[i] == input[j]) { break; }
                    }
                }
            }
            if (j != i)
            {
                ans = "No";
                break;
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>

#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)


typedef long long ll;

int mx[]={-1,1,0,0};
int my[]={0,0,-1,1};
using namespace std;
void dfs(int x,int y,vector<vector<int> > &map,int f){
    if(x<0 or y<0 or x>map.size()-1 or y>map[0].size()-1 or map[x][y]!=f) return;
    map[x][y]=0;
    for(int i=0;i<4;i++)dfs(x+mx[i],y+my[i],map,f);
    
}
int main(){
    int x,y;
    while(cin>>x>>y,x|y){
        vector<vector<int> > map;

        
        for(int i=0;i<x;i++){
            vector<int> tmp;
            string s;
            cin>>s;
            for(int j=0;j<y;j++){

                if(s[j]=='#') {tmp.push_back(1);}
                else if(s[j]=='@') tmp.push_back(2);
                else tmp.push_back(3);    
            }
            map.push_back((tmp));
        }
        int n=0;
        for(int i=0;i<x;i++){
            for(int j=0;j<y;j++){
                //cout<<i<<j<<endl;
                if(map[i][j]!=0) dfs(i,j,map,map[i][j]),n++;
            }
        }
        cout<<n<<endl;
        
    }
    return 0;
};

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

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  if ((a+b+c)>=22) {
    cout << "bust" << endl;
  }
  else {
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 100100;
const int mod = 1e9 + 7;
long long power(long long x, long long k)
{
	long long ans = 1;
	while(k)
	{
		if(k & 1)
			(ans *= x) %= mod;
		k >>= 1;
		(x *= x) %= mod;
	}
	return ans;
}
int n;
long long fac[maxn], invfac[maxn], inv[maxn], hinv[maxn];
void init()
{
	fac[0] = 1;
	for(int i = 1; i <= n; i ++)
		fac[i] = fac[i - 1] * i % mod;
	invfac[n] = power(fac[n], mod - 2);
	for(int i = n - 1; i >= 1; i --)
		invfac[i] = invfac[i + 1] * (i + 1) % mod;
	for(int i = 1; i <= n; i ++)
		inv[i] = fac[i - 1] * invfac[i] % mod;
	hinv[0] = 0;
	for(int i = 1; i <= n; i ++)
		hinv[i] = (hinv[i - 1] + inv[i]) % mod;
}
long long ans = 0;
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	init();	
	for(int i = 1; i <= n; i ++)
	{
		long long a;
		cin >> a;
		(ans += a * (hinv[i] + hinv[n - i + 1] - 1)) %= mod;
	}
	cout << ans * fac[n] % mod << endl;
	return 0;
}

Measured memory_bytes: 3456
//99B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=1; i<n; i++)
using namespace std;
int main(void){
    int a, b, sa;
    cin >> a >> b;
    sa = b-a;
    rep(n, 1000){
        if (((n+1.0)*(n+2.0)/2.0 - n*(n+1.0)/2.0)==sa){
            cout << n*(n+1.0)/2.0-a << endl;
        }
    }
    
}

Measured memory_bytes: 256
n,c,k = map(int,input().split())

t=[]

for _ in range(n):
    t_i = int(input())

    t.append(t_i)

t = sorted(t)

bus=0
index=0
cnt=0

start =t[index]
while index<n:

    end = t[index]

    if end<=start+k:
        if cnt==c:
            bus+=1
            start=t[index]
            cnt=1
            index+=1
        else:
            cnt+=1
            index+=1
            if index==n:
                break
    else:
        bus+=1
        start=t[index]
        cnt=1
        index+=1

if cnt<=c:
    bus+=1

print(bus)


    




Measured memory_bytes: 8280
import sys
from collections import defaultdict,Counter

sys.setrecursionlimit(10**7)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n=list(input())
    if n[-1]=='3':
        print("bon")
    elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
        print("pon")
    else:
        print("hon")
    


if __name__ == "__main__":
    main()

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

int main(void)
{
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= X; i++) {
        if (i * 2 + (X - i) * 4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  if (s[0] == '1') ans++;
  if (s[1] == '1') ans++;
  if (s[2] == '1') ans++;
  cout << ans << endl;
  return 0;
}

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

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

  if (a > b) {
    int tmp = a;
    a = b;
    b = tmp;
  }

  if (a == 1 && b == 2) ans = 3;
  if (a == 1 && b == 3) ans = 2;
  if (a == 2 && b == 3) ans = 1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import sys

line = sys.stdin.readline()
output = []
for i in range( len( line )-1 ):
	c = ord( line[i] )
	if ord( 'a' ) <= c and c <= ord( 'z' ):
		c = chr( c ).upper()
	elif ord( 'A' ) <= c and c <= ord( 'Z' ):
		c = chr( c ).lower()
	else:
		c = chr( c )
	output.append( c )

print( "".join( output ) )

Measured memory_bytes: 4248
#include <stdio.h>
int n;
int adj[101][101];
int used[101];
int f[101];
int d[101];
int time=0;
void dfs(int x){
  int i;
  for(i=1;i<=n;i++){
    if(adj[x][i]==1 && used[i]==0){
      used[i]=1;time++;d[i]=time;
      dfs(i);
    }
  }
    time++;
    f[x]=time;
  
  
}
int main(){
  int i,j;
  int u,k;
  int ad;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&ad);
      adj[u][ad]=1;
    }
  }
  for(i=1;i<=n;i++){
    if(used[i]==0){
      time++;
      d[i]=time;
      used[i]=1;
      dfs(i);
    }
  }
  for(i=1;i<=n;i++)printf("%d %d %d\n",i,d[i],f[i]);
  return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> vec(100);
    double ans = 0;
    int n, m;cin >> n >> m;
    for(int i = 0;i < n;i++){
        cin >> vec.at(i);
        ans += vec.at(i);
    }
    ans = ans / (4.0 * m);
    sort(vec.rbegin(), vec.rend());
    if(vec.at(m-1) >= ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main() {
  string s; cin >> s;
  int ans = 0;
  for(auto p : s) if(p == '1') ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

int main(){
  int n;
  cin >> n;
  vector<pair<string, int>> v;
  rep(i,n){
    string s;
    int t;
    cin >> s >> t;
    v.push_back({s, t});
  }
  string tt;
  cin >> tt;
  int sum = 0;
  int flag = 0;
  rep(i,n){
    if(flag)
      sum += v[i].second;
    else{
      if(v[i].first == tt){
        flag = 1;
        // sum += v[i].second;
      }
    }
  }
  cout <<sum << endl;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

map<pair<long long int, long long int>, long long int> memo;

long long int f(long long int s, long long int x){
    if(s < 0LL || x < 0LL) return 0;
    if(memo.find({s,x}) != memo.end()) return memo[{s,x}];

    // if not...
    if(s == 0LL && x == 0LL){ memo[{0,0}] = 1; return 1; }

    long long int sum = f(s/2, x/2);
    if(s-1 >= 0 && x-1 >= 0) sum += f((s-1)/2, (x-1)/2);
    if(s-2 >= 0)             sum += f((s-2)/2, x/2);
    sum %= MOD;

    memo[{s,x}] = sum;
    return sum;
}

int main(){
    long long int n;
    cin >> n;
    cout << f(n,n) << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

ll fact[1000];

int main(){
	int N;
	cin >> N;
	REP(i, 1000) fact[i] = 0;
	for(int i=2;i<N+1;i++){
		bool flag = true;
		ll x = i;
	    while(flag){
	        ll sqx = sqrt(x)+1;
	        for(ll j=2;j<sqx+1;j++){
	            if(x%j==0){
	                fact[j]++;
	                x/=j;
	                break;
	            }
	            if(j==sqx) flag = false;
	        }
	    }
	    if(x!=1){
	        fact[x]++;
	    }
	}

	ll res = 1;
	REP(i, 1000){
		if(fact[i]!=0){
			res *= (fact[i]+1);
			res %= mod;
		}
	}
	cout << res << endl;
    return 0;
}

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



int main() 
{
    int n, k;
    cin >> n >> k;
    vector<int> su(n);
    rep(i, n) su[i] = 0;


    rep(i,k)
    {
        int d;
        cin >> d;
        rep(i,d)
        {
            int t;
            cin >> t;
            t = t - 1;
            su[t] += 1;
        }
    }
    int cnt = 0;
    rep(i,n)
    {
        if(su[i]==0)
        {
            cnt += 1;
        }
    }
    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int > v,c;

int main() {
IOS;
int  i,n;
cin>>n;
for(i=0;i<n;i++)
{int x;
cin>>x;
    v.push_back(x);
}

for(i=0;i<n;i++)
{int x;
cin>>x;
    c.push_back(x);
}



int ans=0;
for(i=0;i<n;i++)
{
    if(v[i]>c[i])
    ans = ans + v[i] - c[i];
}

cout<<ans<<endl;


	return 0;
}

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

using namespace std;

int main() {
  string N;
  cin >> N;

  if (N.at(0) == N.at(1)) cout << "Bad" << endl;
  else if (N.at(1) == N.at(2)) cout << "Bad" << endl;
  else if (N.at(2) == N.at(3)) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

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

static const int cake = 4;
static const int donut = 7;
static const int maxN = 100;

int main() {
  int N; cin >> N;
  bool found = false;
  for (int i = 0; i < maxN; i += cake) {
    for (int j = 0; j < maxN; j += donut) {
      if (N-(i+j) == 0) {
        found = true;
      }
    }
  }
  cout << (found?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int>v[2005];
int cnt[2005] = {0};
void Addedge(int from, int to){
	v[from].push_back(to);
	v[to].push_back(from);
}
bool vis[2005];

void bfs(int now,int dis){
	queue<int>q;
	int k=0;

	q.push(now);
	vis[now] = true;

	while(k<dis){
		vector<int>vv;
		k++;
		while(!q.empty()){
			int x = q.front();q.pop();
				
			for(int i = 0; i < v[x].size();i++){
				int t = v[x][i];

				if(vis[t])
					continue;
				vis[t] = true;
				//cout<<time<<' '<<x<<' '<<t<<endl;
				vv.push_back(t);
			}
		}
		for(int i=0;i<vv.size();i++)
			q.push(vv[i]);
		cnt[k] += q.size();
	}
}

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int n,x,y;

	cin>>n>>x>>y;
	Addedge(x,y);
	for(int i=1;i<=n-1;i++)
		Addedge(i,i+1);
	
	for(int j=1;j<=n;j++){
		for(int k=1;k<=2005;k++)
			vis[k] = false;
		
		bfs(j,n);
	}
	for(int i=1;i<=n-1;i++)
		cout<<cnt[i]/2<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 1000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    double yen=0;
    for(int i=0;i<N;i++){
        double a;
        string s;
        cin >> a >> s;
        if(s == "BTC"){
            yen += a * 380000;
        }else{
            yen += a;
        }
    }
    cout << yen << endl;
} 

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String[] ss = new String[n]; 
		for(int i=0;i<n;i++) {
			String s = sc.next();
			StringBuilder sb = new StringBuilder(s);
			sb.append('x');
			s = sb.reverse().toString();
			ss[i] = s;
		}
		sc.close();
		Arrays.sort(ss, (i, j)->i.length() - j.length());
		Trie trie = new Trie();
		for(int i=0;i<n;i++) {
			trie.insert(ss[i]);
		}
		System.out.println(trie.cnt);
	}
}

class Trie {

	static class TrieNode{
		TrieNode[] links;
		final int R = 26;
		boolean isEnd;
		Set<Character> needChars;//extension
		public TrieNode() {
			links = new TrieNode[R];
			needChars = new HashSet<>();
		}
		public boolean containKey(char ch) {
			return links[ch - 'a'] != null;
		}
		public TrieNode get(char ch) {
			return links[ch - 'a'];
		}
		public void put(char ch, TrieNode node) {
			links[ch - 'a'] = node;
		} 
		public void setEnd() {
			isEnd = true;
		}
	}

	
	TrieNode root;
	int cnt = 0;
	
    /** Initialize your data structure here. */
    public Trie() {
    	root = new TrieNode();
    }
    
    /** Inserts a word into the trie. */
    public void insert(String word) {
    	int[] cCnt = new int[26];
    	for(int i=0;i<word.length();i++) {
    		cCnt[word.charAt(i)-'a']++;
    	}
    	char last = word.charAt(word.length()-1);
    	word = word.substring(0, word.length()-1);
        TrieNode node = root;
        for(int i=0;i<word.length();i++) {
        	char ch = word.charAt(i);
        	cCnt[ch - 'a']--;
        	if(!node.containKey(ch)) {
        		node.put(ch, new TrieNode());
        	}
        	node = node.get(ch);
        	if(node.isEnd) {
        		for(char c : node.needChars) {
        			if(cCnt[c - 'a'] > 0)cnt++;        			
        		}
        	}
        }
        node.setEnd();
        node.needChars.add(last);
    }
    

}

Measured memory_bytes: 334504
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    ll ans = 0;
    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (i % 3 && i % 5)ans += i;
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3608
/// You just can't beat the person who never gives up
/// ICPC next year


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
void offset(vector<int>&a,int x) {
    for(int i = 0; i < sz(a);i++) {
        a[i] = x;
    }
}
struct cmp {
    bool operator() (const pair<int,int>& lhs, const pair<int,int>& rhs) const {
        return lhs.ff * rhs.ss < lhs.ss * rhs.ff;
    }
//for map<pii,int>
};


// auto cmp = [](pair<int,int>a,pair<int,int>b) {if(a.first==b.first)return a.second>b.second;
//      else return a.first > b.first;
//  };
//  multiset<pair<int,int>,decltype(cmp)>fc(cmp);
double distform(int x, int y, int z, int w) {//(x1,y1,x2,y2)
    return sqrt(1. * pow(x-z,2) + 1. * pow(y-w,2));
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash> safe_map;
};

const int MAXN = 2e5+ 10;

#define int long long
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss > p2.ss;
}
int32_t main() {
    fio
 int n;
    cin >> n;
    map<int,int>ok;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ok[a[i]]++;
    }
    if(ok.size() == n) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO";
    }


    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;


}






Measured memory_bytes: 17828
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int insu[1010] = {};
int n;

void bunkai(int num){
	int now = 2;
	while(now <= num){
		if(num % now == 0){
			insu[now]++;
			num /= now;
			continue;
		}
		now++;
	}
	return;
}

int main() {
	cin >> n;
	for(int i = 1;i <= n;i++){
		bunkai(i);
	}

	ll ans = 1;
	for(int i = 0;i < 1010;i++){
		if(insu[i] != 0){
			ans *= insu[i] + 1;
			// cout << i << endl;
			ans %= 1000000007;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll c=0,c2=0,c3=0;
    for (ll i=0;i<n;i++){
        ll x;
        cin >> x;
        if (x<=a){
            c++;
        }else if (x<=b){
            c2++;
        }else{
            c3++;
        }
    }
    cout << min(c,min(c2,c3)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 101
#define INF 5000000
#define WHITE 0
#define GRAY 1
#define BLACK 2


int n,m[MAX][MAX];

int prim(){
  int u,minv,i,v;
int d[MAX],p[MAX],color[MAX];
 int sum;
for(i = 0;i<n;i++){
  d[i] = INF;
  p[i] = -1;
  color[i] = WHITE;
 }
d[0] = WHITE;

while(1){
  minv = INF;
  u = -1;
  for(i = 0;i<n;i++){
    if(minv > d[i] && color[i] != BLACK){
      u = i;
      minv = d[i];
    }
  }
  if(u == -1)break;
  color[u] = BLACK;

  for(v= 0;v<n;v++){
    if(color[v] != BLACK && m[u][v] != INF){
      if(d[v] > m[u][v]){
	d[v] = m[u][v];
	p[v] = u;
	color[v] = GRAY;
      }
      
    }
  }
 }
 sum = 0;
 for(i = 0;i<n;i++){
   if(p[i] != -1){
     sum += m[i][p[i]];
   }
 }
 return sum;
}
int main(){
  int i,j;

  scanf("%d",&n);

  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
      scanf("%d",&m[i][j]);
    }
  }
  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
      if(m[i][j] <= -1)m[i][j]=INF;
    }
  }
  printf("%d\n", prim());
  return 0;
}



Measured memory_bytes: 2108
N = input()
L = len(N)
ans = 0
t = 0
for i in range(L-1,-1,-1):
    n = int(N[i])+t
    if n == 5:
        if i > 0 and int(N[i-1]) >= 5:
            ans += 10-n
            t = 1
            continue
    if n <= 5:
        ans += n
        t = 0
    else:
        t = 1
        ans += 10-n
if t==1:
    ans += 1
print(ans)

Measured memory_bytes: 5492
S = str(input())
N = len(S)

ans = 0
amari = [0] * 2019
amari[0] = 1
follow = 0
POW = 1

for i in reversed(S):
  follow += int(i) * POW
  follow %= 2019
  amari[follow] += 1
  POW *= 10
  POW %= 2019
  
print(sum( i * (i-1) // 2 for i in amari ))

Measured memory_bytes: 9360
N, M = map(int, input().split())
ans = 1

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


A = make_divisors(M)
for an, a in zip(A, A[1:]):
    ans = an
    if a * N > M:
        break
else:
    ans = M
print(ans)

Measured memory_bytes: 64032
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define MAXN 2000000
#define int long long
#define INF (1e9 + 7)
#define MANX MAXN
#pragma GCC optimize(2)

using namespace std;

inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (c > '9' || c < '0') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') {x = x * 10 + (c ^ 48); c = getchar();}
	return f * x;
}

int ans;

inline int gcd(int a, int b) {if (b == 0) return a; return gcd(b, a % b);}

signed main()
{
	int n = read();
	for (register int i = 1; i <= n; i++)
		for (register int j = 1; j <= n; j++)
			for (register int k = 1; k <= n; k++)
				ans += gcd(gcd(i, j), k);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

const int MAX = 510000;

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

// 二項係数計算
ll 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;
}



ll a[100010];

void solve(){
    
    COMinit();
    
    ll n,k;
    cin >> n >> k;
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    ll ans = 0;
    for(int i=0; i<n; i++){
        if(i<k-1){
            continue;
        }
        ans = (ans+a[i]*COM(i,k-1) )% MOD;
    }
    

    for(int i=0; i<n; i++){
        if(n-i-1<k-1){
            break;
        }
        ans = (ans-a[i]*COM(n-i-1,k-1)) % MOD;
    }
    if(ans<0){
        ans += MOD;
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 13056
import sys
input = sys.stdin.readline

n = int(input())
a = 0
b = 0
ba = 0
ans = 0

for i in range(n):
  s = input().strip()
  leng = len(s)
  if s[0] == 'B' and s[-1] == 'A':
    ba += 1
    #a += 1
    #b += 1
  elif s[-1] == 'A':
    a += 1
  elif s[0] == 'B':
    b += 1
  for j in range(leng - 1):
    if s[j] == 'A' and s[j+1] == 'B':
      ans += 1

if ba == 0:
  ans += min(a,b)
elif ba > 0:
  if a+b > 0:
    ans += ba + min(a,b)
  else:
    ans += ba - 1
print(ans)

Measured memory_bytes: 3064
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i,  r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 100005
#define oo 2000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int a, b, c;

int main () {
    scanf("%d%d%d", &a, &b, &c);
    fto(i, 1, 1000) {
        if (a%2 == 1 || b%2 == 1 || c%2 == 1) {
            printf("%d", i-1);
            return 0;
        }
        int newA = b/2 + c/2;
        int newB = a/2 + c/2;
        int newC = a/2 + b/2;
        a = newA; b = newB; c = newC;
    }

    puts("-1");

    return 0;
}


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
 
tyousin = M*6
tansin = H*30 + M*0.5
 
kakudosa = tyousin - tansin
 
result_root = A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudosa))
 
print(math.sqrt(result_root))

Measured memory_bytes: 62564