akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K;
	cin >> N >> K;
	int maxe=(N-1)*(N-2)/2;
	
	if(K>maxe){
		cout << "-1" << endl;
		return 0;
	}
	
	cout << N-1+maxe-K << endl;
	for(int i=1;i<N;i++)cout << i << " " << N << endl;
	int cur=1;
	while(maxe>K){
		for(int i=cur+1;i<N;i++){
			cout << cur << " " << i << endl;
			maxe--;
			if(maxe==K)break;
		}
		cur++;
	}
	
	return 0;
}

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

using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()


int main () {
  long long r;
  cin >> r;
  cout << ((r*2) * acos(-1)) << endl;
  return 0;
}


Measured memory_bytes: 3776
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	while (cin>>n,n){
		vector < int > num(n);
		REP(i,n){
			cin >> num[i];
		}
		int count=-1;
		vector < int > num2(n);
		num2 = num;
		do
		{
			num = num2;
			count++;
			REP(i, n){
				int cnt = 0;
				REP(j, n){
					if (num[i] == num[j])
						cnt++;
				}
				num2[i] = cnt;
			}

		} while (num!=num2);
		cout << count << endl;
		REP(i,n){
			cout << num[i];
			if (i == n - 1)
				cout << endl;
			else
				cout << ' ';
		}
	}
}

Measured memory_bytes: 3148
a,b,h,m = map(float,input().split())
import math
r_h = (h * (360.0/12)+(0.5*m))
r_m = (m * (360.0/60))
r = min(math.fabs(r_h-r_m),math.fabs(r_m-r_h))
#print(r_m,r_h)
ans = a**2 + b**2 - 2*a*b*math.cos(math.radians(r))
print(math.sqrt(ans))

Measured memory_bytes: 9520
ans = [0,0,0,"C",0,0,0,0,"G","A","E",0,0,0,0,"D",0,"F",0,0,0,0,0,0,"B"]
while(True):
    h = ""
    for _ in range(8):
        h +=input()
    print(ans[h.rfind("1")-h.find("1")])
    try:
        b =input()
    except:
        break


Measured memory_bytes: 5568
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.NoSuchElementException;
public class Main {
	private static final PrintStream ps = System.out;
	private static final InputStream IS = System.in;
	private static final byte[] BUFFER = new byte[1024];
	private static int ptr = 0;
	private static int buflen = 0;

	public static void main(String[] args) {
		int n = ni();
		char[] ch = n().toCharArray();
		
		int lc = 0;
		int rc = 0;
		for (int i = 0; i < n; i++) {
			if (ch[i] == ')') {
				if (rc == 0)
					lc++;
				else
					rc--;
			} else {
				rc++;
			}
		}
		
		for (int i = 0; i < lc; i++) {
			ps.print('(');
		}
		for (int i = 0; i < n; i++) {
			ps.print(ch[i]);
		}
		for (int i = 0; i < rc; i++) {
			ps.print(')');
		}
	}


	private static boolean hasNextByte() {
		if (ptr < buflen)
			return true;
		else {
			ptr = 0;
			try {
				buflen = IS.read(BUFFER);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0)
				return false;
		}
		return true;
	}

	private static int readByte() {
		if (hasNextByte())
			return BUFFER[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public static boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(BUFFER[ptr]))
			ptr++;
		return hasNextByte();
	}

