akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
 
typedef long long ll;
#define INF 1000000000000000ll
 
ll calc(vector<ll>& s, vector<ll>& t,ll x);
 
ll A, B, Q;
vector<ll> si, ti, xi;
 
int main() {
  cin >> A >> B >> Q;
  si = vector<ll>(A+2);
  ti = vector<ll>(B+2);
  xi = vector<ll>(Q);
  si[0] = - INF;
  si[A+1] = INF;
  ti[0] = - INF;
  ti[B+1] = INF;
  for (ll i=0;i<A;i++){
    cin >> si[i+1];
  }
  for (ll i=0;i<B;i++){
    cin >> ti[i+1];
  }
  for (ll i=0;i<Q;i++){
    cin >> xi[i];
    cout << calc(si, ti, xi[i]) << endl;
  }
}
 
ll calc(vector<ll>& s, vector<ll>& t,ll x){
  ll m = INF;
  for (ll i=0;i<2;i++){
    vector<ll> &a = (i==0) ? s : t;
    vector<ll> &b = (i==0) ? t : s;
    for (ll j=0;j<2;j++){
      ll aidx = lower_bound(a.begin(),a.end(),x) - a.begin() -j;
      ll ax = a[aidx];
      for (ll k=0;k<2;k++){
        ll bidx = lower_bound(b.begin(),b.end(),x) - b.begin() -k;
        ll bx = b[bidx];
        m = min(m, abs(x - ax) + abs(ax - bx));
      }
    }
  }
  return m;
}


Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#define LL long long
using namespace std;
inline bool scan_d(int &num)  
{
        char in;bool IsN=false;
        in=getchar();
        if(in==EOF) return false;
        while(in!='-'&&(in<'0'||in>'9')) in=getchar();
        if(in=='-'){ IsN=true;num=0;}
        else num=in-'0';
        while(in=getchar(),in>='0'&&in<='9'){
                num*=10,num+=in-'0';
        }
        if(IsN) num=-num;
        return true;
}
int main()
{
    int n,m;
    while(scan_d(m)){
    	n=2;
	int ma[101][101];
    	ma[0][0] = ma[0][1] = ma[1][0] = 0;
    	for(int i = 1 ; i <= n ; i++){
    		for(int j = 1 ; j <= m ; j++){
    			scan_d(ma[i][j]);
			}
		}
		for(int i = 2; i <= n ; i++){
			ma[i][0] = 0;
		}
		for(int i = 2; i <= m ; i++){
			ma[0][i] = 0;
		}
		int flag = 0;
		for(int i = 1 ; i <= n ; i++){
			for(int j = 1 ; j <= m;j++){
				ma[i][j] += max(ma[i-1][j],ma[i][j-1]);
			}
		}
		if(flag){puts("");
			for(int i = 1 ; i <= n ; i++){
				for(int j = 1 ; j <= m ;j++){
					printf("%d ",ma[i][j]);
				}
				puts("");
			}
		}	
		printf("%d\n",ma[n][m]);
	}
}

Measured memory_bytes: 256
# 一行に整数ひとつだけ
A,B,C,D = gets.chomp.split.map(&:to_i)
CD = C.lcm(D)

AC = (A-1)/C
AD = (A-1)/D
ACD = (A-1)/CD
BC = B/C
BD = B/D
BCD = B/CD

p (B-A) + 1 - (BC - AC) - (BD - AD) + (BCD - ACD)

