akhauriyash/Code-Regression huggingface dataset:
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,len,x,y,a[4],b[4];
string s,t;
map <char,pii> mp;

bool out(int xx,int yy)
{
	return xx<1||yy<1||xx>n||yy>m;
}

void solve(char fm,char sm,int val)
{
	int xx=x,yy=y;
	rep(i,len)
	{
		if(s[i]==fm)
		{
			xx+=mp[fm].fi;
			yy+=mp[fm].se;
			if(out(xx,yy))
			{
				puts("NO");
				//cout<<fm<<endl;
				exit(0);
			}
		}
		if(t[i]==sm)
		{
			if(!out(xx+mp[sm].fi,yy+mp[sm].se))
			{
				xx+=mp[sm].fi;
				yy+=mp[sm].se;
			}
		}
	}
}

int main()
{
	mp['U']={-1,0};
	mp['D']={1,0};
	mp['L']={0,-1};
	mp['R']={0,1};
	cin>>n>>m>>len>>x>>y>>s>>t;
	solve('U','D',x);
	solve('D','U',n-x+1);
	solve('L','R',y);
	solve('R','L',m-y+1);
	puts("YES");
	rt0;
}//stane

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



int main(){
	int n;
	scanf("%d",&n);

	int* d = new int[n];
	for(int i =0;i<n;i++){
		scanf("%d",&d[i]);
	}

	int sum = 0;

	for(int i=0;i<n;i++){
		for(int j=i+1; j<n;j++){
			sum += d[i]*d[j];
		}
	}

	printf("%d",sum);
	return 0;
}

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

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

    if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9)
    {
        cout << "hon" << endl;
        return 0;
    }
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
    {
        cout << "pon" << endl;
        return 0;
    }
    else if (n % 10 == 3)
    {
        cout << "bon" << endl;
        return 0;
    }
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 5; i++){
            int x = sc.nextInt();
            if (x == 0) {
                System.out.println(i+1);
                return;
            }
        }
    }
}

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

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(V) sort((V).begin(),(V).end())
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).length(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) for(int i = 0; i < (V).length(); i++) {cout << (V).at(i) << endl;}

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
string s,t;
//

signed main() {
  RAPID;
  IN2(n,s);
  REP(i,n-2) {
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') c++;
  }
  OUT(c);
}

Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}


vector<ll> yakusuu;
int main() {
	ll N, K;

	cin >> N >> K;
	vector<ll> A(N);
	vector<ll> B(N), B2(N);
	ll sum = 0;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];

	}
	vector< int64_t > yakusuu;
	for (int64_t i = 1; i * i <= sum; i++) {
		if (sum % i == 0) {
			yakusuu.push_back(i);
			if (i * i != sum) yakusuu.push_back(sum / i);
		}
	}


	ll ans = 1;
	
	rep(i, yakusuu.size()) {
		ll sum2 = 0;
		rep(j, N) {
			B[j] = yakusuu[i] - (A[j] % yakusuu[i]);
			B2[j] = (A[j] % yakusuu[i]);
			sum2 += B2[j];
		}

		sort(B.begin(), B.end());
		sort(B2.begin(), B2.end());

		ll sum3 = 0;
		rep(j, B.size()) {
			sum3 += B[j];
			sum2 -= B2[B.size() - 1 - j];
			if (sum3 == sum2 && sum3 <= K) { ans = max(ans, yakusuu[i]); break; }
		}
		

	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int x1, x2, x3, x4, y1, y2, y3, y4, X, Y;

	cin >> x1 >> y1 >> x2 >> y2;

	X = x1 - x2;
	Y = y1 - y2;

	x3 = x2 + Y;
	y3 = y2 - X;

	x4 = x1 + Y;
	y4 = y1 - X;

	cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << ' ' << endl;

	return 0;
}


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