	public static String n() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public static long nl() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b)
			throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b))
				return minus ? -n : n;
			else
				throw new NumberFormatException();
			b = readByte();
		}
	}

	public static int ni() {
		long nl = nl();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public static double nextDouble() {
		return Double.parseDouble(n());
	}

	private static int[] nia(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
}


Measured memory_bytes: 23124
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, K = in_nn()
    A = in_nl()

    for i in range(K, N):
        if A[0 + i - K] < A[i]:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 28416
#include <iostream>

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

using namespace std;

// 1 3 2 1
// 1 2 2 1
// 1 2 2 1
// 1 2 2 1

int N;
int H[100005];

bool solve() {

	if ( N == 1 ) return true;

	H[0]--; //左端はできるだけ小さい方が良い

	REP(i, 1, N) {
		if ( H[i] - H[i - 1] >= 1 ) H[i]--; //-1してもi - 1番目以上なら、-1した方が良い	
	}

	REP(i, 1, N) {
		if (H[i] < H[i - 1]) return false;
	}

	return true;

}

int main(void) {

	scanf("%d", &N);
	REP(i, 0, N) scanf("%d", &H[i]);

	if (solve()) puts("Yes");
	else puts("No");


	return 0;
}


Measured memory_bytes: 640
# https://atcoder.jp/contests/abc079/tasks/abc079_c

a,b,c,d=list(input())
op=['+','-']

for op1 in op:
    for op2 in op:
        for op3 in op:
            res=a+op1+b+op2+c+op3+d
            if eval(res)==7:
                print(res+'=7')
                exit()
                

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

string S;

int main(){
	cin >> S;
	map<char, int> mapi;
	for(int i = 0; i < 4; i++){
		mapi[S[i]]++;
	}
	if(mapi.size() == 2 && mapi[S[0]] == 2){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())

mx = 0
mxid = 0
sc = 0
for i in range(n):
  a = int(input())
  if a >= mx:
    sc = mx
    mx = a
    mxid = i
  elif a > sc:
    sc = a
    
for i in range(n):
  if i == mxid:
    print(sc)
  else:
    print(mx)

Measured memory_bytes: 4540
A = [int(input()) for _ in range(5)]

ans = 0

temp = 10

for a in A:
    if a % 10 == 0:
        ans += a
    else:
        ans += 10 * (a // 10 + 1)
    
    temp2 = a % 10
    if temp2 != 0 and temp2 < temp:
        temp = temp2

print(ans - (10 - temp))


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
  ll k,s,ans=0;cin>>k>>s;
  rep(i,0,k+1){
    rep(j,0,k+1){
      if(s-i-j>=0&&s-i-j<=k){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n,x;
    cin>>n>>x;
    n++;
    vector<int> l(n);
    l[0]=0;
    rep(i,n-1){
        cin>>l[i+1];
    }
    int ans=0,d=0;
    for(;ans<n;ans++){
        if(d+l[ans]<=x){
            d+=l[ans];
        }
        else{
            break;
        }
    }
    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 3616
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            
            String line = br.readLine();
            String[] dataArray = line.split(" ");
            int x = Integer.parseInt(dataArray[0]);
            int y = Integer.parseInt(dataArray[1]);
            if(x<y) System.out.println(Result.LessThan.getValue());
            if(x==y) System.out.println(Result.Equal.getValue());
            if(x>y) System.out.println(Result.GreaterThan.getValue());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

   public enum Result{
    	LessThan("a < b"),
    	Equal("a == b"),
    	GreaterThan("a > b");
	   
		// Field
	    private String name;
	    
	    // Constructor
	    private Result(String name) {
	        this.name = name;
	    }
	    
	    // Method
        public String getValue() {
            return this.name;
        }
   };
}

Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int n, k;
    vector<int> h;
    int min_len = 2000000000;

    cin >> n >> k;

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

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

    /*
    for(int i = 0; i < n; i++){
        cout << h[i] << endl;
    }
    */
    // cout << endl;

    for(int i = 0; i < n-k+1; i++){
        // cout << h[i+k-1] - h[i] << endl;
        if(h[i+k-1] - h[i] < min_len){
            min_len = h[i+k-1] - h[i];
        }
    }

    cout << min_len << endl;
    
    return 0;
}

Measured memory_bytes: 892
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;

class EStringsOfImpurity {
public:
    void solve(std::istream &in, std::ostream &out) {
        string s, t;
        in >> s >> t;
        int n = s.length();
        unordered_map<char, vector<int>> Map;
        for (int i = 0; i < n; ++i) Map[s[i]].push_back(i);

        int res = 0, ind = -1;

        for (int i = 0; i < t.length(); ++i) {
            if (Map[t[i]].empty()) {
                res = -1;
                break;
            }
            auto nxt = upper_bound(Map[t[i]].begin(), Map[t[i]].end(), ind);
            if (nxt == Map[t[i]].end()) res += (n - ind), nxt = Map[t[i]].begin(), ind = *nxt, res += ind;
            else res += (*nxt - ind), ind = *nxt;
        }
        out << res;
    }
};


int32_t main() {
    EStringsOfImpurity solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <numeric>
#include <set>

using namespace std;

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

int main() {
	int n, t = 0, f = 0,g = 0;
	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		if (a % 4 == 0) f++;
		else if (a % 2 == 0) g++;
		if (a % 2 == 1) t++;
	}
	if (g > 0 && f >= t) cout << "Yes" << endl;
	else if(g == 0 && f + 1>= t)cout << "Yes" << endl;
	else cout << "No" << endl;
}



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

M1, M2 = 0, 0
A = []
for i in range(N):
    a = int(input())
    A.append(a)
    if a > M1:
        M2 = M1
        M1 = a
    elif a > M2:
        M2 = a

for i in range(N):
    if A[i] == M1:
        print(M2)
    else:
        print(M1)


Measured memory_bytes: 68904
#include <bits/stdc++.h>
using namespace std;
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define double long double
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e9;
const long long MOD = 1e9+7;
signed main(){
    double a,b,h,m; cin >> a >> b >> h>> m;
    //double sita=(h*(double)30+m/(double)2-m/(double)60)*M_PI/(double)180;
    double sita=M_PI*2*(h/12.0+m/60.0/12.0-m/60.0);
    cout<<fixed << setprecision(20) << sqrt(a*a+b*b-2*a*b*cosl(sita))<<endl;
}    

Measured memory_bytes: 4144
from collections import Counter
def i(): return int(input())
def l(): return list(map(int,input().split()))

N = i();A = l();A.sort()
dp = [1]*(10**6+1);C = Counter(A);ans = 0
for a,b in C.items():
    if b != 1:dp[a] = 0
    elif dp[a]:ans += 1
    for j in range(a,10**6+1,a):dp[j] = 0
print(ans)

Measured memory_bytes: 123476
//xenowitz -- Jai Shree Ram
#include<bits/stdc++.h>
using namespace std;

#define fori(i,a,b) for (long int i = a; i <= b ; ++i)
#define ford(i,a,b) for(long int i = a;i >= b ; --i)
#define mk make_pair
#define mod 1000000007
#define pb push_back
#define eb emplace_back
#define vec vector<long long int>
#define ll long long
#define rnd mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count())
#define pi pair<long long int,long long int>
#define sc second
#define fs first
#define stf shrink_to_fit

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans1 = max(a*c, b*d);
  ll ans2 = max(a*d, b*c);

  cout << max(ans1, ans2) << endl;
  return 0;
}


Measured memory_bytes: 3636
// 2A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

class DisjointSet {
public:
    vector<int> rank, p;

    DisjointSet(){}
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++)makeSet(i);
    }
    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }
    bool same(int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        }
        else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }
    int findSet(int x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

class Edge {
public:
    int source, target, cost;
    Edge(int source = 0, int target = 0, int cost = 0):
    source(source),target(target),cost(cost){}
    bool operator < (const Edge& e)const {
        return cost < e.cost;
    }
};

int kruskal(int N,vector<Edge> edges){
    int totalCost = 0;
    sort(edges.begin(), edges.end());
    DisjointSet dset = DisjointSet(N + 1);
    for (int i = 0; i < N; i++)dset.makeSet(i);

    int source, target;
    for (int i = 0; i < edges.size(); i++) {
        Edge e = edges[i];
        if (!dset.same(e.source, e.target)) {
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;

}
int main()
{
    int n, m, cost;
    int source, target;

    cin >> n >> m;

    vector<Edge> edges;
    for (int i = 0; i < m; i++) {
        cin >> source >> target >> cost;
        edges.push_back(Edge(source, target, cost));

    }
    cout << kruskal(n, edges) << endl;
}




Measured memory_bytes: 5152
#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;

/*
3枚のカードは1枚に
2枚のカードはどれか1枚を犠牲にして1枚に
すなわち、
・3枚以上あるものは、そこから2を引く
・2枚のもののペアがあれば、1枚ずつ減らせる
・2枚のものが１つだけ残れば、1種類のカードを犠牲に
*/

void solve(){
    string s;
    cin >> s;
    int n = s.size();
    int awhere,zwhere;
    rep(i,n){
        if(s[i]=='Z') zwhere=i;
    }
    for(int i=n-1; i>=0; i--){
        if(s[i]=='A') awhere=i;
    }
    cout << zwhere-awhere+1 << endl;
}

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



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

int main(){
    int K, X;
    cin >> K >> X;

    int a = max(X-(K-1), -1000000);
    int b = min(X+(K-1), 1000000);
    for(int i = a; i <= b; ++i){
        cout << i << " ";
    }
    cout << endl;
}

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

int main() 
{
  int N;
  std::cin >> N;
  int a[N];
  for ( int i = 0; i < N; i++ ) std::cin >> a[i];

  std::sort(a, a+N, std::greater<int>());

  int Alice = 0;
  int Bob = 0;
  for ( int i = 0; i < N; i++ ) {
    if ( i % 2 == 0 ) {
      Alice += a[i];
    }
    else {
      Bob += a[i];
    }
  }
  std::cout << Alice - Bob << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	int a, b;
	string s;
	bool flg = true;

	cin >> a >> b >> s;

	for (int i = 0; i < (int)s.size(); i++)
	{
		if (i == a) {
			if (s[i] != '-') {
				flg = false;
			}
		}
		else {
			if (s[i]<'0' || s[i]>'9') {
				flg = false;
			}
		}
	}

	if (flg)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

int main() {
int arr[3]={0};
for(int i=0;i<3;i++)
  cin >> arr[i];
swap(arr[0], arr[1]);
swap(arr[0], arr[2]);
cout << arr[0]<< " " << arr[1] << " " << arr[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long H, W;
  cin >> H >> W;
  vector<string> C(H);
  rep (i, H) cin >> C[i];

  rep (i, 2*H) {
    rep (j, W) cout << C[(i)/2][j];
    cout << endl;
  }
}

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


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

i, o, t, j, l, s, z = map(int, input().split())

ans = o

# a: xoooo.
#    xxx...
# b: xooo
#    xxxo
# c: xxxo
#    xooo
# d: oooo
#    xxxx

odd_num = (i % 2) + (j % 2) + (l % 2)
if odd_num >= 2 and i > 0 and j > 0 and l > 0:
    ans += 3
    i -= 1
    j -= 1
    l -= 1
ans += (i // 2) * 2
ans += (j // 2) * 2
ans += (l // 2) * 2
print(ans)


Measured memory_bytes: 6100
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<u64>()[0];

    let mut ans = std::u64::MAX;
    for a in 1..n{
        let mut a = a;
        let mut b = n - a;
        let mut sum = 0;
        while a > 0{
            sum += a%10;
            a /= 10;

        }
        while b > 0{
            sum += b%10;
            b /= 10;
        }
        ans = cmp::min(ans, sum);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
S = input()
while S:
    if S[-5:] == 'dream':
        S = S[:-5]
    elif S[-5:] == 'erase':
        S = S[:-5]
    elif S[-6:] == 'eraser':
        S = S[:-6]
    elif S[-7:] == 'dreamer':
        S = S[:-7]
    else:
        answer = 'NO'
        break
else:
    answer = 'YES'

print(answer)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,q,a;
  int points[100005] = {};
  cin >> n >> k >> q;
  for(int i=0; i<q; i++){
    cin >> a;
    points[a]++;
  }

  for(int i=1; i<=n; i++){
    if(k - (q - points[i]) <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

  return 0;

}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    int x,y;
    cin>>x>>y;
    int ans = x+y/2;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

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

  ll w, a, b;
  cin >> w >> a >> b;

  if (b + w < a) {
    cout << a - (b + w) << "\n";
  } else if (a + w < b) {
    cout << b - (a + w) << "\n";
  } else {
    cout << 0 << "\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
  ll l;
  cin>>l;
  cout<<fixed<<setprecision(100)<<l*l*l/27.0;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll q=1;
  for(ll i=1;i<=q;i++)
    solve();
}

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); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9
const int mod = 998244353;
int N;
vector<int> D;
ll ans = 1;
int main(){ 
  cin >> N;
  D.resize(N);
  vector<int> cnt(N, 0);
  REP(i, N){
    cin >> D[i];
    cnt[D[i]]++;
  }
  FOR(i, 1, N){
    ll add = 1;
    REP(j, cnt[i]){
      add *= cnt[i-1];
      add %= mod;
    }
    ans *= add;
    ans %= mod;
  }
  if(cnt[0]!= 1 || D[0] != 0) ans = 0;
  bool flag = false;
  FOR(i, 1, N){
    if(cnt[i] == 0) flag = true;
    if(flag && cnt[i] != 0) ans = 0;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
long long h[10000010],x[10000010];
signed main(){
      
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,cnt=0;
  cin>>n;

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

  sort(x,x+n);

  for(int i=0; i<n; i++){
      if(h[i]-x[i]<=1){
          if(x[i]-h[i]<=1) cnt++;
      }else break;
  }

  if(cnt==n) cout<<"Yes"<<'\n';
  else cout<<"No"<<'\n';
}



Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n, m, s, g1, g2;
  while(cin >> n >> m >> s >> g1 >> g2 && n != 0){
    vector< vector<int> > nodes(n, vector<int>(n, 1000001));
    for(int i = 0; i < m; i++){
      int a,b,c;
      cin >> a >> b >> c;
      nodes[a-1][b-1] = c;
    }
    for(int i = 0; i < n ; i++){
      nodes[i][i] = 0;
    }
    for(int k = 0; k < n; k++){
      for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
          nodes[i][j] = min(nodes[i][j],nodes[i][k] + nodes[k][j]);
        }
      }
    }
    int mini = 2000000;
    for(int i = 0 ; i < n; i++){
      mini = min(mini, nodes[s-1][i] + nodes[i][g1-1] + nodes[i][g2-1]);
    }
    cout << mini << endl;
  }
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
using namespace std;

typedef long long ll;
using pi = pair<int, int>;

int main() {
  int N;
  cin >> N;
  N %= 1000;
  N = N == 0 ? 0 : 1000 - N;
  cout << N << endl;
  return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size();
typedef unsigned long  ull;
typedef long long  ll;
using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cin.tie(0);
	
	string s;
	cin>>s;
	if (s=="ABC")
		cout<<"ARC";
	else
		cout<<"ABC";	






 return 0;
 }


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

int main() {
	string s; cin >> s;
	int k; cin >> k;
	vector<string>dic;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j + i - 1 < s.size(); j++) {
			dic.push_back(s.substr(j, i));
		}
	}
	dic.push_back(s);
	sort(dic.begin(), dic.end());
	unique(dic.begin(), dic.end());
	cout << dic[k - 1] << endl;

	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
  int  a, b;
  cin >> a >> b;
  int  c = a + b;
  int  d = a * b;
  int  e = a - b;
  int ans = c;
  if(ans <= d) ans = d;
  if(ans <= e) ans = e;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int n;

vector<int> a, b;

bool eq(vector<int> a, vector<int> b) {
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i]) {
			return false;
		}
	}
	return true;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}

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

	vector<int> p;
	for (int i = 0; i < n; i++) {
		p.push_back(i + 1);
	}

	int cnt = 0;
	int ia, ib;
	do {
		if (eq(p,a)) {
			ia = cnt;
		}
		if (eq(p, b)) {
			ib = cnt;
		}
		cnt++;
	} while (next_permutation(p.begin(), p.end()));

	cout << abs(ia - ib) << endl;

	return 0;
}


Measured memory_bytes: 3608
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	var N = parseInt(input[0][0], 10);
	var M = parseInt(input[0][1], 10);
	var vec_a = input[1].map(e => parseInt(e, 10));
    var ans = calc(vec_a, N, M);
    console.log(ans);
}

function calc(vec_a, N, M){
    if (N > 1){
        var howManyDividedBy2 = 0;
        while(vec_a[0] % 2 === 0){
            vec_a[0] /= 2;
            howManyDividedBy2 ++;
        }
        for (var i = 1; i < N; i++){
            if (vec_a[i] %  Math.pow(2, howManyDividedBy2) !== 0) return 0;
            if (vec_a[i] %  Math.pow(2, howManyDividedBy2 + 1) === 0) return 0;
            vec_a[i] /= Math.pow(2, howManyDividedBy2);
        }
        vec_a.sort((a, b) => a - b);

        var tmp = BigInt(vec_a[0]);
        for (var i = 1; i < N; i++){
            tmp = saishoKobai(tmp, BigInt(vec_a[i]));
            if (tmp  * BigInt(Math.pow(2, howManyDividedBy2 - 1))> BigInt(M)) return 0;
        }

        var increment = Number(tmp) * Math.pow(2, howManyDividedBy2);
        var first = Number(tmp) * Math.pow(2, howManyDividedBy2 - 1);        
        
    } else {
        var increment = vec_a[0];
        var first = vec_a[0] / 2;
    }
    return (((M - first) / increment | 0) + 1);
}

function saishoKobai(x, y){
    if (x < y) [x, y] = [y, x];
    var tmp1 = x;
    var tmp2 = y;
    while (tmp2 != 0){
        [tmp1, tmp2] = [tmp2, tmp1 % tmp2];
    }
    return (BigInt(x) * BigInt(y) / BigInt(tmp1));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 49204
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a[200005],b[200005];
int main()
{
	ll n,k,x,a;cin>>n>>k;
	if(n>k) n=n-n/k*k;
	if(n<=abs(n-k))
 	cout<<n;
	 else cout<<abs(n-k);	
 } 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_169
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            decimal[] ab = ReadDecimals();
            decimal res = Floor(ab[0] * ab[1]);
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
        private static decimal[] ReadDecimals() { return Array.ConvertAll(Read().Split(), decimal.Parse); }
    }
}


Measured memory_bytes: 27572
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        String t = in.nextLine();
        int l = s.length();
        int count = 0;
        for(int i = 0 ; i < l ; i++){
            if(s.charAt(i)!=t.charAt(i))
                count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 42224
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    // Your code here!
    int N;
    unsigned long num = 0;
    string str;
    vector<string> s;
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> str;
        sort(str.begin(), str.end());
        s.push_back(str);
    }
    
    sort(s.begin(), s.end());
    
    unsigned long cnt = 0;
    
    for(int i=1; i<N; i++){
        cnt++;
        if(s[i-1].compare(s[i]) != 0){
            num += cnt * (cnt - 1) / 2;
            cnt = 0;
        }
    }
    
    cnt++;
    num += cnt * (cnt - 1) / 2;
    
    cout << num << endl;
}

Measured memory_bytes: 5748
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

const ll MOD = 1000000007;

ll fact[210000] = {};
void calc_fact() {
    fact[0] = 1;
    for (int i = 1; i < 210000; i++) {
        fact[i] = (i * fact[i - 1]) % MOD;
    }
}

int main() {
    int n; cin >> n;
    string s; cin >> s;
    calc_fact();

    int prev = 'W', flg = 1;
    V<int> S(2 * n);
    int pcnt = 0;
    loop (2 * n, i) {
        S[i] = flg ^ (prev == s[i]);
        flg = S[i];
        if (S[i]) pcnt++;
        prev = s[i];
    }
    if (pcnt != n) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    ll cnt = 0;
    loop (2 * n, i) {
        int j = 2 * n - 1 - i;
        if (S[j] == 0) cnt++;
        else {
            if (cnt <= 0) {
                cout << 0 << endl;
                return 0;
            }
            ans = ans * cnt % MOD;
            cnt--;
        }
    }

    cout << ans * fact[n] % MOD << endl;

    return 0;
}



Measured memory_bytes: 2948
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;

#define LL long long

const int MAXN = 10000000 + 5;
const LL MOD = 1000000000 + 7;


int c[MAXN], a[MAXN];


void divide(int m){
    
    for (int i = 2; i * i <= m; i ++){
        while (m % i == 0){
            c[i] ++;
            m /= i;
        }
    }
    if (m > 1){
        c[m] ++;
    }
}

bool isPairwiseCoprime(int m){
    bool pairwiseCoprime = true;
    vector< pair<int, int> > f;
    f.clear();
    for (int i = 2; i * i <= m; i ++){
        int cnt = 0;
        if (m % i == 0){
            while (m % i == 0){
                c[i] --;
                m /= i;
                cnt ++;
            }
            f.push_back(make_pair(i, cnt));
        }

    }
    if (m > 1){
        c[m] --;
        f.push_back(make_pair(m, 1));
    }
    for (int i = 0; i < f.size(); i ++){
        if (c[f[i].first] > 0){
            pairwiseCoprime = false;
            break;
        }
    }
    for (int i = 0; i < f.size(); i ++){
        c[f[i].first] += f[i].second;
    }
    return pairwiseCoprime;
}

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

int main()
{
    int N, maxa = 0;
    memset(c, 0, sizeof(c));
    cin >> N;
    for (int i = 0; i < N ; i ++){
        cin >> a[i];
        maxa = max(a[i], maxa);
        divide(a[i]);
    }
    bool pairwiseCoprime = true;
    for (int i = 0; i < N; i ++){
        if (isPairwiseCoprime(a[i]) == false){
            pairwiseCoprime = false;
            break;
        }
    }
    if (pairwiseCoprime){
        cout << "pairwise coprime";
    }
    else{
        int factor = gcd (a[0], a[1]);
        for (int i = 2; i < N ; i ++){
            factor = gcd (factor, a[i]);
            if (factor <= 1){
                break;
            }
        }
        if (factor <= 1){
            cout << "setwise  coprime";
        }
        else{
            cout <<  "not coprime";
        }
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 46588
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<stdio.h>
#include<list>
using namespace std;

#define ll long long

int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll na;
    na=abs(n);
    string s;
    char c;
    ll buf=1;
    if(n!=0){
        for(i=0;n!=0;i++,buf*=-2){
            c=(n%(buf*2)!=0)+'0';
            s.push_back(c);
            if(c=='1')n-=buf;
        }
    }
    else s.push_back('0');
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

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

    vector<int> A(N);
    vector<int> B(N);

    for(int i = 0; i < N; ++i){
        cin >> A[i];
        cin >> B[i];
    } 

    // dp[i] 体力を合計i減らすときにかかる魔力の最小値
    vector<long long int> dp(H+10010);

    // 初期化
    for(int i=0; i<H+10010; i++){
        dp[i] = 1000000000;
    }

    dp[0] = 0;
    
    for(int i=0; i<H+10010; i++){
        for(int j=0; j<N; j++){
            if(i - A[j] >= 0){
                dp[i] = min(dp[i], dp[i-A[j]] + B[j]);
            }
        }
    }

    long long int ans = 1000000000;

    for(int i=H; i<H+10010; i++){
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N, ans = 0;
  int a[100];


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

  for(int i = 1; i < N; i += 2){
    if(a[i-1] != a[i] && a[i] == a[i+1]){
      i--;
      continue;
    }else if(a[i-1] != a[i] && a[i] != a[i+1]){
      continue;
    }else{
      ans++;
    }
  }

  cout << ans << endl;

  return 0;

}


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

using namespace std;

int n;
vector<int> vec;
bool used[100005];

int main(void)
{
	cin >> n;
	
	int cnt = 0;
	for(int t = n; t; t/=2) cnt += t&1;
	if(cnt == 1){
		cout << "No" << endl;
		return 0;
	}
	
	int a;
	for(int i = 0; (1<<i) <= n; i++){
		a = 1<<i;
	}
	int b = n - a, p;
	
	
	int x = (n+1)/4-1;
	vec.push_back(1);
	vec.push_back(2);
	vec.push_back(3);
	vec.push_back(1);
	vec.push_back(2);
	vec.push_back(3);
	
	
	if(n >= 7){
		int l = (n+1)/4;
		for(int j = 1; j < l; j++){
			if(n % 4 == 0 && j == a/4) continue;
			for(int i = 0; i < 4; i++) vec.push_back(4*j+i);
			for(int i = 0; i < 4; i++) vec.push_back(4*j+i);
		}
	}
	if(n % 4 == 0){
		for(int j = 0; j < vec.size(); j++){
			if(vec[j] == b){
				p = j;
				break;
			}
		}
		for(int i = 0; i < 4; i++) vec.insert(vec.begin()+p, (a+i));
		for(int i = 0; i < 4; i++) vec.insert(vec.begin()+p, (a+i));
	}
	
	//for(int i = 0; i < vec.size(); i++) cout << vec[i] << " "; cout << endl;
	
	
	cout << "Yes" << endl;
	if(n % 4 == 0){
		cout << b << " " << n << endl;
		cout << a << " " << 2*n << endl;
	}
	else{
		if(n % 4 < 3){
			int y = (n/4)*4;
			cout << 2 << " " << y << endl;
			cout << 3+n << " " << n+y+1 << endl;
			cout << y << " " << y+1 << endl;
			cout << n+y+1 << " " << n+y << endl;
			if(n % 4 == 2){
				cout << y << " " << y+2 << endl;
				cout << 2+n << " " << n+y+2 << endl;
			}
		}
	}
	for(int i = 0; i < vec.size(); i++){
		if(used[vec[i]]) vec[i] += n;
		else used[vec[i]] = true;
	}
	for(int i = 1; i < vec.size(); i++){
		cout << vec[i-1] << " " << vec[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3828
unittest
{
	assert( [ "111100" ].parse.expand.solve == 4 );
	assert( [ "001001" ].parse.expand.solve == 2 );
	assert( [ "000000" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	return s.count!( ( c ) => c == '1' );
}


Measured memory_bytes: 256
N = input().split()

n = float(N[0])
m = float(N[1])
d = float(N[2])

#max_point = m-1
#total = n**m
#total_point = 0.
#point_sub = 0
#point_m = m-d
#point_m_sub = m
#for i in range(point_m):
#    point_sub += point_m_sub*(n-i)
#    point_m_sub -= 1

#print(str(point_sub/total))
if d == 0:
    ans = (m-1)/n
    print(str(ans))
else:
    ans = 2*(m-1)*(n-d)/n**2
    print(str(ans))


#for i in range(int(max_point)):
#    total_point += (n-d-i)*(m-i)

#print(str(total_point/total))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
vl v;

void input(void){
   cin>>n;
   inputv(v,n);
}

void solve(void){
    ll ans=0,a=0;
    rep(i,n-1){
        if(v[i+1]<=v[i])a++;
        else a=0;
        ans=max(ans,a);
    }
    cout<<ans<<endl;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 1400
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

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

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

int main(){
//    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    double A;
    double doubleLogAns = 0;
    long long B;
    long long ans = 1;
    double threshold = log(1e+18);
    bool overflow = false;
    vector<long long> As(N);
    for (int i = 0; i < N; i++) {
        cin >> As[i];
    }
    
    sort(As.begin(), As.end());
    
    for (int i = 0; i < N; i++) {
        B = As[i];
        if (B == 0) {
            cout << "0";
            return 0;
        }
        A = B;
        doubleLogAns += log(A);
        if (doubleLogAns > threshold) {
            overflow = true;
            cout << "-1";
            return 0;
        }
        ans *= B;
    }
    
    if (ans > 1000000000000000000) {
        cout << "-1";
    } else {
        cout << ans;
    }

    return 0;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
struct str{
	int a,b;
}a[110];
bool cmp(str x,str y){
	return x.a<y.a;
}
int main(){
	int n,m,x=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		int a1,b1;
		cin>>a1>>b1;
		if(b1<=m){
			a[i].a=a1;
			a[i].b=b1;
			x=1;	
		}
		else{
			a[i].a=99999999;
		}
	} 
	if(x==0){
		cout<<"TLE"<<endl;
		return 0;
	}
	sort(a+1,a+1+n,cmp);
	cout<<a[1].a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, i, in, cnt = 0;

    scanf("%d", &n);

    for(i = 1; i <= n; i++)
    {
        scanf("%d", &in);
        if(in&1 && i&1)
            cnt++;
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n], b[n], c[n - 1];
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n - 1) cin >> c[i];
    int ans = 0;
    rep(i, 0, n) {
        ans += b[a[i] - 1];

    }
    rep(i, 0, n - 1) {
        if (a[i] + 1 == a[i + 1]) ans += c[a[i] - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1005*1005 + 50;
vector<ll> adj[N];
vector<ll> topo;
unordered_map<ll,ll> released;
ll indeg[N];
ll n;
ll ans = 1;

bool toposort() //Returns 1 if there exists a toposort, 0 if there is a cycle
{
	priority_queue<ll, vector<ll>, greater<ll> > pq;
	for(ll i=1;i<=n;i++)
		for(auto &it: adj[i])
			indeg[it]++;
	for(ll i=1;i<=n;i++)
	{
		if(!indeg[i]){
			pq.push(i);
			released[i] = 1;
		}
	}
	while(!pq.empty())
	{
		ll u=pq.top();
		pq.pop();
		topo.push_back(u);
		for(auto &v:adj[u])
		{
			indeg[v]--;
			released[v] = max( released[v], 1 + released[u]);
			if(!indeg[v]){
				ans = max(ans, released[v]);
				pq.push(v);
			}
		}
	}
	if(topo.size()<n)
		return 0;
	return 1;
}



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(ll i=1; i<=n; ++i){
		vector<ll> oj;
		for(ll j=0; j<n-1; ++j){
			ll x; cin>>x; oj.push_back(x);
		}
		for(ll j=1; j<n-1; ++j){
			ll x1 = min(i,oj[j-1]);
			ll y1 = max(i,oj[j-1]);
			ll x2 = min(i,oj[j]);
			ll y2 = max(i,oj[j]);
			adj[ (x1-1) * n + y1 ].push_back( (x2-1) * n + y2 );
		}
	}
	n = n * n + 5;
	auto give = toposort();
	if( give == 0 ){ cout<<-1<<'\n'; }
	else{ cout<<ans<<'\n'; }

	return 0;
}


Measured memory_bytes: 99036
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
import std.typecons;
alias Pair = Tuple!(size_t, bool);
void main()
{
    immutable n = readln.chomp.to!size_t,
    a = readln.chomp.split.to!(long[]);
    // dp[i, k, 0] := max sum of k elements < i
    // dp[i, k, 1] := max sum of k-1 elements < i and a_i
    auto dp = new long[Pair][n];
    dp[0][Pair(size_t(0), false)] = 0;
    dp[0][Pair(size_t(1), true)] = a[0];
    foreach (i; 1..n)
    {
        foreach (kvp; dp[i-1].byKeyValue)
        {
            immutable
                k = kvp.key[0],
                f = kvp.key[1],
                v = kvp.value;
            if (k < n/2 - (n-i-f+1)/2)
                continue;
            if (auto p = Pair(k, false) in dp[i])
                dp[i][Pair(k, false)] = (*p).max(v);
            else
                dp[i][Pair(k, false)] = v;
            if (!f)
                dp[i][Pair(k+1, true)] = v + a[i];
        }
        debug stderr.writeln(dp[i]);
    }
    max(dp[n-1][Pair(n/2, true)], dp[n-1][Pair(n/2, false)]).writeln;
}


Measured memory_bytes: 74188
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Queue;
import java.util.Scanner;
import java.util.concurrent.ConcurrentLinkedQueue;

class Main {

	/*
	 * 最初は10番目のテストケースでTLEになったのがショックでした
	 */

	public static void main(String[] args) throws Exception {
		//入力と準備
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner scanner = new Scanner(br.readLine());
		int n = Integer.parseInt(scanner.next());
		int quantum = Integer.parseInt(scanner.next());
		scanner.close();
		String name[] = new String[n];
		int time[] = new int[n];
		Queue<Integer> queue = new ConcurrentLinkedQueue<Integer>();
		for(int i=0; i<n; i++) {
			scanner = new Scanner(br.readLine());
			name[i] = scanner.next();
			time[i] = Integer.parseInt(scanner.next());
			scanner.close();
			queue.add(i);
		}
		int currentTime =  0;
		//順に処理
		for(;!queue.isEmpty();) {
			Integer taskNo = queue.poll();
			time[taskNo] -= quantum;
			currentTime += quantum;
			if(time[taskNo] <= 0) {
				currentTime += time[taskNo];//超過しているので戻す
				System.out.println(name[taskNo]+" "+String.valueOf(currentTime));
				continue;
			}
			queue.add(taskNo);
		}

	}

}




Measured memory_bytes: 182648