akhauriyash/Code-Regression huggingface dataset:
while 1:
	x,y = list(map(int,input().split()))
	if x == 0:
		break

	pp = [1,-1,0,0]
	qq = [0,0,1,-1]
	m = []
	for i in range(y):
		m.append(list(input()))
		if '@' in m[-1]:
			ss = m[-1].index('@')
			tt = i
	cnt = 0

	def move (cx,cy):
		global cnt
		if cy >= y or cy < 0 or cx >= x or cx < 0:
			return
		if m[cy][cx] == '.' or  m[cy][cx] == '@':
			cnt += 1
			m[cy][cx] = '0'
			for i in range(4):
				move(cx + pp[i],cy + qq[i])
	move(ss,tt)
	print(cnt)



Measured memory_bytes: 5712
x1, y1, x2, y2 = map(int,input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int a[100010];
int b[100010];
int c[100010];
long long ans=0;
int pro_a=0,pro_c=0;
int main(){
    int n = 0;
    cin>>n;
    rep2(i,1,n+1)scanf("%d",&a[i]);
    rep2(i,1,n+1)scanf("%d",&b[i]);
    rep2(i,1,n+1)scanf("%d",&c[i]);
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    sort(c+1,c+n+1);


    pro_c = 1;
    rep2(i,1,n+1){
        while(pro_a<n&&a[pro_a+1]<b[i])pro_a++;
        while(pro_c<=n&&c[pro_c]<=b[i])pro_c++;
        ans += pro_a * (long long)(n-pro_c+1);
    }
    printf("%lld\n",ans);
    return 0;
}




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

#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld\n",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define mod (int)(1e9 + 7) 
using namespace std;


int main(){
	string s;
	cin >> s;
	if(s[s.size() - 1] == 's'){
		//s.pop_back();
		s += "es";
	}
	else{
		s += "s";
	}
	cout <<s;
}


Measured memory_bytes: 3628
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).
 
get_number(Number) :-
  get_string(String),
  number_string(Number, String).

main :-
  get_number(N),
  Ans is N * 2 * 3.141592,
  writeln(Ans).


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

using namespace std;

typedef long long ll;

const int N = 3e4 + 5;

ll dp[N][4];
string s;
int n;
int last[20];

