akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    long int N, M, X[100000];

    cin >> N >> M;
    for (int i = 0; i < M; i++)
        cin >> X[i];
    sort(X, X + M);

    long int fall[99999], ans = X[M - 1] - X[0];
    for (int j = 0; j < M - 1; j++)
        fall[j] = X[j + 1] - X[j];
    sort(fall, fall + M - 1);
    reverse(fall, fall + M - 1);

    for (int k = 0; k < N - 1; k++)
        ans -= fall[k];
    cout << ans << endl;

    return 0;
}

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

int main()
{
	int m,f,r;
	while(true)
	{
		cin>>m>>f>>r;
		if(m==-1&&f==-1&&r==-1) 
			return 0;
		else
		{
			if(m==-1||f==-1)
				cout<<"F"<<endl;
			else if(m+f>=80)
				cout<<"A"<<endl;
			else if(m+f>=65)
				cout<<"B"<<endl;
			else if(m+f>=50)
				cout<<"C"<<endl;
			else if(m+f>=30&&r>=50)
				cout<<"C"<<endl;
			else if(m+f>=30)
				cout<<"D"<<endl;
			else
				cout<<"F"<<endl;
		}
	} 
	return 0;
 } 


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

LL query(LL a, LL x){ // 0-aまでで
    if(a == -1) return 0;
    return a/x + 1;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    LL A,B,X; cin >>A>>B>>X;
    cout << query(B,X) - query(A-1,X) << endl;


}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val s = (0 until N).map { readLine()!! }.toList()
    val M = readLine()!!.toInt()
    val t = (0 until M).map { readLine()!! }.toList()

    val S = s.toSet()
    val r = S.map { u -> s.filter { p -> p == u }.size - t.filter { q -> q == u }.size }.plus(0)

    println(r.max())
}

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

#define INF 10000000

int N;
int P[40];
int T[40]; 
int maxballon;
int dp[40][101][4];

int dfs(int idx, int pos, int carry){
	if(idx >= N){
		if(carry > 0) return pos;
		else return 0;
	}
	if(dp[idx][pos][carry] != -1){
		return dp[idx][pos][carry];
	}
	int pt = idx > 0 ? T[idx - 1] : 0;
	int ans = INF;
	if(carry < 3 && abs(pos - P[idx]) * (carry + 1) <= T[idx] - pt){
		maxballon = max(maxballon, idx + 2);
		ans = min(ans, abs(pos - P[idx]) + dfs(idx + 1, P[idx], carry + 1));
	}
	if(pos * (carry + 1) + P[idx] <= T[idx] - pt){
		maxballon = max(maxballon, idx + 2);
		ans = min(ans, pos + P[idx] + dfs(idx + 1, P[idx], 1));
	}
	return dp[idx][pos][carry] = ans;
}

int main(){
	while(cin >> N, N){
		for(int i = 0; i < N; i++){
			cin >> P[i] >> T[i];
		}
		for(int i = 0; i < 40; i++){
			for(int j = 0; j < 101; j++){
				for(int k = 0; k < 4; k++){
					dp[i][j][k] = -1;
				}
			}
		}
		maxballon = 1;
		int ret = dfs(0, 0, 0);
		if(ret >= INF){
			cout << "NG "  << maxballon << endl;	
		}else{
			cout << "OK " << ret << endl;
		}
	}
}

Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String N = scanner.next();
        System.out.print(N.charAt(0));
        System.out.print(N.length() - 2);
        System.out.println(N.charAt(N.length() - 1));
    }
}


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