Measured memory_bytes: 1788
fun main(args: Array<String>) {
    a84(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}


fun a84(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val num = args[0].toInt()
    println(48 - num)
}

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

    ans=[0]*N
    ans[1]=abs(h[1]-h[0])


    for i in range(2,N):
        ans[i] = min(abs(h[i] - h[j]) + ans[j] for j in range(max(0,i-K),i))
    print(ans[N-1])
    
main()


Measured memory_bytes: 13980
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <atcoder/segtree>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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







int op(int a, int b){return std::max(a, b);}
int e(){return 0;}

int main(){
    int N, K; std::cin >> N >> K;
    atcoder::segtree<int, op, e> seg(300001);
    {
        int A;
        for(int i(0); i < N; ++i){
            std::cin >> A;
            seg.set(A, seg.prod(std::max(0, A - K), 
                                     std::min(300000, A + K) + 1) + 1);
        }
    }
    std::cout << seg.all_prod() << std::endl;

    return 0;
}


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

int main(){
    int num_value, i, j, value_stacked;
    cin >> num_value;
    vector<int> values(num_value);
    for(i=0;i<num_value;i++){
        cin >> values.at(i);
    }
    
    // 数列初期値の出力
    for(i=0;i<num_value-1;i++){
        cout << values.at(i) << " ";
    }
    cout << values.at(num_value-1) << endl;
    
    // 挿入ソート開始
    for(i=1; i<num_value; i++){
        value_stacked = values.at(i);
        j = i-1;
        
        while(j>=0 && values.at(j)>value_stacked){
            values.at(j+1) = values.at(j);
            j--;
        }
        values.at(j+1) = value_stacked;
        
        for(j=0;j<num_value-1;j++){
            cout << values.at(j) << " ";
        }
        cout << values.at(j) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h> 
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii; 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

   //int t; cin>>t; while(t--) 
	int l; cin>>l;
	double y=(double)l/3;
	double x=y*y*y;
	printf("%0.9lf",x);
    return 0 ;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
set<int> s;
int32_t main(){
	int n,m,x;cin>>n>>m>>x;for(int i=1;i<=m;i++){int tmp;cin>>tmp;s.insert(tmp);}
	int a1 = 0;
	for(int i=x;i>=0;i--)a1+=s.count(i);
	int a2 = 0;
	for(int i=x;i<=n;i++)a2+=s.count(i);
	cout<<min(a1,a2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll n, A, B, C;
vector<ll> L(8);

ll cost(vector<ll> S, ll i)
{
    if (i == n)
    {
        ll a = 0, b = 0, c = 0, m = 0;
        for (ll idx = 0; idx < n; idx++)
        {
            if (S[idx] == 0)
            {
                if (a != 0)
                    m += 10;
                a += L[idx];
            }
            if (S[idx] == 1)
            {
                if (b != 0)
                    m += 10;
                b += L[idx];
            }
            if (S[idx] == 2)
            {
                if (c != 0)
                    m += 10;
                c += L[idx];
            }
        }
        if (a == 0 or b == 0 or c == 0)
            return INT_MAX;
        return abs(A - a) + abs(B - b) + abs(C - c) + m;
    }
    S[i] = 0;
    ll cost_a = cost(S, i + 1);
    S[i] = 1;
    ll cost_b = cost(S, i + 1);
    S[i] = 2;
    ll cost_c = cost(S, i + 1);
    S[i] = 3;
    ll cost_n = cost(S, i + 1);
    return min(cost_a, min(cost_b, min(cost_c, cost_n)));
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> A >> B >> C;
    for (int i = 0; i < n; i++)
        cin >> L[i];
    cout << cost({3, 3, 3, 3, 3, 3, 3, 3}, 0) << endl;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)     
#define REPB(i ,n) for(int i=n; i >= 0; i--)   
#define FOR(i ,m ,n) for(int i=m; i < n; i++)  
#define FORB(i, m, n) for(int i=m; i>= m; i--) 
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

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

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

int main () {

    string S;
    cin >> S;

    string signboard = "CODEFESTIVAL2016";

    int ans = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S[i] != signboard[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define inf 10e9
using namespace std;
struct act{
    int a,b,c;
};
int solve(vector<act> arr,int n)
{
    int dp[n+1][3];
    dp[1][0]=arr[1].a;
    dp[1][1]=arr[1].b;
    dp[1][2]=arr[1].c;
    for(int i=2;i<=n;i++)
    {
        
        dp[i][0]=arr[i].a+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i].b+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i].c+max(dp[i-1][1],dp[i-1][0]);
    }
    int ans=max(dp[n][0],dp[n][1]);
    ans=max(ans,dp[n][2]);
    return ans;
}
int main() {
    int n;
    cin>>n;
    vector<act> arr(n+1);
    for(int i=1;i<=n;i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
        
        arr[i].a=x;
        arr[i].b=y;
        arr[i].c=z;

    }
    cout<<solve(arr,n);
}


Measured memory_bytes: 6664
#include<iostream>
using namespace std;
int main(){
  char t[3], s[3];
  scanf("%s", t);
  scanf("%s", s);
  int cnt = 0;
  for(int i =0; i<3; i++){
    if(s[i] == t[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> card(N,0);
  for(int i=0;i<N; i++){
    cin >> card.at(i);
  }
  sort(card.begin(),card.end());
  int out;
  out=0;
  for(int i=N-1;i>0;i=i-2){
    out=out+card.at(i)-card.at(i-1);
  }
  if(N%2==1){
    out=out+card.at(0);
  }
  cout << out <<endl;
}

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

int main() {
	// your code goes here
	int n,k,t;
	int ans ,ans1;
	cin>>n>>k>>t;
	ans = n/k;
	if(n%k!=0){
	    ans++;
	}
	ans1 = t*ans;
	cout<<ans1;
	
	return 0;
}


Measured memory_bytes: 3620
import math

N, D = (int(i) for i in input().split())
X = [[int(i) for i in input().split()] for i in range(N)]

ans = 0
for i in range(N):
    for j in range((N - i) - 1):
        A = 0
        if N - i == 0:
            continue
        for k in range(D):
            B = 0
            point1 = X[i][k]
            point2 = X[(i + j) + 1][k]
            B = B + point1 - point2
            A = A + pow(B, 2)
        C = math.sqrt(A)
        if C.is_integer():
            ans = ans + 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
    long long a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (a == 1) {
	if (b == 1) {
	    cout << 1;
	    return 0;
	}
	cout << b - 2;
	return 0;
    }
    if (a == 2) {
	cout << 0;
	return 0;
    }
    cout << (a - 2) * (b - 2);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] S = sc.next().toCharArray();
        int N = S.length;
        int K = sc.nextInt();
        int[][][] dp = new int[N+1][K+1][2];
        dp[0][0][1] = 1;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= K; j++) {
                for (int s = 0; s < 2; s++) {
                    if (dp[i][j][s] == 0)  continue;
                    if (s == 0) {
                        dp[i+1][j][0] += dp[i][j][0];
                        if (j+1 <= K) {
                            dp[i+1][j+1][0] += 9*dp[i][j][0];
                        }
                    } else {
                        int a = S[i]-'0';
                        if (a == 0) {
                            dp[i+1][j][1] += dp[i][j][1];
                        } else {
                            dp[i+1][j][0] += dp[i][j][1];
                            if (j+1 <= K) {
                                dp[i+1][j+1][0] += (a-1)*dp[i][j][1];
                                dp[i+1][j+1][1] += dp[i][j][1];
                            }
                        }
                    }
                }
            }
        }
        System.out.println(dp[N][K][0]+dp[N][K][1]);
    }
}



Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int N, A, B;
int h[1000010];
// index が条件を満たすかどうか
bool isOK(ll n) {
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += max(0ll,(h[i] - B * n + A - B - 1)) / (A - B);
	}
	if (sum <= n) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
ll binary_search() {
	ll ng = 0; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll ok = mod; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* ok と ng のどちらが大きいかわからないことを考慮 */
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;

		if (isOK(mid)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main()
{

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

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

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

    char s[N];
    for (int i=0;i<N;i++){
        cin >> s[i];
        
    }
    
    int ans=1;
    for (int i=1;i<N;i++){
        if(s[i] != s[i-1]){
            ans += 1;
            
        }
        
    }
    cout << ans;
    
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int N;
    cin >> N;
    int answer = 0;

    int dp[100001]={};
    for (int i = 0; i <= 100000;i++){
        dp[i] = 1000000;
    }
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 2;
    dp[3] = 3;
    dp[4] = 4;
    dp[5] = 5;
    int num_s = 6;
    int num_n = 9;
    for (int i = 6; i <= 100000; i++)
    {
        //1系
        for (int j = 1; j <= 5;j++)
        {
            if(dp[i-j]+j<=dp[i])
                dp[i] = dp[i - j] + j;
        }
        //6系

        while (i-num_s>=0){
            if(dp[i-num_s]+1<dp[i])
                dp[i] = dp[i - num_s] + 1;
            num_s *= 6;
        }

        //9
        while (i - num_n >= 0)
        {
            if (dp[i - num_n] + 1 < dp[i])
                dp[i] = dp[i - num_n] + 1;
            num_n *= 9;
        }
        num_s = 6;
        num_n = 9;
    }

    cout << dp[N] << endl;


    return 0;
}


Measured memory_bytes: 640
import std.algorithm,
       std.string,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] hw = readln.chomp.split.to!(int[]);
  int h = hw[0],
      w = hw[1];
  int n = readln.chomp.to!int;
  int[] ai = readln.chomp.split.to!(int[]);

  ulong[] tmp;

  foreach (i, a; ai) {
    foreach (j; a.iota) {
      tmp ~= i + 1;
    }
  }

  ulong[][] ans;

  foreach (i; h.iota) {
    auto t = tmp[(i*w)..((i+1)*w)];
    if (i % 2) {
      reverse(t);
    }
    writeln(t.to!(string[]).join(" "));
  }
}


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

int n;
int64_t a[16][16];
int64_t memo[1<<16];
static bool checked[1<<16];

int64_t dp(int s){
    if(s == 0) return 0;
    if(checked[s]) return memo[s];
    int64_t ret = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(s&(1<<i) && s&(1<<j)) ret += a[i][j];
        }
    }
    if(ret < 0) ret = 0;

    for(int t=(s-1)&s;t>0;t=(t-1)&s){
        ret = max(ret, dp(t) + dp(s-t));
    }
    checked[s] = true;
    memo[s] = ret;
    return ret;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) cin >> a[i][j];
    }

    cout << dp((1<<n)-1) << endl;
    
    return 0;
}

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