int main() {
  memset(last, -1, sizeof last);
  cin >> n;
  cin >> s;
  s = "#" + s;
  ll ans = 0;
  dp[0][0] = 1;
  for(int i = 1; i <= n; i++) {
    dp[i][0] = 1LL;
    int idx = last[s[i] - '0'];
    for(int k = 1; k <= 3; k++) {
      dp[i][k] += dp[i - 1][k - 1] + dp[i - 1][k];
      if(idx != -1) dp[i][k] -= dp[idx - 1][k - 1];
    }
    last[s[i] - '0'] = i;
  }
  cout << dp[n][3] << '\n';
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  ll ans=0,now=0;
  rep(i,n){
      ll x;
      cin >> x;
      if(now>x){
          ans+=(now-x);
      }
      now=max(now,x);
  }
  cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int res = 0;
  for (int i = 2; i < N; i += 2) {
    string T = S.substr(0, N-i);
    string zen = T.substr(0, T.size()/2);
    if (T == zen + zen) {
      res = N-i;
      break;
    }
  }
  cout << res << endl;
}

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

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

	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		ans += S[i] - '0';
	}

	S[0] -= 1;
	int ans2 = S[0] - '0';
	for (int i = 1; i < S.size(); i++) {
		ans2 += 9;
	}

	cout << max(ans, ans2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
typedef long long LL;
using namespace std;
LL a , b , c , d , n;
int main()
{
	while(~scanf("%lld%lld%lld%lld%lld" , &n , &a , &b , &c , &d)){
		LL res = 0;
		bool ok = 0;
		for(LL i = 0;i <= n - 1;i++){
			if(b <= a + d * i - c * (n - 1 - i) && b >= a + c * i - d * (n - i - 1)) {
				ok = 1;
				break;
			}
		}
		if(ok) printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 128
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   double t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>s1;
    s2=s1;
    reverse(all(s2));
    l(i,0,s1.size())
    {
        if(s1[i]!=s2[i])
        {
            d++;
        }


    }
    cout<<d/2<<endl;


}


Measured memory_bytes: 3736
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    N, W = map(int, input().split())

    dp = [0] * (W + 1)
    for _ in range(N):
        v, w = map(int, input().split())
        for i in range(1, W + 1):
            if i - w >= 0:
                dp[i] = max(dp[i], dp[i - w] + v)
    print(dp[-1])


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 5924
//**************************
//*** writer  :  Alex Hu **
//************************

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi; 

const int maxn=1e5+10;

vi adj[maxn];
int mindis[maxn];
int color[maxn];
int v[maxn];
int d[maxn];
int c[maxn];

void dfs(int node,int dleft,int Cin)
{
	if (dleft<=mindis[node]) return;
	mindis[node]=dleft;
	if (color[node]==0) color[node]=Cin;
	rept(i,0,adj[node].size())
	{
		int to=adj[node][i];
		dfs(to,dleft-1,Cin);
	}	
}

int main()
{
	int n,m,q;
	scanf("%d%d",&n,&m);
	rept(i,0,n) mindis[i]=-1;
	rept(i,0,m)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	scanf("%d",&q);
	rept(i,0,q) scanf("%d%d%d",v+i,d+i,c+i);
	for (int i=q-1;i>=0;i--) dfs(v[i]-1,d[i],c[i]);
	rept(i,0,n) printf("%d\n",color[i]);
    return 0;
}

Measured memory_bytes: 8440
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define li long 
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define pb push_back
#define fori(i,k,n) for(int i = k;i<n; i++)
#define rfori(i,k,n) for(int i = k; i>=n; i--)
void optimize()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll power(ll x, ll y, ll p) 
{ 
   ll res = 1;       
  
    x = x % p;   
  
    while (y > 0) 
    { 
        
        if (y & 1) 
            res = (res*x) % p; 
  
        
        y = y>>1;  
        x = (x*x) % p;   
    } 
    return res; 
} 
void test_case()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	string ans;
	for(int i = 0; i<n; i++)
	{
	    ans+=s[i];
	    ans+=t[i];
	}
	cout<<ans;
}

int main()
{
	optimize();
	test_case();
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N;
	vector<int>num(1000001);
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	for (auto i : v) {
		for (int j = 2; j*j <= i; j++) {
			int cnt = 0;
			while (i%j == 0) {
				i /= j;
				cnt++;
			}
			num[j] = max(num[j], cnt);
		}
		if (i > 1)num[i] = max(num[i], 1);
	}
	long long int lcm = 1;
	for (int i = 2; i <= 1000000; i++) {
		lcm *= power(i, num[i], MOD);
		lcm %= MOD;
	}
	long long int ans = 0;
	for (auto i : v) {
		ans += lcm * power(i, MOD - 2, MOD);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();
        int x,y,a = 0;

        int xh = 0;
        int xe = W;
        int yh = 0;
        int ye = H;

        for(int i = 0; i<N; i++) {
            x = sc.nextInt();
            y = sc.nextInt();
            a = sc.nextInt();
            if(a == 1) {
                xh = Math.max(xh, x);
            }else if(a == 2) {
                xe = Math.min(xe, x);
            }else if(a == 3) {
                yh = Math.max(yh, y);
            }else {
                ye = Math.min(ye, y);
            }
        }
        //System.out.println(xh+" "+xe+" "+yh+" "+ye);
        if(xe-xh<0 || ye-yh<0) System.out.println(0);
        else System.out.println((xe-xh)*(ye-yh));
    }
}

Measured memory_bytes: 24020
#include<cstdio>

int main(){
	int n, m;
	int p;
	while (scanf("%d %d %d", &n, &m, &p) && n | m | p){
		int sum = 0;
		int hit = 0;
		for (int i = 0; i < n; ++i){
			int	x;
			scanf("%d", &x);
			if (i + 1 == m)hit = x;
			sum += x * 100;
		}
		if (hit == 0){
			printf("%d\n", 0);
		}
		else{
			printf("%d\n", (sum*(100-p) / 100) / hit);
		}
	}
	return 0;
}

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

ll gcd(ll a, ll b) {
  if (a > b) {
    ll tmp = b;
    b = a;
    a = tmp;
  }
  ll r = b % a;
  while (r != 0) {
    b = a;
    a = r;
    r = b % a;
  }
  return a;
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll l = lcm(c, d);
  ll count_b = b - b / c - b / d + b / l;
  ll count_a = (a - 1) - (a - 1) / c - (a - 1) / d + (a - 1) / l;
  cout << count_b - count_a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int n, i, a[1000]={}, sum=0, dap=0, x, t;
    scanf("%d", &n);
    for(i=1;i<=n;i++)
    {
        scanf("%d", &a[i]);
        sum+=a[i];
    }
    t=sum/n;
    if((sum-n*t)>(n/2))
        x=t+1;
    else
        x=t;

    for(i=1;i<=n;i++)
        dap+=(x-a[i])*(x-a[i]);
    printf("%d", dap);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h, w;
        while (true) {
            h = sc.nextInt();
            w = sc.nextInt();
            if (h == 0 && w == 0) {
                break;
            }
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (i % 2 == 1) {
                        if (j % 2 == 1) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    } else {
                        if (j % 2 == 1) {
                            System.out.print(".");
                        } else {
                            System.out.print("#");
                        }
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
        sc.close();
    }
}


Measured memory_bytes: 37724
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		long r = scan.nextLong();

		r = myModPow(r, 2, 0);
		r = 3 * r;

		System.out.println(r);

	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。ｓ
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myModPow(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  string a,b,c,d;cin>>a>>b>>c>>d;
  /*if(a<1200){
    cout << "ABC";
    return 0;
  }else{
    result = "ARC";
  }*/
  a.replace(5,1," ");
  a.replace(13,1," ");
  cout << a;
}


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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

int	main() {
	string S;
	cin >>S;
	int N=S.size()+1;
	vector<long> a(N, 0);
	for (int i=0; i<N-1; i++) {
		if ('<'==S.at(i))
			a.at(i+1)=a.at(i)+1;
	}
	for (int i=N-2; i>=0; i--) {
		if ('>'==S.at(i))
			a.at(i)=max(a.at(i), a.at(i+1)+1);
	}
	long SUM=0;
	for (int i=0; i<N; i++)
		SUM +=a.at(i);
	cout <<SUM <<endl;
	return 0;
}



Measured memory_bytes: 4740
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var a = o.l();
  return a[0]===a[1] && a[0] === a[2] ? "Yes" : "No";
}

Measured memory_bytes: 21064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define cerr                                                                   \
  if (true)                                                                    \
  cerr
#define dump(v) (cerr << #v << ": " << v << endl)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> p) {
  int l = 0, r = 0;
  ll ans = 0;
  int j = 0;

  for (int i = 0; i < N; i++) {
    if (i != p[i] - 1)
      continue;
    int buf = 1;
    for (j = i + 1; j < N; ++j) {
      if (j >= N)
        continue;
      if (j != p[i] - 1)
        break;
      buf++;
    }
    cerr << i << ":" << j << ":" << buf << endl;
    i = j;
    ans += buf / 2 + buf % 2;
  }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> p(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> p[i];
  }
  solve(N, p);
  return 0;
}


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