int main() {
  double x[4], y[4];

  while(cin >> x[0] >> y[0]) {
    for(int i = 1; i < 4; i++) {
      cin >> x[i] >> y[i];
    }

    bool b = true;
    if(x[0] > x[3] && x[1] > x[2]) b = false;
    if(x[0] < x[3] && x[1] < x[2]) b = false;
    if(y[0] > y[3] && y[1] > y[2]) b = false;
    if(y[2] > y[1] && y[3] > y[0]) b = false;

    if(b) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1224
#include <stdio.h>
int main(void){
    int a,b;
    double f2;
    
    scanf("%d %d\n",&a,&b);
    
    f2 = 1.0 * a/b;
    printf("%d %d %f\n",a/b,a%b,f2);
    
    return 0;
}



Measured memory_bytes: 2048
import java.util.*;
import java.math.BigInteger;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(), A=sc.nextInt(), B=sc.nextInt(), t=n, i=0;
		BigInteger s = BigInteger.ZERO;
		long[] T = new long[n];
		long[] a = new long[n-1];
		long[] b = new long[n-1];
		long[] c = new long[n-1];
		Arrays.fill(a, B);
		while (t-->0) T[i++] = sc.nextLong();
		b[0] = c[0] = (T[1]-T[0])*A;
		for (i=1; i<n-1; i++) {
			b[i] = (T[i+1]-T[i])*A;
			c[i] = b[i]+c[i-1];
		}
		for (i=0; i<n-1; i++) {
			s = s.add(new BigInteger(""+Math.min(a[i],b[i])));
			s = new BigInteger(""+Math.min(c[i],s.longValue()));
		}
		System.out.println(s);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

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

using namespace std;
#define int long long
signed main(){
	int n;
	cin>>n;
	int m;
	if(n%2){
		m=n/2+1;
	}else{
		m=n/2;
	}
	printf("%.10f",double(m*1.000000000/n*1.0000000000000));
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sample201
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            
            if(a <= 8 && b <= 8){
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = Integer.parseInt(sc.next());
        }

        for (int i = 1; i < N; i++) {
            int diff = H[i] - H[i - 1];
            if (diff == 0) {
            } else if (diff > 0) {
                H[i] = H[i] - 1;
            } else {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 50052
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  998244353;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

ll count(ll i, ll n, const vector<ll>& a) {
  // cout << i << endl;
    vector<ll> tmp = a;    
    REP(j, n) {
      tmp[j] = tmp[j] % i;
    }
    sort(all(tmp));
    // REP(k, n) cout << tmp[k] << " "; cout << endl;
    ll cnt = 0;
    int lft = 0;
    int rgt = n - 1;
    while(lft < rgt) {
      cnt += tmp[lft];
      tmp[rgt] += tmp[lft];
      tmp[lft] = 0;
      while(i <= tmp[rgt]  && rgt > 0) {
        tmp[rgt-1] += tmp[rgt] - i;
        rgt--;
      }
      lft++;
      // REP(k, n) cout << tmp[k] << " "; cout << endl;
    }
    // cout << cnt << endl;
    // cout << "======" << endl;
    return cnt;
}


signed main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<ll> a(m), b(m), c(m);
  REP(i, m) {
    ll x, y, z;
    cin >> x >> y >> z;
    x--;y--;
    a[i] = x;
    b[i] = y;
    c[i] = -z;
  }
  vector<ll> d(n, inf);
  d[0] = 0;
  REP(i, n-1) {
    REP(j, m) {
      d[b[j]] = min(d[b[j]], d[a[j]] + c[j]);
    }
  }
  vector<bool> update(n, false);
  REP(i, n) {
    REP(j, m) {
      if (d[b[j]] > d[a[j]] + c[j]) {
        d[b[j]] = d[a[j]] + c[j];
        update[b[j]] = true;
      }
    }
  }
  if(update[n-1]) {
    cout << "inf" << endl;
  }
  else {
    cout << -d[n-1] << endl;
  }
  return 0; 
}


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

int
main(void)
{
  int window, curtain;
  cin >> window >> curtain;
  int uncoverd = window - (curtain * 2);

  if (uncoverd <= 0) {
    cout << 0 << endl;
  } else {
    cout << uncoverd << endl;
  }

  return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"


signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    string a,b;
    cin>>a>>b;
    b.erase(b.end()-1);
    
    if(a==b)
    {
        cout<<"Yes"<<endl;
    }
    
    else cout<<"No"<<endl;
    
    
    
}

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
	int n, k;
	while(cin >> n >> k, n&&k) {
		int s[100], b[100][100];
		for(int i = 0; i < k; i++) {
			cin >> s[i];
		}
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < k; j++) {
				cin >> b[i][j];
			}
		}
		bool f = false;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < k; j++) {
				s[j] -= b[i][j];
				if(s[j] < 0) {
					f = true;
					break;
				}
			}
		}
		cout << (f ? "No" : "Yes") << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h> 
#define ll long long
#define length 100006   //10万
int compare(const int*a,const int *b);
/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これ移動
*/
int main(){
    int array[length],N,K,i,max=0,num;
    int *aryp;
    ll sum=0,temp=0;
    char chara[20];
    scanf("%d",&N);
  for(i=0;i<N;i++){
  scanf("%d",array+i);
  }
  for(i=1;i<N;i++){
  	if(array[i-1]>=array[i]){
  		temp++;
  		}
  	if(array[i-1]<array[i]){
  		temp=0;
  		}
  	if(temp>sum){
  		sum =temp;
  	}
  	
  }
printf("%lld",sum);
    return 0;
}
int compare(const int*a,const int *b){
    if(*a<*b)
      return -1;
    else if(*a>*b)
      return 1;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007



int main(){
  int n;
  cin >> n;
  vector<vector<long>> a(n,vector<long>(n));
  vector<tuple<long,int,int>> data;
  long ans = 0;
  rep(i,n){
    rep(j,n){
      cin >> a.at(i).at(j);
      if(j > i){
        data.push_back(make_tuple(a.at(i).at(j),i,j));
        ans += a.at(i).at(j);
      }
    }
  }
  sort(data.begin(),data.end());
  rep(k,n){
    rep(i,n){
      rep(j,n){
        if(a.at(i).at(j) > a.at(i).at(k) + a.at(k).at(j)){
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  
  rep(i,data.size()){
    tuple<long,int,int> t = data.at(i);
    long cost;
    int from,to;
    tie(cost,from,to) = t;
    rep(k,n){
      if(k == from || k == to) continue;
      if(a.at(from).at(to) == a.at(from).at(k) + a.at(k).at(to)){
        ans -= a.at(from).at(to);
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2176
import sys

import numpy as np

N, M = list(map(int, sys.stdin.readline().split()))
A = np.array([list(sys.stdin.readline().rstrip()) for _ in range(N)]) == '#'
B = np.array([list(sys.stdin.readline().rstrip()) for _ in range(M)]) == '#'
size = len(B)

ok = False
for i in range(len(A) - size + 1):
    for j in range(len(A) - size + 1):
        ok |= (A[i:i + size, j:j + size] == B).all()
if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 12432
def nCr(n, r):
    mod=10**9+7
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

x,y=map(int,input().split())

n=(2*y-x)//3
m=(x+y)//3-n

if (x+y)%3!=0 or n<0 or m<0:
      print(0)
      exit()

print(nCr((x+y)//3,n))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};

class UnionFind {
    int n;
    vector<int> uni;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }

    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};


int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<edge<int>> G;
        for (int i = 0; i < m; ++i) {
            int a, b, w;
            scanf("%d %d %d", &a, &b, &w);
            a--; b--;
            G.emplace_back(a, b, w);
        }
        sort(G.begin(),G.end(), [](edge<int> e1, edge<int> e2){ return e1.cost > e2.cost; });
        int a = m;
        int ans = INF<int>;
        for (int i = 0; i < m; ++i) {
            UnionFind tree(n);
            int mi = INF<int>, Ma = 0;
            for(int j = (int)G.size()-1; j >= 0; --j) {
                if(tree.unite(G[j].from, G[j].to))  {
                    mi = min(mi, G[j].cost);
                    Ma = max(Ma, G[j].cost);
                }
            }
            if(tree.size(0) == n) ans = min(ans, Ma-mi);
            G.pop_back();
        }
        cout << (ans == INF<int> ? -1 : ans) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3264
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	string array1, array2;
	// cout << "array1: ";
	cin >> array1;
	// cout << "array2: ";
	cin >> array2;
	int l1 = array1.length(), l2 = array2.length();
	long long int result[l1 + 1][l2 + 1];
	for(int i = 0; i <= l1; i++){
		result[i][0] = i;
	}
	for(int i = 0; i <= l2; i++){
		result[0][i] = i;
	}
	for(int i = 1; i <= l1; i++){
		for(int j = 1; j <= l2; j++){
			int w;
			if(array1[i - 1] == array2[j - 1]) w = 0;
			else w = 1;
			result[i][j] = min(result[i - 1][j - 1] + w, min(result[i - 1][j] + 1, result[i][j - 1] + 1));
		}
	}
	cout << result[l1][l2] << endl;
	return 0;
}

Measured memory_bytes: 11044
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 1010;
char s[maxn][maxn];

void solve3 (int i, int j) {
	s[i][j] = s[i][j + 1] = s[i + 1][j + 2] = s[i + 2][j + 2] = 'e';
}

void solve2_a (int i, int j) {
	s[i][j] = s[i][j + 1] = 'a';
	s[i + 1][j] = s[i + 1][j + 1] = 'b';
}

void solve2_b (int i, int j) {
	s[i][j] = s[i + 1][j] = 'c';
	s[i][j + 1] = s[i + 1][j + 1] = 'd';
}

void solve_even (int i, int j, int k) {
	for (int l = 0; l < k; l ++)
		solve2_a(i + l * 2, j + l * 2);
	for (int l = 0; l < k - 1; l ++)
		solve2_b(i + l * 2 + 2, j + l * 2);
	solve2_b(i, j + k * 2 - 2);
}

/* void solve9 (int i, int j) { */
/* 	for (int x = 0; x < 3; x ++) */
/* 		for (int y = 0; y < 3; y ++) */
/* 			solve3(i + x * 3, j + y * 3); */
/* } */

void solve5 (int i, int j) {
	char t[10][10] = {
		".ijjl",
		"fi..l",
		"f.ppm",
		"hho.m",
		"ggonn",
	};
	for (int x = 0; x < 5; x ++)
		for (int y = 0; y < 5; y ++)
			s[i + x][j + y] = t[x][y];
}

void solve7 (int i, int j) {
	char t[10][10] = {
		"a...lmm",
		"a.nnl..",
		".b..jkk",
		".b..ji.",
		"ccd..i.",
		"..dgg.h",
		"eeff..h",
	};
	for (int x = 0; x < 7; x ++)
		for (int y = 0; y < 7; y ++)
			s[i + x][j + y] = t[x][y];
}

int main () {
	int n = read;
	for (int i = 1; i <= n; i ++)
		std::fill(s[i] + 1, s[i] + n + 1, '.');

	if (n == 2) return puts("-1"), 0;

	if (n == 5)
		solve5(1, 1);
	else if (n == 7)
		solve7(1, 1);
	else if (n % 3 == 0)
		for (int i = 1; i <= n; i += 3)
			solve3(i, i);
	else if (n % 2 == 0)
		solve_even(1, 1, n / 2);
	else {
		solve5(1, 1);
		solve_even(6, 6, (n - 5) / 2);
	}

	for (int i = 1; i <= n; i ++)
		puts(s[i] + 1);
}


Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		double x = scan.nextDouble();
		double h = scan.nextDouble();
			while(x != 0 && h != 0){
			double s = Math.sqrt(h*h+(x/2)*(x/2));
			System.out.println(x*x+(s*x*0.5)*4);
			x = scan.nextDouble();
			h = scan.nextDouble();
		}
	}
}

Measured memory_bytes: 18620
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <limits>
using namespace std;

int main(int argc, char *argv[])
{
  int n;
  double p1 = 0.0, p2 = 0.0, p3 = 0.0, pinf = 0.0;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x.at(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> y.at(i);
  }
  for (int i = 0; i < n; ++i) {
    p1 += (double)(abs((x.at(i) - y.at(i))));
  }
  for (int i = 0; i < n; ++i) {
    p2 += pow(abs((x.at(i) - y.at(i))), 2);
  }
  for (int i = 0; i < n; ++i) {
    p3 += pow(abs(x.at(i) - y.at(i)), 3);
  }
  for(int i=0;i<n;++i){
    pinf = max((double)abs(x.at(i)-y.at(i)), pinf);
  }
  cout << fixed;
  cout << setprecision(9);
  cout << p1 << endl;
  cout << pow(p2, 1.0/2.0) << endl;
  cout << pow(p3, 1.0/3.0) << endl;
  cout << pinf << endl;
  return 0;
}



Measured memory_bytes: 3480
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string>

using namespace std;

void solve(int N, int A, int B) {
  int ans = min(A * N, B);

  printf("%d\n", ans);
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  solve(N, A, B);
  return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=101;
int M_MAX=1000;
int INF=1e5;
struct edge{int from, to, cost;};
int main()
{
  int n,m,a,b,c,i,j,k,res=0;
  int d[N_MAX][N_MAX];
  edge e[M_MAX];
  cin >> n >> m;
  for(i=1;i<=n;i++)
    fill(d[i]+1,d[i]+n+1,INF);
  for(i=1;i<=n;i++)
    d[i][i]=0;
  for(i=0;i<m;i++){
    cin >> a >> b >> c;
    e[i].from=a;
    e[i].to=b;
    e[i].cost=c;
    d[a][b]=c;
    d[b][a]=c;
  }
  for(k=1;k<=n;k++)
    for(i=1;i<=n;i++)
      for(j=1;j<=n;j++)
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
  for(i=0;i<m;i++){
    a=e[i].from;
    b=e[i].to;
    c=e[i].cost;
    if(d[a][b]<c)
      res++;
  }
  cout << res << endl;
  return 0;
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define oo (1<<29)
#define LL long long
using namespace std;
int n,m,h,w,a[505][505]; LL ans;
int main()
{
	int i,j;
	scanf("%d %d %d %d",&n,&m,&h,&w);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++){
			if(i%h==1%h&&j%w==1%w) a[i][j]=oo;
			if(i%h==0&&j%w==0) a[i][j]=-oo-1;
		  }
	for(i=1;i<=h;i++)
		for(j=w+1;j<=m;j++)
			a[i][j]=a[i][j-w];
	for(i=h+1;i<=n;i++)
		for(j=1;j<=m;j++)
			a[i][j]=a[i-h][j];
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			ans+=a[i][j];
	if(ans<0) printf("No");
	else{
		printf("Yes\n");
		for(i=1;i<=n;i++){
			for(j=1;j<=m;j++)
				printf("%d ",a[i][j]);
			printf("\n");
		  }
	  }
	return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

#define MOD 1000000007


int main() {
	int N;
	string s;
	cin >> N>>s;
	int count = 0;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'R') {
			count++;
		}
		else {
			count--;
		}
	}
	
	if (count>0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int h, w, sy, sx, dy[] = {-1, 0, 1, 0}, dx[] = {0, 1, 0, -1};
char data[20][20];
bool vis[20][20];

bool check(int y, int x){
  if(y<0 || y>=h) return false;
  if(x<0 || x>=w) return false;
  return true;
}

int dfs(int y, int x){
  int res = 1;
  vis[y][x] = true;
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(!check(ny, nx)) continue;
    if(vis[ny][nx]) continue;
    if(data[ny][nx] == '.') res += dfs(ny, nx);
  }
  return res;
}

main(){
  while(cin >> w >> h && (w|h)){
    fill(vis[0], vis[20], false);
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> data[i][j];
        if(data[i][j] == '@'){
          sy = i;
          sx = j;
          data[i][j] = '.';
        }
      }
    }
    cout << dfs(sy, sx) << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define MOD2 998244353

using namespace std;
typedef long long int ll;

int main(void)
{
	fast;
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	int n, k; cin >> n >> k;
	if (n >= 2*k-1) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
a, b, c = 0, 0, 0
for i in range(N):
    if P[i] % 4 == 0:
        a += 1
    elif P[i] % 2 == 0:
        b += 1
    else:
        c += 1
if b % 2 == 1:
    b -= 1
    c += 1
if 2 * a >= (a + c - 1):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
#include <cstdio>
#include <queue>
#include <vector>
const int MAXN = 1005;
const int NOPE = -1;
typedef std::vector<int> vin;
int dist[MAXN][MAXN];
int end[MAXN];
bool seen[MAXN];
int upper[MAXN][MAXN]{ };
vin G[MAXN];
int M, N;
int a, b;

void bfs(int src) {
  for (int i = 1; i <= N; ++i) {
    dist[src][i] = NOPE;
    upper[src][i] = NOPE;
    seen[i] = false;
  }
  end[src] = NOPE;
  std::queue<int> Q;
  Q.push(src);
  seen[src] = true;
  int *D = dist[src];
  D[src] = 0;

  while (!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    for (int nxt: G[cur]) {
      if (nxt == src) {
        if ((end[src] == NOPE) ||
            (D[cur] < D[end[src]])) {
          end[src] = cur;
        }
      }
      if (seen[nxt]) continue;
      D[nxt] = D[cur] + 1;
      upper[src][nxt] = cur;
      seen[nxt] = true;
      Q.push(nxt);
    }
  }
}

int solve() {
  int src = NOPE;
  for (int i = 1; i <= N; ++i) {
    bfs(i);
    if (end[i] != NOPE) {
      if ((src == NOPE) ||
          (dist[i][end[i]] < dist[src][end[src]])) {
        src = i;
      }
    }
  }
  return src;
}

int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; ++i) {
    scanf(" %d%d", &a, &b);
    G[a].push_back(b);
  }
  int ret = solve();
  if (ret != NOPE) {
    printf("%d\n", dist[ret][end[ret]] + 1);
    int cur = end[ret];
    while (cur != NOPE) {
      printf("%d\n", cur);
      cur = upper[ret][cur];
    }
  } else {
    puts("-1");
  }
  return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin >> n >> m;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]/=2;
    }
    int t;
    for(int i=0;i<n;i++){
        int cnt=0;
        int num=a[i];
        while(num%2==0){
            num/=2;
            cnt++;
        }
        if(i){
            if(t!=cnt){
                cout << 0 << endl;
                return 0;
            }
        }
        t=cnt;
    }
    ll l=1;
    for(int i=0;i<n;i++){
        l=l/gcd(l,a[i])*a[i];
    }
    cout << m/l-m/(2*l) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{
  int a,b,ab;
  int x,y;
  int sum = 0;

  cin >> a >> b >> ab >> x >> y;

  if ( a+b < ab*2 )
  {
    sum += x*a+y*b;
  } else {
    if ( x > y ) {
      sum += ab*2*y;
      sum += min(ab*2*(x-y), a*(x-y));
    } else {
      sum += ab*2*x;
      sum += min(ab*2*(y-x), b*(y-x));
    }
  }

  cout << sum << endl;
}


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

int main(){
#define int ll
  while(1){
    int r,n; cin >> r >> n;
    if(r == 0 and n == 0) break;
    map<int,int> maxh;
    FOR(i,-r-1,r+2) maxh[i];
    rep(i,n){
      int nl,nr,h;
      cin >> nl >> nr >> h;
      FOR(j,nl,nr) maxh[j] = max(maxh[j], h);
    }
    if(maxh[r] == 0) maxh[r] = maxh[r-1];
    ROF(i,r,-r+1) maxh[i] = min(maxh[i], maxh[i-1]);
    dump(maxh);
    double ans = inf;
    FOR(i,-r,r+1){
      ans = min(ans, maxh[i] - sqrt(pow(r, 2) - pow(i, 2)));
    }
    printf("%.10f\n",ans + r);
  }
}


Measured memory_bytes: 3164
use proconio::{input, fastout};

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    h: usize,
    w: usize,
    n: usize,
    mut aa: [usize; n]
  };

  let mut ans = vec![vec![0; w]; h];

  let mut idx = 0;
  let forward : Vec<usize> = (0..w).collect();
  let backward : Vec<usize> = (0..w).rev().collect();
  for i in 0..h {
    let range = if i % 2 == 0 {&forward} else {&backward};
    for j in range {
      let j = *j;
      ans[i][j] = idx + 1;
      aa[idx] -= 1;
      if aa[idx] == 0 {
        idx += 1;
      }
    }
  }

  let ans = ans.into_iter()
    .map(|row| 
      row.into_iter().map(|i| i.to_string()).collect::<Vec<_>>().join(" ")
    ).collect::<Vec<_>>().join("\n");
  echo!(ans);
}


Measured memory_bytes: 2316
#include <bits/stdc++.h>
#define inf (long long)(1e18 + 8)
using namespace std;

struct data {
  long long sum, a, f;
};

bool operator<(const data &l, const data &r) {
  if(l.sum != r.sum) return l.sum < r.sum;
  return l.a < r.a;
}

long long n, k;
vector<long long> a, f;
vector<data> v;

long long solve();
bool ch(long long x);

int main() {
  cin >> n >> k;
  a.resize(n);
  f.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> f[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  sort(f.begin(), f.end());
  sort(a.begin(), a.end(), greater<long long>());
  for(int i = 0; i < n; ++i)
    v.push_back({a[i] * f[i], a[i], f[i]});
  long long l = 0, r = inf;
  if(ch(0)) return 0;
  while(r - l > 1) {
    long long now = (l + r) / 2;
    if(ch(now))
      r = now;
    else
      l = now;
  }
  return r;
}

bool ch(long long x) {
  long long sum = 0;
  for(int i = 0; i < n; ++i) {
    long long p = x / v[i].f;
    sum += max(0LL, v[i].a - p);
  }
  return sum <= k;
}

Measured memory_bytes: 11632
#[test]
fn test_solve() {
    assert_eq!(solve("5 2 2\n1 2 3 4 5\n"), "4.500000\n1\n");
    assert_eq!(solve("4 2 3\n10 20 10 10\n"), "15.000000\n3\n");
    assert_eq!(solve("5 1 5\n1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996\n"), "1000000000000000.000000\n1\n");
    assert_eq!(solve("50 1 50\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n"), "1.000000\n1125899906842623\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let mut comb = vec![vec![1]];
    for n in 1..51 {
        comb.push(Vec::new());
        comb[n].push(1);
        for r in 1..n {
            let tmp = comb[n - 1][r - 1] + comb[n - 1][r];
            comb[n].push(tmp);
        }
        comb[n].push(1);
    }

    let n: usize = sc.read();
    let a: usize = sc.read();
    let b: usize = sc.read();
    let mut v: Vec<u64> = (0..n).map(|_| sc.read()).collect();
    v.sort_by(|a, b| b.cmp(a));
    let s = v.iter().take(a).sum::<u64>() as f64;
    let av = s / a as f64;
    let nc: usize = if v[0] == v[a - 1] {
        let len = 1 + bis_usize(0, n, |i| v[i] == v[0]);
        (a..b + 1)
            .map(|a| if len >= a { comb[len][a] } else { 0 })
            .sum()
    } else {
        let l1 = a - bis_usize(a - 1, 0, |i| v[i] == v[a - 1]);
        let l2 = bis_usize(a - 1, n, |i| v[i] == v[a - 1]) + l1 + 1 - a;
        comb[l2][l1]
    };

    format!("{:.6}\n{}\n", av, nc)
}

fn bis_usize<P>(t: usize, f: usize, eval: P) -> usize
where
    P: Fn(usize) -> bool,
{
    if t > f {
        if t - f == 1 {
            return t;
        }
    } else if f - t == 1 {
        return t;
    }
    let m = (t + f) >> 1;
    if eval(m) {
        bis_usize(m, f, eval)
    } else {
        bis_usize(t, m, eval)
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
  
  int K,S;
  int a,i,j,count=0;
  scanf("%d %d",&K,&S);
  for(i=0;i<=K;i++){
    for(j=0;j<=K;j++){
      a=S-i-j;
        if(0<=a&&a<=K){
         // printf("%d %d %d\n",i,j,a);
          count++;
        }
    }
  }
  printf("%d",count);
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll INF = 1e12;

int main()
{
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a + 2), t(b + 2);
    s[0] = -INF, t[0] = -INF;
    s[a + 1] = INF, t[b + 1] = INF;

    for (int i = 1; i <= a; i++)
        cin >> s[i];
    for (int i = 1; i <= b; i++)
        cin >> t[i];

    rep(i, q)
    {
        ll ans = INF;
        ll x;
        cin >> x;
        ll na = lower_bound(ALL(s), x) - s.begin();
        ll nb = lower_bound(ALL(t), x) - t.begin();

        ll c[2] = {s[na], s[na - 1]};
        ll d[2] = {t[nb], t[nb - 1]};

        rep(i, 2)
        {
            rep(j, 2)
            {
                ll res1 = abs(x - c[i]) + abs(c[i] - d[j]), res2 = abs(x - d[j]) + abs(c[i] - d[j]);
                ans = min({ans, res1, res2});
            }
        }
        OP(ans);
    }

    return 0;
}

Measured memory_bytes: 2944
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  var primeCounts = new Int32Array(100001);

  for(var i = 1; i < 5133; i++){
    var pni = primeNumbers[i];
    for(var k = 1; k <= i; k++){
      var sum = pni + primeNumbers[k];
        primeCounts[sum]++;
    }
  }
  var i = 0;
  while(c = +input[i++]){
    console.log(primeCounts[c]);
  }
  
}
   
function calcPrimeNumbers(){
  var max = 49999;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(5134);
  var c = 0;
  for(var i = 1; i <= max; i++){
    if(!primeNumbers[i]){
      primeNums[++c] = i;
    }
  }
     
  return primeNums;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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

    int r;
    cin >> r;
    cout << (3 * r * r ) << endl;

    return 0;
}



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


int main(void){

    char s[4];
    scanf("%s",s);
    int i,val = 700;
    for(i=0;i<3;i++){
        if(s[i] == 'o'){
            val += 100;
        }
    }
    printf("%d\n",val);
    return 0;
}

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

int main(){
	int num[5],j,i,k;
	
	for(i=0;i<5;i++)scanf("%d",&num[i]);
	
	for(i=0;i<5;i++){
		for(j=i;j<5;j++){
			if(num[i]<num[j]){
				k=num[i];
				num[i]=num[j];
				num[j]=k;
			}
		}
	}
	
    printf("%d %d %d %d %d\n",num[0],num[1],num[2],num[3],num[4]);
return 0;
}

Measured memory_bytes: 1024
from __future__ import division
from collections import defaultdict
from heapq import heappush, heappop
from sys import stdin

class UnionFindSet:
	def __init__(self, nodes):
		self.fa = {}
		for n in nodes:
			self.fa[n] = n

	def find(self, x):
		if self.fa[x] == x:
			return x
		else:
			self.fa[x] = self.find(self.fa[x])
			return self.fa[x]

	def union(self, x, y):
		fx = self.find(x)
		fy = self.find(y)
		if fx == fy:
			return fx
		else:
			self.fa[fx] = fy
			return fy


"""
graph is a hash
graph["nodes"] is a list of all nodes in the graph
graph["edges"] is a list of all edges in the graph in (x, y, w) form
  - x is the first nodes
  - y is the second nodes
  - w is the weight of the edges
graph["relation"] is the graph relation of the graph
"""

def kruscal(graph):
	"kruscal minimum spanning tree algorithm"
	ufset = UnionFindSet(graph["nodes"])

	ret = 0

	for (x, y, w) in sorted(graph["edges"], key = lambda x: x[-1]):
		fx = ufset.find(x)
		fy = ufset.find(y)
		if fx != fy:
			ret += w
			ufset.union(fx, fy)
		else:
			pass
	return ret


def dijkstra(graph, root):
	dis, vis = {}, {}
	for n in graph["nodes"]:
		dis[n] = 10 ** 9
		vis[n] = False

	heap = []
	dis[root] = 0
	heappush(heap, (0, root))

	while heap:
		_, n = heappop(heap)
		vis[n] = True
		for (y, w) in graph["adj"][n]:
			if not vis[y] and dis[n] + w < dis[y]:
				dis[y] = dis[n] + w
				heappush(heap, (dis[y], y))

	return dis

if __name__ == '__main__':
	V, E, root = map(int, stdin.readline().strip().split())
	graph = {}
	graph["nodes"] = [i for i in range(V)]
	graph["edges"] = []
	graph["adj"] = defaultdict(list)
	for _ in range(E):
		x, y, w = map(int, stdin.readline().strip().split())
		graph["edges"].append((x, y, w))
		graph["adj"][x].append((y, w))

	dis = dijkstra(graph, root)

	for n in graph["nodes"]:
		print dis[n] if dis[n] < 10 ** 9 else "INF"

Measured memory_bytes: 173660
from sys import exit
import copy
import numpy as np
#from collections import deque


h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)


def count(arr):
    cnt = 0
    for l in arr:
        for i in l:
            if i == "#":
                cnt += 1

    return cnt


ans = 0
for i in range(2 ** w):
    tmp = copy.deepcopy(c)
    for j in range(w):
        if ((i >> j) & 1):
            for s in range(h):
                tmp[s][j] = '$'

    for t in range(2 ** h):
        tmp2 = copy.deepcopy(tmp)
        for j in range(h):
            if ((t >> j) & 1):
                for s in range(w):
                    tmp2[j][s] = '$'
        # for l in tmp2:
        #     print(l)
        if count(tmp2) == k:
            ans += 1

print(ans)


Measured memory_bytes: 27076
inp = input()
changed_input = inp.replace('BC', 'D')
A_count = 0
total_ans = 0
for st in changed_input:
    if st == 'A':
        A_count += 1
    elif st == 'D':
        total_ans += A_count
    else:
        A_count = 0
print(total_ans)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    std::cout << n/2 + n%2 << std::endl;
    
}


Measured memory_bytes: 256
def main():
    mod=1000000007
    n,a,b=map(int,input().split())
    ans=(pow(2,n,mod)-1)%mod
    tmp=1
    for i in range(a):
        tmp*=n-i
        tmp*=pow(i+1,mod-2,mod)
        tmp%=mod
    #print(tmp)
    ans-=tmp
    ans%=mod
    tmp=1
    for i in range(b):
        tmp*=n-i
        tmp*=pow(i+1,mod-2,mod)
        tmp%=mod
    #print(tmp)
    ans-=tmp
    ans%=mod
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 40300
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		String[] splitLine;
		String[] sentence = new String[32];
		String line = new String();
		int[] num = new int[32];
		int max = 0,maxLen=0;
		int i;
		int current=0;
		boolean flag;
		
		line = scan.nextLine();
		splitLine = line.split(" ");
		
		for(i=0;i<32;i++){
			num[i] = 1;
		}
		
		for(i=0;i<splitLine.length;i++){
			if(current == 0){
				sentence[0] = splitLine[0];
				current++;
			}else{
				flag = true;
				for(int j=0;j<current;j++){
					if(sentence[j].equals(splitLine[i])){
						num[j]++;
						flag = false;
					}
				}
				if(flag){
					sentence[current] = splitLine[i];
					current++;
				}
			}
		}
		
		for(i=1;i<current;i++){
			if(num[max] < num[i]){
				max = i;
			}
			if(sentence[maxLen].length() < sentence[i].length()){
				maxLen = i;
			}
		}
		
		System.out.println(sentence[max] + " " + sentence[maxLen]);
		scan.close();
	}
}

Measured memory_bytes: 17136
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL  INF=1<<31;



int main(){
     int n,a,x[50];
     cin>>n>>a;
     for(int i=0;i<n;++i){
          cin>>x[i];
     }
     LL dp[55][55][5505]={0};
     dp[0][0][0]=1;
     for(int i=0;i<=n;++i){
          for(int j=0;j<=n;++j){
               for(int k=0;k<=n*a;++k){
                    dp[i+1][j][k]+=dp[i][j][k];
                    if(k>=x[i])dp[i+1][j+1][k]+=dp[i][j][k-x[i]];
               }
          }
     }

     LL ans=0;
     for(int i=1;i<=n;++i){
          ans+=dp[n][i][i*a];
     }
     cout<<ans<<endl;
}

Measured memory_bytes: 130432
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


const int MAX = 700000;//階乗の配列数
const int MOD = 1000000007;

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

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// a^n mod を計算する
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(){
  int x, y;
  cin >> x >> y;
  if((x+y)%3!=0){
    cout << "0" << endl;
  } else {
    int apb=(x+y)/3;
    int b=x-apb;
    int a=y-apb;
    if(b<0 || a<0){
      cout << "0" << endl;
    } else {
      COMinit();
      cout << COM(a+b, b) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 20052
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-23 21:11:13
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

const int MAX_SIZE = 1000010; // 10000010でもよさそう？
bool isprime[MAX_SIZE];
vector<int> prime_num;

void init()
{
  fill(isprime, isprime + MAX_SIZE, true);
  isprime[0] = isprime[1] = false;
  for (auto i = 2; i < MAX_SIZE; i++)
  {
    if (isprime[i])
    {
      prime_num.push_back(i);
      for (auto j = 2; i * j < MAX_SIZE; j++)
      {
        isprime[i * j] = false;
      }
    }
  }
}

bool prime(long long x)
{ // 2 \leq x \leq MAX_SIZE^2
  if (x < MAX_SIZE)
  {
    return isprime[x];
  }
  for (auto e : prime_num)
  {
    if (x % e == 0)
      return false;
  }
  return true;
}

const long long MOD = 1000000007;

long long inv[MAX_SIZE];
long long fact[MAX_SIZE];
long long factinv[MAX_SIZE];

void init2()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = ((MOD - inv[MOD % i]) * (MOD / i)) % MOD;
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = (i * fact[i - 1]) % MOD;
    factinv[i] = (inv[i] * factinv[i - 1]) % MOD;
  }
}

long long C(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return ((fact[n] * factinv[k]) % MOD * factinv[n - k]) % MOD;
  }
  return 0;
}

map<ll, ll> X;

int main()
{
  init();
  init2();
  ll N, M;
  cin >> N >> M;
  if (prime(M))
  {
    cout << N << endl;
  }
  else
  {
    for (auto x : prime_num)
    {
      while (M % x == 0)
      {
        M /= x;
        if (X.find(x) == X.end())
        {
          X[x] = 1;
        }
        else
        {
          X[x]++;
        }
      }
    }
    if (M != 1)
    {
      X[M] = 1;
    }
    ll ans = 1;
    for (auto x : X)
    {
      // cerr << x.first << ": " << x.second << endl;
      ll k = x.second;
      ans *= C(k + N - 1, k);
      ans %= MOD;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 25080