int main(){
	string str;
	bool f;
	while(getline(cin,str)){
		stack<char> st;
		f = true;
		if(str == ".") break;
		for(int i = 0;i < str.size();++i){
			if(str[i] == '(' || str[i] == '['){
				st.push(str[i]);
			}
			if(str[i] == ')' || str[i] == ']'){
				if(st.empty() || (str[i] == ')' && st.top() != '(') || (str[i] == ']' && st.top() != '[')){
					f = false;
					break;
				}
				else st.pop();
			}
		}
		if(!st.empty()) f = false;
		if(f) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    string s;
    cin >> s;
    if ( s == "ABC" ) {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
# https://atcoder.jp/contests/agc019/tasks/agc019_a

import itertools
import collections
import bisect
import sys
input = sys.stdin.readline

def main():
    Q, H, S, D = map(int, input().split())
    N = int(input())
    half = min(Q * 2, H)
    one = min(half * 2, S)
    two = min(one * 2, D)
    print(two * (N // 2) + one * (N % 2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
/*
      author : nishi5451
      created: 11.08.2020 01:02:02
*/

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


int main(){
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

Measured memory_bytes: 3636
n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]

def dfs(x):
  if visit[x]==True:
    return
  visit[x]=True
  for i in range(n):
    if graph[x][i]==True:
      dfs(i)

ans=0
for i in range(m):
  graph=[[False]*n for _ in range(n)]
  for j in range(m):
    if j!=i:
      a,b=AB[j]
      graph[a-1][b-1]=True
      graph[b-1][a-1]=True
  visit=[False]*n
  dfs(0)
  if sum(visit)!=n:
    ans+=1
print(ans)

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

int main(){
  int H,W;
  cin >> H >> W;
  
  int h = H;
  int w = W;
  
  vector<vector<char>> data(H, vector<char>(W, 0));
  vector<vector<char>> newdata(H, vector<char>(W, 0));
  

  for(int i=0; i<H;i++){
    for(int j=0;j<W;j++){
      char tmp;
      cin >> tmp;
      data.at(i).at(j) = tmp;
    }
  }
  int cnt = -1;
  for(int i=0; i<H;i++){
    int flg = 0;
    for(int j=0;j<W;j++){
      if (data.at(i).at(j) == '#') flg = 1;
    }
    if (flg == 1){
      cnt++;
      for (int j = 0; j<W;j++){
        newdata.at(cnt).at(j) = data.at(i).at(j);
      }
    }
  }
  int newh = cnt+1;
  
  cnt = -1;
  for(int i=0; i<W;i++){
    int flg = 0;
    for(int j=0;j<newh;j++){
      if (newdata.at(j).at(i) == '#') flg = 1;
    }
    if (flg == 1){
      cnt++;
      for (int j = 0; j<newh;j++){
        newdata.at(j).at(cnt) = newdata.at(j).at(i);
      }
    }
  }
  int neww = cnt+1;

  for(int i=0; i<newh;i++){
    for(int j=0;j<neww;j++){
      cout<<newdata.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
int N;
int mod[4] = {1000, 100, 10, 1};
int A[10];
int sum;

int main() {
	std::cin >> N;
	for (int i = 1; i <= 4; i++) {
		A[i] = N / mod[i - 1];
		sum += A[i];
		N %= mod[i - 1];
	}
	if (sum == 7) {
		std::cout << A[1] << "+" << A[2] << "+" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - A[2] * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "+" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - A[3] * 2 == 7) {
		std::cout << A[1] << "+" << A[2] << "-" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - A[4] * 2 == 7) {
		std::cout << A[1] << "+" << A[2] << "+" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[2]+A[3]) * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "-" << A[3] << "+" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[4] + A[3]) * 2 == 7) {
		std::cout << A[1] << "+" << A[2] << "-" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[2] + A[4]) * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "+" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	if (sum - (A[2] + A[3] + A[4]) * 2 == 7) {
		std::cout << A[1] << "-" << A[2] << "-" << A[3] << "-" << A[4] << "=7" << std::endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int f(int a,int b,int c){
	int res=0;
	res+=a/5*5*380*80/100+a%5*380;
	res+=b/4*4*550*85/100+b%4*550;
	res+=c/3*3*850*88/100+c%3*850;
	return res;
}

int main() {
	int n;
	while(n=in()){
		int res=1000000000;
		int a,b,c;
		for(a=0;a<=n/200+1;a++){
			for(b=0;b<=n/300+1;b++){
				for(c=0;c<=n/500+1;c++){
					if(a*200+b*300+c*500==n){
						chmin(res,f(a,b,c));
//cout<<a<<" "<<b<<" "<<c<<" "<<f(a,b,c)<<endl;
					}
				}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

#define LL long long
#define DB double
#define MAXN 2000000
#define MOD 998244353
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000000000000
#define mem(x,v) memset(x,v,sizeof(x))

LL read(){
	LL x=0,F=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*F;
}

int n,f[MAXN+5],mx[MAXN+5],ans[MAXN+5];
vector<int> G[MAXN+5];
int a[MAXN+5],b[MAXN+5];

int C(int x,int val){
	if(x>val)return 0;
	int res=1;
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==f[x])continue;
		res+=C(v,val);
	}return res;
}
void dfs1(int x){
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==f[x])continue;
		f[v]=x,mx[v]=max(mx[x],v);
		dfs1(v);
	}
	if(mx[x]>mx[f[x]]){
		b[x]=1;
		for(int i=0;i<G[x].size();i++){
			int v=G[x][i];
			if(v==f[x])continue;
			int tmp=C(v,mx[f[x]]);
			a[v]=C(v,mx[x])-tmp;
			b[x]+=tmp;
		}
	}
}
void dfs2(int x){
	for(int i=0;i<G[x].size();i++){
		int v=G[x][i];
		if(v==f[x])continue;
		ans[v]=ans[x];
		if(mx[x]>mx[f[x]])ans[v]+=a[v];
		if(mx[v]>mx[x])ans[v]+=b[v];
		dfs2(v);
	}
}

int main(){
	n=read();
	for(int i=1;i<n;i++){
		int u=read(),v=read();
		G[u].push_back(v);
		G[v].push_back(u); 
	}
	mx[1]=1;dfs1(1);
	dfs2(1);
	for(int i=2;i<=n;i++)printf("%d ",ans[i]);
}

Measured memory_bytes: 74884
#include <iostream>
#include <regex>

using namespace std;

int main()
{
	string s, p;
	regex re;
	cin >> s >> p;
	re = p;
	s += s;
	if (regex_search(s, re)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<double> p(n);
	rep(i, n) cin >> p[i];

	if (n == 1) {
		double l = p[0] * (p[0] + 1) / 2;
		l /= p[0];
		cout << fixed << setprecision(10) << l << endl;
		return 0;
	}

	vector<double> ans(n);
	rep(i, n) {
		ans[i] = p[i]*(p[i] + 1) / 2;
		ans[i] /= p[i];
	}
	
	vector<double> j_ans(n + 1);
	j_ans[0] = 0;
	for (int i = 1; i < n + 1; ++i) {
		j_ans[i] = j_ans[i - 1] + ans[i - 1];
	}

	double just_ans = 0;
	if (n == k) {
		just_ans = max(just_ans, j_ans[n] - j_ans[n - k]);
	}
	else {
		for (int i = k + 1; i < n + 1; ++i) {
			just_ans = max(just_ans, j_ans[i] - j_ans[i - k]);
		}
	}

	cout << fixed << setprecision(10) << just_ans << endl;
	
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
long long int r()
{
	string in;
	cin>>in;
	long long int res = 0;
	for (int i = 0; i < in.length(); ++i)
	{
		if ('0' <= in[i] && in[i] <= '9')
		{
			res = res * 10 + (in[i] - '0');
		}
	}
	return res;
}
int main(int argc, char const *argv[])
{
	long long int a, b;
	a = r();
	b = r();
	cout<<(a * b) / 100ll<<"\n";
	return 0;
}

Measured memory_bytes: 3624
<?php

$n = trim(fgets(STDIN));
$a = explode(' ', trim(fgets(STDIN)));
asort($a);

$f = 0;
foreach($a as $k => $v){
  if ($f == 1) {
    echo " ";
  } else {
    $f = 1;
  }
  echo $k+1;
}
  
?>

Measured memory_bytes: 16884
A, B, K = map(int,input().split())
listAB = []
for i in range(min(A,B)):
    if A%(i+1) == 0 and B % (i+1) == 0:
        listAB.append(i+1)
listAB.sort(reverse = True)
if A == 1 or B == 1:
    print(1)
else:
    print(listAB[K-1])

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

int main(){
	long long x, ans=0;	cin>>x;

	ans+=(x/500);	x-=ans*500;
	ans*=1000;

	//cout<<x<<endl;

	ans+=(x/5)*5;

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


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

int main() {
  int n;
  cin >> n;
  set<string> st;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (st.count(s) == 0) {
      st.insert(s);
    }
  }

  cout << st.size() << endl;
  return 0;
}


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

int main() {
  int ans = 0, temp = -1, n;

  cin >> n;

  vector<int> p(n);

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

  for (int i = 0; i < n; i++) {
    if (temp < p[i]) {
      temp = p[i];
    }
  }

  for (int i = 0; i < n; i++) {
    ans += p[i];
  }

  cout << ans - temp / 2;

  return 0;
}

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

int main() {int n;cin>>n;if(n%2!=0)
{cout<<"No"<<endl;return 0;}string s;cin>>s;
   if(s.substr(0,n/2)==s.substr(n/2)){cout<<"Yes"<<endl;}
   else{cout<<"No"<<endl;}
}

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


namespace StartFinish
{
    class Program
    {   
            
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int exchange_count = 0;

            for(int i = 0; i < n; i++)
            {
                int min = i;
                for(int j = i; j < n; j++)
                {
                    if (array[min] > array[j])
                    {
                        min = j;
                    }
                }
                if (min != i)
                {
                    int tmp = array[i];
                    array[i] = array[min];
                    array[min] = tmp;
                    exchange_count++;
                }
            }
            for(int i = 0; i < n - 1; i++)
            {
                Console.Write("{0} ",array[i]);
            }
            Console.WriteLine(array[n-1]);
            Console.WriteLine(exchange_count);
        }
    }
}

Measured memory_bytes: 9612
#!/bin/bash

read n
s=0
for i in $(seq 0 $(($n / 15 - 1))); do
    s=$(($s + ($i * 120) + 60))
done
for i in $(seq $((($n / 15) * 15)) $n); do
    if [ $((i % 3)) != 0 ]; then
        if [ $((i % 5)) != 0 ]; then
            s=$(($s + $i))
        fi
    fi
done
echo $s

Measured memory_bytes: 10196
<?php
fscanf(STDIN, '%d', $cnt);
$map = array_fill(0, $cnt, 0);
$nums = array_map('intval', explode(' ', trim(fgets(STDIN))));
for ($i=0; $i < $cnt-1; $i++) { 
    $map[$nums[$i]-1]++;
}
echo implode("\n", $map);

Measured memory_bytes: 42160
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        cs: chars,
    }
    let mut data = cs;
    if data[1] == 'R'
    {
        data[1] = 'B';
    }
    else if data[1] =='B'
    {
        data[1] = 'R';
    }
    for x in 0..3 {
        print!("{}",data[x]);
    }


    }
    


Measured memory_bytes: 2088
N=int(input())
S=input()
length=len(S)

alp='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
num=[i for i in range(26)]

def f(s, n, alp, add):
  out=[0 for i in range(n)]
  for i in range(n):
    for j in range(26):
      if s[i]==alp[j]:
        out[i]=j
        
  out2=[out[i]+add for i in range(n)]
  out3=[out2[i]%26 for i in range(n)]
  out4=[alp[out3[i]] for i in range(n)]
  return out4

ans=f(S, length, alp, N)

print("".join(ans))

Measured memory_bytes: 3316
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
int distsq(const vi &x, const vi &y){
  int ret = 0;
  rep(i,x.size()){
    ret += (x[i]-y[i]) * (x[i]-y[i]);
  }
  return ret;
}

bool is_int(int r){
  double rsq = sqrt((double)r);
  int a = (int)rsq;
  if((a-1)*(a-1)==r || a*a==r || (a+1)*(a+1)==r) return true;
  return false;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n,d;
  cin >> n >> d;
  vvi x(n,vi(d));
  rep(i,n){
    rep(j,d) cin >> x[i][j];
  }
  int ret = 0;
  rep(i,n){
    rep(j,i+1,n){
      if(is_int(distsq(x[i],x[j]))) ret++;
    }
  }
  cout << ret << endl;
  return 0;
}


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


class Node(object):

  def __init__(self, idx):
    self.idx = idx
    self.edges = []
    self.depth = -1

  def __str__(self):
    return '{}: -> {}'.format(self.idx, ','.join(str(e.idx) for e in self.edges))


def search(nodes):
  new_nodes = set()

  for node in nodes:
    for edge in node.edges:
      if edge.depth == -1:
        edge.depth = node.depth + 1
        new_nodes.add(edge)
      elif abs(edge.depth - node.depth) != 1:
        return False

  if len(new_nodes) == 0:
    return True

  return search(new_nodes)


def main():
  nodes = [Node(i) for i in range(int(input()))]
  value = 0

  for i in range(len(nodes)):
    for j, v in enumerate(map(int, input().strip())):
      if v == 1:
        nodes[i].edges.append(nodes[j])

  for i in range(len(nodes)):
    for node in nodes:
      node.depth = -1

    start = nodes[i]
    start.depth = 1

    if not search([start]):
      print(-1)
      return

    for node in nodes:
      value = max(node.depth, value)

  print(value)


if __name__ == '__main__':
  main()


Measured memory_bytes: 52444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 







signed main(){
    int t=1;
    // cin>>t;
    while(t--){
        int x;
        cin>>x;
        for(int i=-1000;i<=1000;i++){
            for(int j=-1000;j<=1000;j++){
                int a = pow(i,5);
                int b = pow(j,5);
                // cout<<a<<" "<<b<<" ## ";
                if(a-b==x){
                    cout<<i<<" "<<j<<endl;
                    return 0;
                }

            }
        }
    }
    return 0;
}

Measured memory_bytes: 4104
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
int n,m,ss;
char a[1001][1001];
int f[10][2];
int d[1001][1001];
int dir[4][2]={0,1,0,-1,1,0,-1,0};
typedef pair<int,int> P;
int bfs(int sx,int sy,int ex,int ey)
{
	memset(d,-1,sizeof(d));
	queue<P> q;
	q.push(P(sx,sy));
	d[sx][sy]=0;
	while(q.size())
	{
		const P p=q.front();
		q.pop();
		if(p.first==ex&&p.second==ey)
		{
			break;
		}
		for(int i=0;i<4;i++)
		{
			int tx=p.first+dir[i][0];
			int ty=p.second+dir[i][1];
			if(tx<0||tx>=n||ty<0||ty>=m||d[tx][ty]!=-1)
			{
				continue;
			}
			if(a[tx][ty]!='X')
			{
				q.push(P(tx,ty));
				d[tx][ty]=d[p.first][p.second]+1;
			}
		}
	}
	return d[ex][ey];
}
int main()
{
	while(cin>>n>>m>>ss)
	{
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(a[i][j]=='S')
				{
					f[0][0]=i,f[0][1]=j;
				}
				else if(a[i][j]>='1'&&a[i][j]<='9')
				{
					int x=a[i][j]-'0';
					f[x][0]=i;
					f[x][1]=j;
				}
			}
		}
		int step=0;
		for(int i=0;i<ss;i++)
		{
			step+=bfs(f[i][0],f[i][1],f[i+1][0],f[i+1][1]);
		}
		cout<<step<<endl;
	 } 
}


Measured memory_bytes: 7988
#include <stdio.h>


struct dice{
	int top;
	int bottom;
	int up;
	int down;
	int left;
	int right;
};


int north( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->down;
	n->down = n->bottom;
	n->bottom = n->up;
	n->up = temp;

	return 0;
};


int south( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->up;
	n->up = n->bottom;
	n->bottom = n->down;
	n->down = temp;

	return 0;
}







int west( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->right;
	n->right = n->bottom;
	n->bottom = n->left;
	n->left = temp;

	return 0;
}

int east( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->left;
	n->left = n->bottom;
	n->bottom = n->right;
	n->right = temp;

	return 0;
}

int compear( struct dice d1, struct dice d2 ){


	int i;

	if( d1.top == d2.up ) south( &d2 );
	else if( d1.top == d2.down ) north( &d2 );
	else if( d1.top == d2.right ) west( &d2 );
	else if( d1.top == d2.left ) east( &d2 );
	else if( d1.top == d2.bottom  ){
		north( &d2 ); north( &d2 );
	}

	//
	south( &d1 );
	south( &d2 );


	//
	for( i=0; i<4; i++ ){
		if( d1.up==d2.up && d1.down==d2.down &&
			d1.right==d2.right && d1.left==d2.left )
			break;

		west( &d2 );
	}


	//	
	if( d1.up==d2.up && d1.down==d2.down &&
		d1.right==d2.right && d1.left==d2.left &&
		d1.top==d2.top && d1.bottom==d2.bottom )
		return 0;
	else
		return 1;



}


int main(){

	int n, c=0, i;
	struct dice d1, d2;


	scanf( "%d", &n );

	scanf( "%d %d %d %d %d %d", &d1.top, &d1.down,
			&d1.right, &d1.left, &d1.up, &d1.bottom );

	for( i=1; i<n; i++ ){
		scanf( "%d %d %d %d %d %d", &d2.top, &d2.down,
			&d2.right, &d2.left, &d2.up, &d2.bottom );

		if( compear( d1, d2 ) ) c++;

	}

	if( c == (n-1) ) printf( "Yes\n" );
	else printf( "No\n" );



	return 0;

}

Measured memory_bytes: 580
#include<stdio.h>
#include<math.h>
struct P{double x,y;};
struct W{P p;double r;}w[100];
double D(P p){return sqrt(p.x*p.x+p.y*p.y);}
double I(P a,P b){return a.x*b.x+a.y*b.y;}
double O(P a,P b){return a.x*b.y-a.y*b.x;}
P F(P l,P r){P p={l.x-r.x,l.y-r.y};return p;}
double S(P a,P b,P c)
{
	if(I(F(b,a),F(c,a))<1e-9)return D(F(c,a));
	if(I(F(a,b),F(c,b))<1e-9)return D(F(c,b));
	return fabs(O(F(b,a),F(c,a)))/D(F(b,a));
}
int main()
{
	P a,b;
	int i,n,m;
	while(scanf("%d",&n),n)
	{
		for(i=0;i<n;++i)scanf("%lf%lf%lf",&w[i].p.x,&w[i].p.y,&w[i].r);
		for(scanf("%d",&m);m--;)
		{
			scanf("%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y);
			for(i=0;i<n;++i)
			{
				if(D(F(a,w[i].p))<=w[i].r&&D(F(b,w[i].p))<=w[i].r)continue;
				if(S(a,b,w[i].p)<=w[i].r){puts("Safe");goto E;}
			}
			puts("Danger");
E:;
		}
	}
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  int count = 0;
  
  for (int i = 0; i < S.size()-1; i++) {
    if (S.at(i) == S.at(i+1)) {
      count ++;
    }
  }
  
  if (count > 0) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  
  return 0;
}
    
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=1000005,mu=1000000007;
int p[N],inv[N],n,m,ans;
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*1ll*x%mu)
		if (y&1) ans=ans*1ll*x%mu;
	return ans;
}
int C(int x,int y){
	return p[x]*1ll*inv[y]%mu*inv[x-y]%mu;
}
int main(){
	scanf("%d%d",&n,&m);
	p[0]=1;
	for (int i=1;i<=n;i++) p[i]=p[i-1]*1ll*i%mu;
	inv[n]=ksm(p[n],mu-2);
	for (int i=n-1;i>=0;i--) inv[i]=inv[i+1]*1ll*(i+1)%mu;
	for (int i=0;i<=n/2;i++){
		int x=n-i*2;
		if (x*2+i==m){
			ans=(ans+C(x+i,i))%mu;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 8064
#include <cstdio>
typedef long long ll; 
ll MOD, dp[305][305], sum[305][305], C[305][305]; 
int main()
{
	// freopen("AGC024-E.in", "r", stdin); 
	int n, lim; 
	scanf("%d%d%lld", &n, &lim, &MOD); 
	for (int i = 0; i <= n; i++)
	{
		C[i][0] = 1; 
		for (int j = 1; j <= i; j++)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD; 
	}
	for (int i = 0; i <= lim; i++)
	{
		dp[1][i] = 1; 
		sum[1][i] = lim - i + 1; 
	}
	for (int i = 2; i <= n + 1; i++)
	{
		for (int j = lim; j >= 0; j--)
		{
			for (int k = 1; k < i; k++)
				(dp[i][j] += C[i - 2][k - 1] * dp[i - k][j] % MOD * sum[k][j + 1]) %= MOD; 
			sum[i][j] = (sum[i][j + 1] + dp[i][j]) % MOD; 
		}
	}
	printf("%lld\n", dp[n + 1][0]);
	return 0; 
}


Measured memory_bytes: 2304
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

char s[1 << 20];
int k;

int main() {
  scanf("%s%d", s, &k);
  int n = strlen(s);
  for (int i = 0; i < n - 1; i++) {
    if (s[i] != 'a') {
      int d = 'z' - s[i] + 1;
      if (k >= d) {
        k -= d;
        s[i] = 'a';
      }
    }
  }
  k %= 26;
  for (int i = 0; i < k; i++) {
    if (s[n - 1] == 'z') {
      s[n - 1] = 'a';
    } else {
      s[n - 1]++;
    }
  }
  printf("%s\n", s);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll T=0,N;
vector<vector<ll>> V(17);

void dfs(ll X,ll rt[],ll C){
    rt[X]=1;
    C++;
    if(C==N){
        T++;
    }
    else{
        rep(i,V[X].size()){
            if(rt[V[X][i]]==0){
                dfs(V[X][i],rt,C);
            }
        }
    }
    rt[X]=0;
}

int main(){
    ll M,A,B;
    ll rt[10];
    rep(i,10){
        rt[i]=0;
    }
    cin >> N >> M;
    rep(i,M){
        cin >> A >> B;
        V[A].push_back(B);
        V[B].push_back(A);
    }
    dfs(1LL,rt,0LL);
    cout << T << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
#include <stack>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

struct LazySegmentTree {
    vector<long long> data, lazy;
    int n;

    LazySegmentTree(int n_) {
        for(n = 1; n < n_; n *= 2);
        data.assign(n*2 - 1, 0);
        lazy.assign(n*2 - 1, 0);
    }

    void propagate(int i, int l, int r) {

        if(lazy[i] != 0) {
            data[i] += lazy[i];

            if(r - l > 1) {
                lazy[i*2+1] += lazy[i] / 2;
                lazy[i*2+2] += lazy[i] / 2;
            }
        }

        lazy[i] = 0;
    }

    void update(int a, int b, long long x, int i = 0, int l = 0, int r = -1) {
        if(r < 0) r = n;

        propagate(i, l, r);

        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[i] += (r - l) * x;
            propagate(i, l, r);
        } else {
            update(a, b, x, i*2+1, l, (l+r)/2);
            update(a, b, x, i*2+2, (l+r)/2, r);
            data[i] = data[i*2+1] + data[i*2+2];
        }
    }

    long long query(int a,int b,int i = 0,int l = 0, int r = -1) {
        if(r < 0) r = n;
        if(b <= l || r <= a) return 0;

        propagate(i, l, r);
        if(a <= l && r <= b) return data[i];
        long long vl = query(a, b, i*2+1, l, (l+r)/2);
        long long vr = query(a, b, i*2+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,q; cin >> n >> q;
    LazySegmentTree st(n);
    REP(i,q) {
        int y, s, t, x;
        cin >> y;
        if(y==0) {
            cin >> s >> t >> x;
            st.update(s-1, t, x);
        } else {
            cin >> s >> t;
            cout << st.query(s-1, t) << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 6980
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359
#define rep(i,n) for(int i=0;i<(n);i++)
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main()
{
    int n, ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < 10;i++){
        for (int j = 0; j < 10;j++){
            for (int k = 0; k < 10;k++){
                int count = 0;
                for (int l = 0; l < n; l++)
                {
                    int c;
                    if (count == 0)
                        c = i;
                    else if (count == 1)
                        c = j;
                    else if (count == 2)
                        c = k;
                    else if(count == 3)
                        break;
                    if(s[l]-'0'==c)
                        count++;
                }
                if(count == 3)
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define repn(i,a,b)   for(ll i=a;i>=b;i--)
#define F first
#define S second
#define qi queue<ll>
#define pii pair<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define vii vector<pii>
#define mi multiset<ll>
#define mii multiset<pii>
#define MI map<ll,ll>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define mod 998244353
#define mod2 998244353

// size_t f= str.find(string s,0); find s in str from start
// if found then (f != string::npos)
// m.insert({x,y}); m[x]=y;

int fexp(int a, int b){int ans = 1;while(b){if(b&1) ans = ans*a%mod2; b/=2;a=a*a%mod2;}return ans;}
int inverse(int a, int p){return fexp(a, p-2);}

int solve(){
    
    return 0;
}

signed main(){
    IOS
// 	#ifndef ONLINE_JUDGE
//     	freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	#endif
    char s;
  cin>>s;
  int a = s;
  if(a>=97&&a<=122) cout<<"a";
  else cout<<"A";
    return 0;
}


Measured memory_bytes: 3636