using namespace std;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

bool sub()
{
    const auto S(cin2var<string>());
    for (size_t i = 0; i < S.size(); ++i) {
        if (i % 2 == 0 && S[i] == 'L') return false;
        if (i % 2 == 1 && S[i] == 'R') return false;
    }
    return true;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    cout << (sub() ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

long long ncr(int n, int r) {
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
ll mod(ll a,ll b,ll m){
    if(b==0)return 1;
    if(b%2==0){
        ll y =  mod(a,b/2,m);
        return (y*y)%m;
    }
    else{
        return ((a%m)*mod(a,b-1,m))%m;
    }
}

ll modinv(ll a,ll m){
return mod(a,m-2,m);
//works only for prime m.
//else calculate phi(m)-1.
}



int main()
{
    int n;
    cin>>n;
    cout<<n*n*n<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string T; cin >> T;
    int size_T = T.length();
    for(int i = 0; i < size_T; i++){
        char tmp = T[i];
        if(tmp == '?'){
            T[i] = 'D';
        }
    }

    /*char tmp1 = T[0];
    char tmp2;
    int ans = 0;
    if(tmp1 == 'D') ans ++;

    for(int i = 1; i < size_T; i++){
        char tmp2 = T[i];
        //PDかどうか確認
        if(tmp1 == 'P' && tmp2 == 'D') ans ++;
        //Dかどうか確認
        if(tmp2 == 'D') ans ++;

        tmp1 = tmp2;
    }*/

    cout << T << endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
int cnt=0;
int ans=0;
vector<int> A[11];

void count(int N, int M, int Q, vector<int> a, vector<int> b, vector<int> c, vector<int> d, int x){
    if(x==N){
        cnt=0;
        rep(i, Q){
            if(A[x].at(b.at(i)-1)-A[x].at(a.at(i)-1)==c.at(i)){
                cnt+=d.at(i);
            }
            
        }
        A[x]={};
        ans=max(ans, cnt);
    }else if(x==0){
        for(int j=1;j<=M;j++){
            A[1]={j};
            count(N, M, Q,a, b, c, d, 1);
        }
    }
    else{
        for(int j=A[x].at(x-1);j<=M;j++){
            A[x+1]=A[x];
            A[x+1].push_back(j);
            count(N, M, Q,a, b, c, d, x+1);
        }
    }
}

//Start from Here
int main(){
    int N, M, Q;
    cin>>N>>M>>Q;
    vector<int> a, b, c, d;
    rep(i, Q){
        int x, y, z, w;
        cin>>x>>y>>z>>w;
        a.push_back(x);
        b.push_back(y);
        c.push_back(z);
        d.push_back(w);
    }
    count(N, M, Q,a, b, c, d, 0);
    cout<<ans<<endl;
}

Measured memory_bytes: 3660
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
var n = Number(input[0]);
var ans = 0;
var tmp = 0;
var tx = input[1].split("");
for(var i in tx){
    if(tx[i] == 'I'){
        tmp++;
    }else{
        tmp--;
    }
    ans = Math.max(ans,tmp);
}
console.log(ans);


Measured memory_bytes: 20980
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	s, w := readInt(), readInt()

	if s > w {
		fmt.Println("safe")
	} else {
		fmt.Println("unsafe")
	}
}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
 
#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)
 
 
int main()
{
	ll q;cin>>q;
 
	multiset<ll> l,r;
	ll sum = 0;
	REP(i,q)
	{
		ll a,b,c;
		cin>>a;
		if( a == 2 )
		{
			cout << (l.size()==0 ? 0 : (*l.rbegin()))
			 << " " << sum << endl;
		}
		else
		{
			cin>>b>>c;
			if( l.size() == 0 )
			{
				sum += c;
				l.insert(b); r.insert(b);
			}
			else
			{
				if( b < *l.rbegin() )
				{
					sum += abs( b - *l.rbegin() ) + c;
					r.insert(*l.rbegin()); l.erase(--(l.end())); 
					l.insert(b); l.insert(b);
				}
				else if( *r.begin() < b )
				{
					sum += abs( b - *r.begin() ) + c;
					l.insert(*r.begin()); r.erase(r.begin()); 
					r.insert(b); r.insert(b);
				}
				else
				{
					sum += c;
					l.insert(b); r.insert(b);
				}
			}
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 18944
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        
        if ((x+r)<=W && (x-r)>=0 && (y+r)<=H && (y-r)>=0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
    }
}


Measured memory_bytes: 26352
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    res = [[] for _ in range(2 ** 3)]

    if m == 0:
        print(0)
        exit()

    for _ in range(n):
        a = na()

        for i in range(2 ** 3):
            tmp = 0
            for j in range(3):
                if i >> j & 1:
                    tmp += -a[j]
                else:
                    tmp += a[j]
            res[i].append(tmp)

    ans = -INF
    for resi in res:
        if len(resi) == 0:
            continue
        resi.sort(reverse=True)
        ans = max(ans, sum(resi[:m]))
    print(ans)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << '\n';cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const int inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}
template <class T>
bool triangle(T a, T b, T c) {
	if (a + b <= c || a + c <= b || b + c <= a || a==b || b==c || c==a) return false;
	return true;
}


int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	ll a[n];
	int ret = 0;
	for (int i = 0; i<n; i++) cin >> a[i];
	for (int i = 0; i<n-2 && n >= 3; i++) {
		for (int j = i+1; j<n-1; j++) {
			for (int k = j+1; k<n; k++) {
				if (triangle(a[i], a[j], a[k])) ret++;
			}
		}
	}
	cout << ret << '\n';
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){ 
    cin.tie(nullptr); ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

int main() {
    int N;
    cin >> N;
    auto P = scan<vector<int>>(N);
    auto Q = scan<vector<int>>(N);
    vector<int> A(N);
    iota(A, 1);
    int i = 0, a, b;
    do {
        i++;
        if (equal(A, P)) {
            a = i;
        }
        if (equal(A, Q)) {
            b = i;
        }
    } while (next_permutation(A));
    cout << abs(a - b) << LN;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define INWORD 1
#define OUTWORD 0

int isAlphabet(char c)
{
	if((c>='a'&&c<='z')||(c>='A'&&c<='Z')||c=='\'')
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main()
{
	char sentence[1026];
	char word[7]={'\0'};
	int state=OUTWORD,i,len=0,first=1;

	fgets(sentence,1026,stdin);
	for(i=0;sentence[i]!='\n';i++)
	{
		if(isAlphabet(sentence[i]))
		{
			state=INWORD;
			if(len<6)
			{
				word[len]=sentence[i];
			}
			len++;
		}
		else
		{
			if(state==INWORD)
			{
				if(len>2&&len<7)
				{
					if(first)
					{
						first=0;
					}
					else
					{
						putchar(' ');
					}
					printf("%s",word);
				}
				len=0;
				memset(word,'\0',7);
			}
			state=OUTWORD;
		}
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<ll,ll> pi;

ll fastSum(ll n){
    return (n*(n+1ll))>>1;
}

int main(){
    int n;
    scanf(" %d",&n);
    int nums[n];
    unordered_map<int,ll> fr;
    for(int i = 0; i < n;++i){
        scanf(" %d",&nums[i]);
        ++fr[nums[i]];
    }
    ll ans = 0;
    for(auto va:fr)
        ans += fastSum(va.second-1ll);
    for(int i = 0; i < n;++i)
        printf("%lld\n",ans-fr[nums[i]]+1ll);
    return 0;
}


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

#define ll long long

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

    bool flag = 0;
    for (int i = 1; i <= 9 ; i++){
        if (n % i == 0 && n / i <= 9 && n / i >= 1){
            flag = 1;
        }
    }

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


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,ans=0;
    cin>>n;
    vector<int> v(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    for(int i=1;i<=n;i++){
        if(v[i]==i && i!=n){
            swap(v[i],v[i+1]);
            ans++;
        }else if(v[i]==i && i==n){
            swap(v[i],v[i-1]);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e6+5;
char s[maxm];
int n,k;
signed main(){
    cin>>n>>k;
    scanf("%s",s+1);
    int ans=0;
    vector<int>rl,lr;
    for(int i=2;i<=n;i++){
        if(s[i]==s[i-1]){
            ans++;
        }else{
            if(s[i]=='L'){
                rl.push_back(i);
            }else{
                lr.push_back(i);
            }
        }
    }
    int len1=rl.size();
    int len2=lr.size();
    int c=0,cc=0;
    vector<int>temp;
    while(c<len1&&cc<len2&&k){
        int x=rl[c],y=lr[cc];
        if(x<y){//R|LLL|R
            ans+=2;
            k--;
            c++,cc++;
        }else{//L|RRR|L
            ans+=2;
            k--;
            c++,cc++;
        }
    }
    while(c<len1)temp.push_back(rl[c++]);
    while(cc<len2)temp.push_back(lr[cc++]);
    ans+=min((int)temp.size(),k);
    cout<<ans<<endl;
    return 0;
}
/*
LLL这种全部一样的翻转之后权值不变,
只有R|LLL这种,翻转一遍之后会增加一个权值,
遇到R|LLL|R这种能增加两个权值.
其他情况下不增加了.
发现一次操作最多增加两个权值.
那么贪心一下就行了:
记录每个L|R和R|L的位置,然后贪心的翻转.
*/


Measured memory_bytes: 5076
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

#define rep(i, from, to) for(int i = from; i < to; i++)
#define inf 1000000000

int main(){
  string S; cin >> S;
  ll counter[26], res = 1; rep(i, 0, 26) counter[i] = 0;
  for(int i = S.size()-1; i >= 0; i--){
    res += S.size()-i-1-counter[S[i]-97]++;
  }
  cout << res << endl;
}


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

int main() {
	string s;
	getline( cin, s );

	for( int i = 0; i < s.size(); ++i ) {
		char ch = s.at( i );

		if( ch >= 'A' && ch <= 'Z' ) {
			s.at( i ) += 'a' - 'A';
		}
		else if( ch >= 'a' && ch <= 'z' ) {
			s.at( i ) -= 'a' - 'A';
		}
	}

	cout << s << endl;
}



Measured memory_bytes: 3196
from collections import deque


def BFS(G, counter, N):
    que = deque([0])
    ans = [-1 for i in range(N)]
    ans[0] = counter[0]

    while que:
        v = que.popleft()
        n = counter[v]
        for w in G[v]:
            if ans[w] > -1:
                continue
            counter[w] += n
            ans[w] = counter[w]

            que.append(w)

    return ans


N, Q = map(int, input().split())
G = [[] for i in range(N)]

for i in range(N - 1):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    G[b - 1].append(a - 1)

counter = [0 for i in range(N)]

for i in range(Q):
    p, x = map(int, input().split())
    counter[p - 1] += x

ans = BFS(G, counter, N)
print(*ans)

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

int main() {
    int n;
    cin >> n;
    cout << n << ":";
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            cout << " " << i;
            n /= i;
        }
    }
    if (n != 1) cout << " " << n;
    cout << endl;
}


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

struct Set{
    int a, b;
};

bool up_a(const Set &x, const Set &y){
  return x.a < y.a;
}

int main() {
  int n, m;
  cin >> n >> m;
  Set sets[m];
  rep(i, m) {
    int a, b; 
    cin >> a >> b;
    if (a > b) swap(a, b);
    sets[i].a = a;
    sets[i].b = b;
  }
  sort(sets, sets+m, up_a);
  
  int l, r;
  l = 0; r = n;
  int count = 1;
  rep(i, m) {
    l = sets[i].a;
    if (l < r) {
      r = (sets[i].b < r) ? sets[i].b : r;
    }
    else {
      r = sets[i].b;
      ++count;
    }
  } 
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>

int main(void){
    int n,k;
    double sum=0;
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++){
        double tmp=0;
        double lki= log2(k) - log2(i);
        while(true){
            if(tmp>=lki)break;
            tmp++;
        }
        sum += (1.0/(double)n)*pow((1.0/2.0),tmp);
    }
    printf("%.16f\n",sum);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class Pair
{
	public long Num { get; private set; }
	public string S { get; private set; }
	public long P { get; private set; }

	public Pair(long num, string s, long p)
	{
		Num = num;
		S = s;
		P = p;
	}
}

public class B
{
	public static void Main()
	{
		long N = GetLong();
		List<Pair> pairs = new List<Pair>((int)N);
		for(long i = 1; i <= N; i++)
			pairs.Add(new Pair(i, GetString(), GetLong()));
		pairs.Sort((x, y) => (x.S.CompareTo(y.S) != 0) ? x.S.CompareTo(y.S) :
			(int)(y.P - x.P));

		for(long i = 0; i < N; i++)
			Console.WriteLine(pairs[(int)i].Num);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

#define ll long long 
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

int main()
{
      int n,k;
      cin>>n>>k;
      int r,s,p;
      cin>>r>>s>>p;
      string t;
      cin>>t;
      int pr,ps,pp;
      pr=p;
      ps=r;
      pp=s;
      int arr[n];
      int res=0;
      for(int i=0;i<n;i++)
      {
          if((i<k)||(t[i]!=t[i-k]))
          {
              if(t[i]=='r')
               res+=pr,arr[i]=pr;
               else if(t[i]=='p')
                res+=pp,arr[i]=pp;
                else
                 res+=ps,arr[i]=ps;
          }
          else
          {
          if((arr[i-k]==0))
          {
              if(t[i]=='r')
              {
                arr[i]=pr;
                res+=pr;
              }
              else if(t[i]=='p')
              {
                  arr[i]=pp;
                  res+=pp;
              }
              else
              {
                  arr[i]=ps;
                  res+=ps;
              }
          }
          else
           arr[i]=0;
          }
      }
      cout<<res;
      return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
	vector<long long> f(1<<n, 1ll<<60), nf;
	f[0] = 0;
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		int msk = 0;
		for(int j = 0; j < b; j++){
			int x; cin >> x; x--;
			msk |= 1<<x;
		}
		nf = f;
		for(int j = 0; j < 1<<n; j++){
			nf[j | msk] = min(nf[j | msk], f[j] + a);
		}
		f = nf;
	}
	long long r = f[(1<<n) - 1];
	if(r >= (1ll<<60)) r = -1;
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 256
x, y, m = map(int,input().split())
mat = set()
r = [0]*x
c = [0]*y
smx = 0
smy = 0
for _ in range(m):
    p, q = map(int,input().split())
    p -= 1
    q -= 1
    mat.add((p,q))
    r[p] += 1
    c[q] += 1
    smx = max(smx,r[p])
    smy = max(smy,c[q])
xs = []
ys = []
for i in range(x):
    if smx == r[i]: xs.append(i)
for i in range(y):
    if smy == c[i]: ys.append(i)

ans = smx + smy - 1

for h in xs:
    for w in ys:
        if (h, w) in mat: continue
        print(ans + 1)
        exit()
print(ans)


Measured memory_bytes: 83452
import math
a, b, c = map(int, input().split())

S = a * b * math.sin(math.radians(c)) / 2
cl = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(c)))
L = a + b + cl
h = S*2/a

print('{:.4f}'.format(S))
print('{:.4f}'.format(L))
print('{:.4f}'.format(h))


Measured memory_bytes: 5708
#include <stdio.h>

void bomb(int x,int y,int map[8][8]){
  int i;

  map[y][x] = 0;

  for(i = ((x - 3 < 0) ? 0 : (x - 3)); i <= ((x + 3 > 7) ? 7 : (x + 3)); i++){
    if(map[y][i] == 1){
      bomb(i,y,map);
    }
    map[y][i] = 0;
  }

  for(i = ((y - 3 < 0) ? 0 : (y - 3)); i <= ((y + 3 > 7) ? 7 : (y + 3)); i++){
    if(map[i][x] == 1){
      bomb(x,i,map);
    }
    map[i][x] = 0;
  }

  return;
}

int main(int argc, char *argv[]){
  int n,i,j,k;
  int map[8][8];
  char buf[9];
  scanf("%d",&n);
  
  for(i = 0;i < n; i++){
    int x,y;
    for(j = 0; j < 8; j++){
      scanf("%s",buf);
      for(k = 0; k < 8; k++){
	map[j][k] = buf[k] - '0'; 
      }
    }
    
    scanf("%d",&x);
    scanf("%d",&y);
    
    bomb(x-1,y-1,map);
    
    printf("Data %d:\n",i+1);
    for(j = 0; j < 8; j++){
      for(k = 0; k < 8; k++){
	printf("%d",map[j][k]);
      }
      printf("\n");
    }
  }
  
  return 0;    
}

Measured memory_bytes: 0
n=int(input())
s=input()
li=[]
for i in range(n):
    li.append(s[i])
num=[]
m=0
for i in range(1,n):
    l1=set(li[:i])
    l2=set(li[i:])
    for j in l1:
        if j in l2:
            m+=1
        else:
            pass
    num.append(m)
    m=0

ans=max(num)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vector<int> X1(n);
	vector<int> X2(n);
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		X1[i] = x;
		X2[i] = x;
	}
	sort(all(X1));
	int md = X1[n/2];
	for (int i = 0; i < n; i++)
	{
		if (X2[i] < md)
			cout << md << endl;
		else
			cout << X1[n/2-1] << endl;
	}
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int inf=1e+9;
int main(void){
    int n,a,b,c;cin>>n>>a>>b>>c;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    int res=inf;
    for(int i=0;i<(1<<16);i++){
        int na=0,nb=0,nc=0,tmp=i;
        int now=0;
        rep(j,n){
            if(tmp%4==1){
                if(na!=0)now+=10;
                na+=l[j];
            }
            else if(tmp%4==2){
                if(nb!=0)now+=10;
                nb+=l[j];
            }
            else if(tmp%4==3){
                if(nc!=0)now+=10;
                nc+=l[j];
            }
            tmp/=4;
        }
        if(na==0||nb==0||nc==0)continue;
        int A=a-na;
        int B=b-nb;
        int C=c-nc;
        if(A<0)A*=-1;
        if(B<0)B*=-1;
        if(C<0)C*=-1;
        res=min(res,A+B+C+now);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;

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

	void solve() {
		int M1,D1,M2,D2;
		M1 = nextInt();
		D1 = nextInt();
		M2 = nextInt();
		D2 = nextInt();

		int res = 0;
		if(M2-M1 == 1 && D2 == 1) {
			res = 1;
		}
		out.println(res);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 21716
import collections

N = int(input())
D = list(map(int, input().split()))

cnt = collections.Counter(D)

if D[0] != 0:
    ans = 0
elif cnt[0] != 1:
    ans = 0
else:
    ans = 1
    for i in range(1, max(D)+1):
        if cnt[i] == 0:
            ans = 0
            break
        else:
            ans *= cnt[i-1] ** cnt[i]

print(ans%998244353)

Measured memory_bytes: 19928
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	int n = Integer.parseInt(br.readLine().trim());
      	int count=0;
      	boolean flag = false;
      	for(int i=1;i<=n;i++){
          String s[] = br.readLine().trim().split(" ");
          int a = Integer.parseInt(s[0]);
          int b = Integer.parseInt(s[1]);
          if(a == b){
				count++;
          }
          else{
            	count=0;
          }
          if(!flag && count == 3){
            	System.out.println("Yes");
          		flag = true;
          }
        }
      	if(!flag && count!=3)
      		System.out.println("No");
    }
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

void solve(){
    int N;
    cin >> N;

    vector<ll> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(all(L));

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            int Li = L[i];
            int Lj = L[j];
            vector<ll>::iterator lit = lower_bound(L.begin()+j+1, L.end(), Lj);
            vector<ll>::iterator rit = lower_bound(L.begin()+j+1, L.end(), Li + Lj);
            int d = distance(L.begin(), rit) - distance(L.begin(), lit);
            ans += max(0, d);
        }
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main ()
{
    int h,w;
    cin>> h>>w ;
    vector<string> pic(h);
    for (int i=0;i<h;i++)
    {
        cin>>pic.at(i);
    }
    
    for(int i=-1;i<h+1;i++)
    {
        if(i==-1||i==h)
        {
            for(int j=0;j<w+2;j++)
            {
                cout<<'#';
            }
            cout<<endl;
        }
        else
        {
            cout<<'#'<<pic.at(i)<<'#'<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdtr1c++.h>
// typedef __int128 int128;
// typedef __float128 float128;

using namespace std;
using namespace rel_ops;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ld> vd;
typedef vector<vd> vvd;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;
#define pb push_back


int main(){


  // freopen("A.in", "r", stdin);

  ll N;
  cin >> N;

  ll W;
  cin >> W;

  ll w[110], v[110];

  for (ll i = 1; i <= N; ++i) {
    cin >> w[i] >> v[i];
  }

  ll p[100010];

  ll nums[100010];
  p[w[1]] = v[1];

  nums[w[1]]++;

  for (ll k = 2; k <= N; k++) {
    ll numused[100010];
    p[w[k]] = max(p[w[k]], v[k]);
    nums[w[k]]++;
    numused[w[k]]++;
    for (ll x = W; x >= 1; x--) {
      if (p[x] && x + w[k] <= W && (x != w[k] || nums[w[k]] - numused[w[k]] >= 1)){
        numused[w[k]]++;
        p[x+w[k]] = max(p[x+w[k]],  v[k] + p[x]);
      }
    }

  }

  ll res = 0;
  for (ll i = 1; i <= W; ++i) {
    res = max(res, p[i]);
  }

  cout << res << endl;

}


Measured memory_bytes: 2432
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).ok();
    return word.trim().to_owned();
}

fn main() {
    let (a, b) = {
        let line = get_input();
        let mut split_line = line.split_whitespace();
        let a:u32 = split_line.next().unwrap().parse().unwrap();
        let b:u32 = split_line.next().unwrap().parse().unwrap();
        (a, b)
    };

    let ans =
    if a >= 13 {
        b
    } else if 6 <= a && a <= 12 {
        b / 2
    } else {
        0
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352