int main(){
  int n;
  ll c;
  cin >> n >> c;
  ll x[n],v[n];
  rep(i,n)cin >> x[i] >> v[i];
  //右
  ll vsr[n+1];
  vsr[0]=0;
  rep(i,n)vsr[i+1]=vsr[i]+v[i];
  ll r[n+1];
  r[0]=0;
  //左
  rep(i,n)r[i+1]=max(r[i],vsr[i+1]-x[i]);
  ll vsl[n+1];
  vsl[0] = 0;
  rep(i,n)vsl[i+1]=vsl[i]+v[n-i-1];
  ll l[n+1];
  l[0]=0;
  rep(i,n)l[i+1]=max(l[i],vsl[i+1]-c+x[n-i-1]);
  //search
  ll ans = 0;
  rep(i,n){
    ans = max(ans,r[i+1]);
    ans = max(ans,vsr[i+1]-2*x[i]+l[n-i-1]);
    ans = max(ans,l[i+1]);
    ans = max(ans,vsl[i+1]-2*(c-x[n-i-1])+r[n-i-1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;

int N;
const int MAX_N = 100010;
int color[MAX_N], par[MAX_N];
mat path;

void dfs(int v,int p){
    par[v] = p;
    for(int u:path[v]){
        if(u==p)continue;
        dfs(u,v);
    }
}

void paint(int v,int p){
    color[v] = color[p];
    for(int u:path[v]){
        if(u==p)continue;
        if(color[u])continue;
        paint(u,v);
    }
}

bool solve(){
    dfs(1,0);
    int cnt = 0;
    for(int v=N;v>0;v=par[v]){
        cnt++;
    }
    for(int v=N,i=0;v>0;v=par[v],i++){
        if(i<cnt/2)color[v] = 2;
        else color[v] = 1;
    }
    
    for(int v=N;v>0;v=par[v]){
        paint(v,v);
    }

    cnt = 0;
    for(int i=1;i<=N;i++){
        cnt += (color[i] == 1);
    }
    return cnt>(N/2);
}

int main(){
    
    scanf("%d",&N);
    path.assign(N+1, vec());
    for(int i=0,x,y;i<N-1;i++){
        scanf("%d%d",&x,&y);
        path[x].push_back(y);
        path[y].push_back(x);
    }

    if(solve()){
        puts("Fennec");
    }else{
        puts("Snuke");
    }

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i, n) for (i=0;i<n;i++)

using namespace std;
long long i, x, y, a, b, c, t, u=0, v=0, w=0, sum=0, pt, qt, rt;
priority_queue<long long> p, q, r;

int main() {
    scanf(" %lld %lld %lld %lld %lld", &x, &y, &a, &b, &c);
    for (i=0;i<a;i++) {
        scanf("%lld", &t);
        p.push(t);
    }
    for (i=0;i<b;i++) {
        scanf("%lld", &t);
        q.push(t);
    }
    for (i=0;i<c;i++) {
        scanf("%lld", &t);
        r.push(t);
    }
    while (x + y > u + v + w) {
        if (p.empty()) pt = -1; else pt = p.top();
        if (q.empty()) qt = -1; else qt = q.top();
        if (r.empty()) rt = -1; else rt = r.top();

        if (x > u && y > v) {
            if (max(pt, max(qt, rt)) == pt) {
                sum += pt;
                p.pop();
                u++;
            } else if (qt >= rt) {
                sum += qt;
                q.pop();
                v++;
            } else {
                sum += rt;
                r.pop();
                w++;
            }
        } else if (x == u && y > v) {
            if (qt >= rt) {
                sum += qt; q.pop(); v++;
            } else {
                sum += rt; r.pop(); w++;
            }
        } else if (x > u && y == v) {
            if (pt >= rt) {
                sum += pt; p.pop(); u++;
            } else {
                sum += rt; r.pop(); w++;
            }
        }
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 3316
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author varunvats32
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CWelcomeToAtCoder solver = new CWelcomeToAtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class CWelcomeToAtCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();

            // Skip the extra newline
            in.nextLine();

            Map<Integer, CWelcomeToAtCoder.Pair> map = new HashMap<>();

            for (int i = 1; i <= M; i++) {
                String l = in.nextLine();
                String[] token = l.split(" ");
                Integer p = Integer.parseInt(token[0]);
                String sub = token[1];

                if (map.containsKey(p)) {
                    if (!map.get(p).succeed)
                        if (sub.equals("WA"))
                            map.put(p, new CWelcomeToAtCoder.Pair(map.get(p).count + 1, false));
                        else
                            map.put(p, new CWelcomeToAtCoder.Pair(map.get(p).count, true));
                } else {
                    if (sub.equals("WA"))
                        map.put(p, new CWelcomeToAtCoder.Pair(1, false));
                    else
                        map.put(p, new CWelcomeToAtCoder.Pair(0, true));
                }
            }


            long pen = 0;
            long cor = 0;

            for (Map.Entry<Integer, CWelcomeToAtCoder.Pair> entry : map.entrySet()) {
                if (entry.getValue().succeed) {
                    cor += 1;
                pen += entry.getValue().count;}
            }


            out.println(cor + " " + pen);
        }

        static class Pair {
            int count;
            boolean succeed;

            public Pair(int c, boolean s) {
                count = c;
                succeed = s;
            }

        }

    }
}



Measured memory_bytes: 116264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   ll n,i;
   map<ll,ll>a;
   map<ll,ll>b;
   cin>>n;
   for(i=1; i<=n; i++)
   {
       cin>>a[i]>>b[i];
   }
   for(i=1; i<=(n-2); i++)
   {
       if((a[i]==b[i]) && (a[i+1]==b[i+1]) && (a[i+2]==b[i+2]))
       {
           cout<<"Yes";
           return 0;
       }
   }
   cout<<"No";



}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define sff(x)     scanf("%lld",&x)
int main()
{
    long long x[5];
    sff(x[0]),sff(x[1]),sff(x[2]);
    if(x[0]%2==0 or x[1]%2==0 or x[2]%2==0){printf("0");return 0;}
    sort(x,x+3);
    printf("%lld",x[0]*x[1]);
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	var n, x, y int
	fmt.Fscan(fp, &n)
	tree := make([][]int, n+1)
	visited := make([]int, n+1)
	dp := make([][]int64, 2)
	dp[0] = make([]int64, n+1)
	dp[1] = make([]int64, n+1)
	for i := 0; i < n-1; i++ {
		fmt.Fscan(fp, &x, &y)
		tree[x] = append(tree[x], y)
		tree[y] = append(tree[y], x)
	}
	w, b := chokudai(1, tree, visited, dp)
	fmt.Println((w + b) % 1000000007)
}

func chokudai(node int, tree [][]int, visited []int, dp [][]int64) (int64, int64) {
	l := len(tree[node])
	dp[0][node] = int64(1)
	dp[1][node] = int64(1)
	visited[node] = 1
	for i := 0; i < l; i++ {
		if visited[tree[node][i]] == 1 {
			continue
		}
		visited[tree[node][i]] = 1
		w, b := chokudai(tree[node][i], tree, visited, dp)
		dp[0][node] = (dp[0][node] * (w + b)) % 1000000007
		dp[1][node] = (dp[1][node] * w) % 1000000007
	}
	return dp[0][node], dp[1][node]
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<P> a(n);
  rep(i, n) cin >> a[i].first, a[i].second = i;
  sort(a.rbegin(), a.rend());

  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));

  rep(i, n) for (int j = 0; i + j < n; ++j) {
    dp[i + 1][j] =
        max(dp[i + 1][j], 
            dp[i][j] + a[i + j].first * (a[i + j].second - i));
    dp[i][j + 1] =
        max(dp[i][j + 1],
            dp[i][j] + a[i + j].first * (n - 1 - j - a[i + j].second));
  }
  rep(i, n + 1) ans = max(ans, dp[i][n - i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34672
#include<iostream>
using namespace std;
void solve()
{
string s;
cin>>s;
long long int sum(0);
for(int i=0; i<s.length(); ++i)
sum+=(s[i]-'0');
if(sum%9)
cout<<"No";
else
cout<<"Yes";
}
int main()
{
int t;
t=1;
while(t--)
solve();
return 0;
}


Measured memory_bytes: 3356
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    for(int i=0;i<10;++i){
        for(int j=0;j<10;++j){
            if(i*j==N){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const dangers = arg.slice(1, M + 1);
    
    let answer = [...Array(N + 1)].fill(1);
    let broken = -1;
    let NG     = false;
    
    for(let i in dangers) {
        if(broken + 1 === dangers[i]) {
            NG = true;
        }
        
        answer[dangers[i]] = 0;
        broken = dangers[i];
    }
    
    for(let i=2; i<=N; i++) {
        answer[i] = answer[i] * (answer[i - 2] + answer[i - 1]) % 1000000007;
    }
    
    console.log(answer[N]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 32076
n = int(input())
primenumber = []
if n == 1 :
    primenumber = []
else :
    for i in range(2, n + 1) :
        for j in range(2, i + 1) :
            if i == j :
                pass
            elif i % j == 0 :
                break
        else :
            primenumber += [j]
powers = [0] * len(primenumber)
for i in range(len(primenumber)) :
    prime = primenumber[i]
    power = 0
    k = 1
    while n // (prime ** k) > 0 :
        power += n // (prime ** k)
        k += 1
    powers[i] = power + 1
ans = 1
for power in powers :
    ans *= power
print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

bool isprime(lint x) {
	//xが素数:true,xが素数でない:false
	if (x == 2) {
		return true;
	}
	else if (x == 1 || x % 2 == 0) {
		return false;
	}
	else {
		lint i = 3;
		while (i * i <= x) {
			if (x % i == 0) {
				return false;
			}
			i += 2;
		}
		return true;
	}
}

int main() {
	int N;
	cin >> N;
	int a = 0;
	int cnt = 0;
	rep(i, N) {
		cin >> a;
		if (isprime(a))cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int c, r;
	while (cin >> r >> c) {
		if (c == 0 && r == 0) {
			break;
		}
		vector< vector<int> > data(r, vector<int>(c));
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				cin >> data[i][j];
			}
		}
		int ll = 2 << r;
		long long int ccc = 0;
		for (int i = 0; i < ll; i++) {
			vector< vector<int> > d2;
			d2 = data;
			for (int j = 0; j < r; j++) {
				for (int k = 0; k < c; k++) {
					if ((i & (2<<j)) != 0) {
						d2[j][k] ^= 1;
					}
				}
			}
			long long int cc = 0;
			for (int k = 0; k < c; k++) {
				int ss = 0;
				for (int j = 0; j < r; j++) {
					ss += d2[j][k];
				}
				cc += (long long int)max(ss, r-ss);
			}
			ccc = max(ccc, cc);
		}
		cout << ccc << endl;
	}
	return 0;
}

Measured memory_bytes: 2024
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x))
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e5 + 5, M = 50 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;

ll fact[N], dgs, mnks;
void calcFac()
{
    fact[0] = 1;
    for (ll i = 1 ; i <= N ; i++)
        fact[i] = (i * fact[i - 1]) % mod;
}
int main()
{
    MuhammedAly
    calcFac();
    cin >> dgs >> mnks;
    if(abs(dgs - mnks) > 1)
        cout << 0;
    else if(abs(dgs - mnks) == 0)
        cout << (((fact[dgs] * fact[mnks]) % mod) * 2) % mod;
    else
        cout << (fact[dgs] * fact[mnks]) % mod;
    return 0;
}

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

int main(){

    string AL="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string al="abcdefghijklmnopqrstuvwxyz";

    string s;
    cin >> s;

    rep(i,al.size()){
        if(s[0]==al[i]){
            cout << al[i+1] << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<bool>> G(N, vector<bool>(N, false));
  rep(i, M){
    int a, b;
    cin >> a >> b;
    G.at(a-1).at(b-1) = true;
    G.at(b-1).at(a-1) = true;
  }
  
  vector<int> vec(N-1);
  rep(i, N-1) vec.at(i) = i+1;
  int ans = 0;
  do { 
    if(!G.at(0).at(vec.at(0))) continue;
    bool flag = true;
    for(int i = 0; i < N - 2 ; i++){
      if (!G.at(vec.at(i)).at(vec.at(i+1))){
        flag = false;
        break;
      }
    }
    if(flag) ans++;
  } while (next_permutation(all(vec)));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define ld     long double
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    ld a,b;
    cin>>a>>b;
    a*=b;
    int m=a;
    cout<<m;
}
int32_t main()
{
    clock_t tStart = clock();
    // #ifndef ONLINE_JUDGE
    // _READ
    // #endif
    _FAST    
    int t;
    t=1;
    while(t--)
        solve();
    
    #ifndef ONLINE_JUDGE
    cout<<fixed<<setprecision(5)<<"\nTime taken: "<<(double)(clock() - tStart)/CLOCKS_PER_SEC;
    #endif
    
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/

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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    REP(i, n) cin >> x[i] >> y[i];

    vector<int> a(n);
    iota(ALL(a), 0);
    double t = 0.0;
    do {
        REP(i, n - 1) {
            t += sqrt((x[a[i + 1]] - x[a[i]]) * (x[a[i + 1]] - x[a[i]]) + (y[a[i + 1]] - y[a[i]]) * (y[a[i + 1]] - y[a[i]]));
        }

    } while (next_permutation(ALL(a)));
    int b = 1;
    REP1(i, n) {
        b *= i;
    }
    cout << t / b << EOL;
}


Measured memory_bytes: 384
#include <stdio.h>

int main() {
    while (1) {
        int i;
        int value, change;
        int array[6] = {500, 100, 50, 10, 5, 1};
        int times = 0; 
        int tmp;

        scanf("%d", &value);
        if (!value) return 0;

        change = 1000 - value;

        tmp = change;
        for (i=0;i<6;i++) {
            times += (tmp/array[i]);
            tmp %= array[i];
        }

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

Measured memory_bytes: 1028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static InputStreamReader is = new InputStreamReader(System.in);
	static BufferedReader br = new BufferedReader(is);
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		try {
			String S = br.readLine();
			String[] Ss = S.split(" ");
			int a = Integer.parseInt(Ss[0]);
			long b = Long.parseLong(Ss[1]);
			if(a+b<10) {
				System.out.println(a+b);
			}else {
				System.out.println("error");
			}

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 21332
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    brs = sorted(zip(a, b), key=lambda br: br[1])
    last = -1
    ans = 0
    for ai, bi in brs:
        if ai <= last:
            continue
        ans += 1
        last = bi - 1
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19796
import math

a,b,h,m=map(int,input().split())
def c(a,b,h,m):
  theta=abs((h*30+m*0.5)-m*6)
  if theta>180:
        theta=360-theta
  h=a**2+b**2-2*a*b*math.cos(math.radians(theta))
  print(math.sqrt(h))

c(a,b,h,m)

Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
int N, M, D[100010]; 
int INF = 1145141919; 
pair<int, int> A[100010]; 
vector<int> E[100010]; 
map<pair<int, int>, int> mp;
vector<int> ans;  
bool seen[100010];
void dfs(int i, int p){
	if(seen[i]) return; 
	seen[i] = true; 
	for(int j = 0; j < E[i].size(); j++){
		if(seen[E[i].at(j)]) continue; 
		dfs(E[i].at(j), i); 
	}
	if(D[i] % 2){
		D[i] ++; D[p] ++; 
		ans.push_back(mp[make_pair(i, p)]); 
	}
}
int main(){
	cin >> N >> M; 	
	for(int i = 0; i < N; i++){
		cin >> A[i].first >> A[i].second; 
	}
	A[N].first = -INF; A[N].second = 0; 
	A[N+1].first = INF; A[N+1].second = 0; 
	sort(A, A+N+2); 
	for(int i = 0; i < N+1; i++){
		D[i] = (A[i+1].second ^ A[i].second); 
	}
	for(int i = 0; i < M; i++){
		int L, R; cin >> L >> R; 
		int a = lower_bound(A, A+N+2, make_pair(L, 0)) - A - 1; 
		int b = upper_bound(A, A+N+2, make_pair(R, 2)) - A - 1; 
		if(a == b) continue; 
		E[a].push_back(b); E[b].push_back(a);
		mp[make_pair(a, b)] = i + 1; 
		mp[make_pair(b, a)] = i + 1;  
	}
	for(int i = 0; i < N+1; i++) dfs(i, 100008);
	if(D[100008]){
		cout << -1 << endl; return 0; 
	}
	sort(ans.begin(), ans.end()); 
	cout << ans.size() << endl; 
	for(int i = 0; i < ans.size(); i++){
		cout << ans.at(i) << " "; 
	}
	cout << endl; 
}

Measured memory_bytes: 41596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[3][3];
bool b[3][3];
int main(void){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	int n; cin>>n;
	for(int i=0;i<n;i++){
		int A;
		cin>>A;
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(a[j][k]==A){
					b[j][k]=true;
				}
			}
		}
	}
	if(b[0][0]&&b[0][1]&&b[0][2]){
		cout<<"Yes"<<endl;
	}else if(b[1][0]&&b[1][1]&&b[1][2]){
		cout<<"Yes"<<endl;
	}else if(b[2][0]&&b[2][1]&&b[2][2]){
		cout<<"Yes"<<endl;
	}else if(b[0][0]&&b[1][0]&&b[2][0]){
		cout<<"Yes"<<endl;
	}else if(b[0][1]&&b[1][1]&&b[2][1]){
		cout<<"Yes"<<endl;
	}else if(b[0][2]&&b[1][2]&&b[2][2]){
		cout<<"Yes"<<endl;
	}else if(b[0][0]&&b[1][1]&&b[2][2]){
		cout<<"Yes"<<endl;
	}else if(b[0][2]&&b[1][1]&&b[2][0]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	    
}


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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


class Union_Find_size{
public:
  vector<int> Parent;
  //コンストラクタ
  Union_Find_size(int N){
    Parent=vector<int>(N,-1);
  }
  //木の根を求める
  int root(int x){
    //x（自分）が親ならxを返す
    if(Parent.at(x)<0)  return x;
    //経路圧縮しながら return する
    return Parent.at(x)=root(Parent.at(x));
  }
  //xの属する木の要素数を調べる
  int size(int x){
    return -Parent.at(root(x));
  }
  //xとyが同じ集合に属するかを判定する
  bool same(int x,int y){
    return root(x)==root(y);
  }
  //xとyの属する集合を併合する
  void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)  return;
    if(size(x)<size(y)) swap(x,y);
    Parent.at(x)+=Parent.at(y);
    Parent.at(y)=x;
  }
};

//abc097d,abc120d,abc126e
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;
  vector<int> p(N);
  rep(i,N){
    cin >> p.at(i);
    p.at(i)--;
  }
  Union_Find_size uni(N);
  rep(i,M){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    uni.unite(x,y);
  }

  int ans=0;
  rep(i,N){
    if(uni.same(i,p.at(i))) ans++;
  }
  cout << ans << endl;

  return 0;
}

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


int main()
{
	int n,m,c=0,b=0;
  	float s=0,k;
  cin >> n >> m;
  int a[n];
  rep(i,n){
  	cin >> a[i];
    s+=a[i];
  }
k=s/(4*m);
rep(i,n)
{
  if(a[i]>=k) b++;
  else c++;
  if(b>=m) {cout << "Yes"; return 0;}
  else if(n-c<m){ cout << "No"; return 0;}
    
}
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int cnt = 0;
	if (a % 10 != 0) {
		cnt = a % 10;
	}
	if (b % 10 != 0) {
		cnt = min(cnt, b % 10);
	}
	if (c % 10 != 0) {
		cnt = min(cnt, c % 10);
	}
	if (d % 10 != 0) {
		cnt = min(cnt, d % 10);
	}
	if (e % 10 != 0) {
		cnt = min(cnt, e % 10);
	}
	if (cnt != 0) {
		cnt -= 10;
	}
	a = (a + 9) / 10 * 10;
	b = (b + 9) / 10 * 10;
	c = (c + 9) / 10 * 10;
	d = (d + 9) / 10 * 10;
	e = (e + 9) / 10 * 10;
	cout << a + b + c + d + e + cnt << endl;
	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long
//using mint = atcoder::modint;

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, std::vector<long long> x, std::vector<long long> y){
    vector<pair<pair<int, int>, int>> XY(N);
    rep(i,0,N) XY[i] = {{x[i], y[i]}, i+1};
    sort(all(XY));
    set<pair<pair<int, int>, int>> yRange;
    atcoder::dsu d(N+1);
    rep(i,0,N) {
        int Y = XY[i].first.second;
        int index = XY[i].second;
        if (yRange.empty() || yRange.begin()->first.first > Y) {
            yRange.insert({{Y, Y}, index});
        } else {
            int maxY = Y, minY = yRange.begin()->first.first;
            for (auto itr = yRange.begin(); itr != yRange.end();) {
                const auto& range = *itr;
                if (range.first.first > Y) break;
                d.merge(range.second, index);
                maxY = max(maxY, range.first.second);
                itr = yRange.erase(itr);
            }
            yRange.insert({{minY, maxY}, index});
        }
    }
    rep(k,1,N+1) {
        cout << d.size(k) << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 15160
x,n=map(int,input().split())
p=list(map(int,input().split()))

if n==0:
    print(x)
    exit(0)

p=sorted(p)

dist=10*9
ans=102
for i in range(102,-2,-1):
    if abs(x-i)<=dist and i not in p:
        dist = abs(x-i)
        ans = i
        if i<=ans:
            ans = i
        

print(ans)




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

int main() {
    int N, K;
    cin >> N >> K;
    int count = N;
    int answer = K;
    for (int i = 1; i < count; i++)
    {
        answer *= (K-1);
    }
    cout << answer << endl;
    



}


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

int main(){
    int N,a,u;
    a=0;u=0;
    string s,ans;
    cin >> N;
    ans="YES";
    for(int i=0;i<N;i++){
        cin >> s;
        if(s.at(0)=='A'){
            a++;
        }else{
            u++;
        }
        if(u>a){
            ans="NO";
        }
    }
    if(a!=u) ans="NO";
    cout << ans << endl;
}


Measured memory_bytes: 3236
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,i;
    cin>>n;
    vector<pair<int,pair<int,int> > > vp(n);
    int a,b;
    rep(i,n){
        cin>>a>>b;
        vp[i]=mp(b,mp(a,i+1));
    }
    Sort(vp);
    vector<int> v(n+1);//v[i]は仕事iの終了時間
    int time=0;
    bool ch=true;
    for(i=0;i<n;i++){
        time+=vp[i].second.first;
        v[vp[i].second.second]=time;
        if(vp[i].first<time)ch=false;
        // cout<<vp[i].first<<" "<<time<<endl;
    }
    if(ch) fin("Yes");
    else fin("No");
    // for(i=1;i<=n;i++)cout<<v[i]<<" ";
    // cout<<endl;
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 3456
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    A.sort()
    n = A[-1]
    ans = -1
    for a in A:
        if a + 1 <= n / 2:
            ans = a
        else:
            b = n - a
            if b > ans:
                ans = a

    print(n, ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14428
package main

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

// AtCoder Functions
var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	S := nextString()

	if S == "Sunny" {
		fmt.Println("Cloudy")
	} else if S == "Cloudy" {
		fmt.Println("Rainy")
	} else if S == "Rainy" {
		fmt.Println("Sunny")
	}
}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for B - Tax Rate
	var N int
	fmt.Scanf("%d", &N)

	var flag int = 0
	for x := 1; x <= N; x++ {
		if int(math.Floor(float64(x)*1.08)) == N {
			fmt.Println(x)
			flag = 1
			break
		}
	}

	if flag == 0 {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 1840
#include<stdio.h>

int main(void){
  long int a,b,k,r,ab;

  while(scanf("%ld %ld",&a,&b)!=EOF){
    if(a<b){
      k=a;
      a=b;
      b=k;
    }
    ab=a*b;
    while((r=a%b)!=0){
      a=b;
      b=r;
    }
    printf("%ld %ld\n",b,ab/b);  
  }
  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000


int main(){
	
	int H,W;
	cin>>H>>W;
	
	vector<string> S(H);
	
	for(int i=0;i<W+2;i++){
		cout<<'#';
	}
	cout<<endl;
	
	for(int i=0;i<H;i++){
		cin>>S[i];
		cout<<'#';
		cout<<S[i];
		cout<<'#';
		cout<<endl;
	}
	
	for(int i=0;i<W+2;i++){
		cout<<'#';
	}
	cout<<endl;
	
	
	
	
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

//vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    int N;
    cin >> N;
    if(N >= 1200)
        cout << "ARC";
    else
    {
        cout << "ABC";
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
 
 
//#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
 
 
#define boost ios::sync_with_stdio(false); cin.tie(nullptr);
#define MOD 1000000007
#define sd(x) scanf("%d", &(x))
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ones(x) __builtin_popcount(x)
#define sz(x) int (x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define f1(i,a,b) for(int i=a; i<=b; i++)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define NFOR(i,a,b) for(int i=(a);i>=(b);--i)
 
 
using ll = unsigned long long ;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;  
typedef double ld;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
 
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
 
#ifdef np
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
 
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
 
void solve(){
	char d[3][3];
	for(int i=0 ; i<3 ;++i){
		for(int j = 0 ; j<3 ;++j) cin>>d[i][j];
	}
	for(int i=0 ; i<3 ;++i){
		for(int j = 0 ; j<3 ;++j) {
			if(i==j) cout<<d[i][j];
		}
	}
}
 
signed main(){
	int T =1 ; 
	//sd(T);
	while(T--){
		solve();
	}
 
#ifdef np
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}

Measured memory_bytes: 256
import fractions
n = int(input())
for i in range(n):
  a,b,c,d = map(int,input().split())
  if b > d or b > a:print("No")
  elif b <= c:print("Yes")
  else:
    num = fractions.gcd(b,d)
    if b-num+(a%num) > c:print("No")
    else:print("Yes")

Measured memory_bytes: 5304
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
using PII = pair<ll, ll>;
#define FOR(i,a,n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	double p;
	ll n;
	cin >> p >> n;
	vector<vector<PII>> g(n);
	REP(i, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		g[a].push_back({ b, c });
		g[b].push_back({ a, c });
	}

	double all = 0;
	function<void(ll, ll, double)> pre = [&](ll v, ll par, double prob) {
		for (auto to : g[v]) {
			if (to.first == par) continue;
			all += prob * to.second;
			pre(to.first, v, prob * p);
		}
	};
	pre(0, -1, p);

	double ans = 0;
	function<void(ll, ll, double)> dfs = [&](ll v, ll par, double prob) {
		ans += prob * all;
		for (auto to : g[v]) {
			if (to.first == par) continue;
			ans += prob * p * to.second;
			dfs(to.first, v, prob*p);
		}
	};
	dfs(0, -1, 1);
	
	cout << fixed << setprecision(9) << ans << endl;
}


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

int min(int a, int b)
{
    if (a > b){
        return (b);
    }
    return (a);
}

int main(void)
{
    int cost[3] = {380, 550, 850};
    int weight[3] = {200, 300, 500};
    int i, j;
    int ans[5001];
    
    memset(ans, -1, sizeof(ans));
    
    ans[0] = 0;
    
    for (i = 0; i < 3; i++){
        for (j = 0; j + weight[i] <= 5000; j += 100){
            if (ans[j] != -1){
                if (ans[j + weight[i]] != -1){
                    ans[j + weight[i]] = min(ans[j + weight[i]], ans[j] + cost[i]);
                }
                else {
                    ans[j + weight[i]] = ans[j] + cost[i];
                }
            }
        }
    }
    
    cost[0] = 380 * 5 * 80 / 100;
    cost[1] = 550 * 4 * 85 / 100;
    cost[2] = 850 * 3 * 88 / 100;
    
    for (i = 0; i < 3; i++){
        for (j = 0; j + weight[i] * (5 - i) <= 5000; j += 100){
            if (ans[j] != -1){
                if (ans[j + weight[i] * (5 - i)] != -1){
                    ans[j + weight[i] * (5 - i)] = min(ans[j + weight[i] * (5 - i)], ans[j] + cost[i]);
                }
                else {
                    ans[j + weight[i] * (5 - i)] = ans[j] + cost[i];
                }
            }
        }
    }
    
    while (1){
        scanf("%d", &i);
        
        if (i == 0){
            break;
        }
        
        printf("%d\n", ans[i]);
    }
    
    return (0);
}

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

using namespace std;
#define BUF (200005)
#define ll long long 

char s[BUF];
char lft[BUF];
char rgt[BUF];

enum {
	L=0,
	M,
	R
};

int v[257];
int t[257];
int l[BUF];
int p[BUF];
ll ans;




static int n;
ll bit[BUF];

/*
init my minary indexed tree
-----------------------
-----------
-----      ------     
--   ---   ---   ---
 a0 a1 a2 a3 a4 a5 a6 a7
*/
void bit_init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<=n;i++)bit[i]=0;
}

/*
add v to a[i]
update all related nodes
*/
void add(int i, ll v){
    while(i<=n){
        bit[i]+=v;
        i+=i&-i;
    }
}

/*
    require sum value a[0] ~ a[i];
*/
ll sum(int i){
    ll s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}


int main(void){
	cin >>s;
	n = strlen(s);

	//count 
	for(int i=0;i<n;i++) v[s[i]]++;

	//find odd
	int odd_cnt = 0;
	char odd = 0;
	int odd_index = 0;
	for(int i='a';i<='z';i++) {
		if(v[i]%2==1){
			odd_cnt++;
			odd = i; 
		}
	}
	//finish.
	if(odd_cnt>1)
	{ 
		cout << -1 << endl;
		return 0;
	}
	
	//label l,m,r
	for(int i=0;i<n;i++){
		t[s[i]]++;
		if(2*t[s[i]]<=v[s[i]]) l[i]=L;
		else l[i]=R;
		if(s[i]==odd && t[s[i]]==(v[odd]+1)/2){
			l[i] = M;
			if(l[i]==M) odd_index = i;
		}
	}


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

//find first R
	int f_M=0;
	for(int i=0;i<n;i++){
		if(l[i]==R){
			f_M=i;
			break;
		}
	}

//cout << f_M << odd_index;
	if(n%2==1 && odd_index < f_M){
		for(int i=odd_index;i<n;i++){
			if(l[i]==L) ans++;
		}
	}else if (n%2==1 && odd_index>f_M){
		for(int i=0;i<odd_index;i++){
			if(l[i]==R) ans++;
		}
	}	

//cout << ans;
	//count 
	int ini = f_M;
	for(int i=ini;i<n;i++){
		if(l[i]==L){
			ans+=i-f_M;
			f_M++;
		}
	}



	//make L,R string
	int li=0,ri=0;
	for(int i=0;i<n;i++){
		if(l[i]==L) {
			lft[li] =(s[i]);
			li++;
		}
		if(l[i]==R){
			rgt[ri]  =(s[i]);
			ri++;
		}
	}



	queue<int> A[257];

	for(int i=0;i<n/2;i++){
		char c = lft[i];
		A[c].push(i);
	}



	for(int i=n/2-1;i>=0;i--){
		char c = rgt[i];
		p[i] = n/2 - A[c].front();
		A[c].pop();
//		cout << p[i];
	}

	int N = n/2;

	bit_init(N+2);
//	cout << n;

	for(int i=0;i<N;i++){
		ans+=(ll)(i-sum(p[i]));
		add(p[i],1);
	}

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


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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (b - a == c - b) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256