akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N,K,S; cin>>N>>K>>S;
  if(S==1000000000){
    rep(i,0,K)cout<<S<<" ";
  rep(i,0,N-K)cout<<1<<" ";
  cout<<endl;
    }
  else{
  rep(i,0,K)cout<<S<<" ";
  rep(i,0,N-K)cout<<S+1<<" ";
  cout<<endl;
  }
  }


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;


//0-indexed
class BreadthFirstSearch
{
public:
	long long int **Used,**BFSResult;
	char **HW;
	long long int MaxH,MaxW;
	stack<pair<long long int,long long int> >Root;
	
	BreadthFirstSearch(long long int H,long long int W){
		MaxH=H;
		MaxW=W;
		HW= new char*[H+1];
		Used= new long long int*[H+1];
		BFSResult= new long long int*[H+1];
		for(int i=0;i<H;i++)
		{
			HW[i]= new char[W+1];
			Used[i]= new long long int[W+1];
			BFSResult[i]= new long long int[W+1];
		}
	}
	
	void DoBFS(pair<long long int,long long int>Start){
		for(int i=0;i<MaxH;i++)
		{
			for(int j=0;j<MaxW;j++)
			{
				Used[i][j]=0;
				BFSResult[i][j]=1000;
			}
		}
BFSResult[Start.first][Start.second]=0;
		queue<pair<long long int,long long int> >task;
		task.push(Start);
		Used[Start.first][Start.second]=1;
		
		while(!task.empty())
		{
			long long int h=task.front().first;
			long long int w=task.front().second;
			for(int i=-1;i<=1;i++)
			{
				for(int j=-1;j<=1;j++)
				{
					if(h+i<0||w+j<0||h+i>=MaxH||w+j>=MaxW||abs(i-j)==2) 
					{
						continue;
					}
					if(Used[h+i][w+j]==0&&HW[h+i][w+j]=='.')
					{
						Used[h+i][w+j]=1;
						BFSResult[h+i][w+j]=BFSResult[h][w]+1;
						task.push({h+i,w+j});
					}
				}
			}
			task.pop();
		}
	}
	
};

int main(){
	long long int n,t;
	cin>>t>>n;
	while(n!=0||t!=0){
		BreadthFirstSearch bfs(150,150);
	
		for(int i=0;i<125;i++){
			for(int j=0;j<125;j++)
			{
				bfs.HW[i][j]='.';
			}
		}
		
		for(int i=0;i<n;i++){
			long long int x,y;
			cin>>x>>y;
			bfs.HW[x+60][60+y]='#';
		}
	        
		long long int p,q;
		cin>>p>>q;
		bfs.DoBFS({p+60,q+60});
		//cout<<4;
		long long int res=0;
		for(int i=-60;i<65;i++)
		{
			for(int j=-60;j<65;j++)
			{
				if(bfs.BFSResult[60+i][60+j]<=t){res++;}
			}
			
		}
               cout<<res<<endl;
		cin>>t>>n;

	}
}



Measured memory_bytes: 82032
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i=1, x;
    
    scanf("%d", &x);
    while (x != 0) {
        printf("Case %d: %d\n", i, x);
        i++;
        scanf("%d", &x);
    }
    
    return 0;
}


Measured memory_bytes: 2040
a, b = [int(x) for x in input().split()]

def f_xor(n):
    temp = (n // 2) % 2
    if n % 2 == 0:
        temp ^= n
    else:
        temp ^= 1
    return temp

if a == 0:
    print(f_xor(b))
else:
    print(f_xor(a - 1) ^ f_xor(b))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll i;
    ll A[N];
    ll sum[N+1];
    sum[0]=0;
    for(i=0;i<N;i++){
        cin >> A[i];
        sum[i+1]=sum[i]+A[i];
    }
    ll ans=100000000000;
    for(i=1;i<N;i++){
        ans=min(ans,abs(sum[N]-2*sum[i]));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int digit_sum(int n){
	int ret = 0;
	while(n > 0){
		ret += n%2;
		n >>= 1;
	}
	return ret;
}

ll n,m;
ll a[22];
ld p[22];
ll gcd(ll x,ll y){
	if(y == 0)return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	if(x == -1)return x;
	x /= gcd(x,y);
	if(log((ld)x)+log((ld)y) > log((ld)m)+1)return -1;
	return x*y;
}

int main(){
	cin >> n >> m;
	rep(i,n)cin >> a[i];
	rep(i,n)cin >> p[i];
	rep(i,n)p[i] /= 100.0;
	
	ld ret = 0.0;
	rep1(i,(1<<n)-1){
		ll LCM = 1;
		ld pp = 1.0;
		rep(j,n){
			if((i>>j)&1){
				LCM = lcm(LCM,a[j]);
				pp *= p[j];
			}
		}
		if(LCM != -1)ret += ((digit_sum(i)%2==1)?1.0:(-1.0))*(m/LCM)*pp;
	}
	
	printf("%.10llf\n", ret);
	
	//cout.precision(20);
	//cout << ret+m << endl;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ff first
#define ss second
#define sfi(a) scanf("%d",&a)
#define sfi2(a,b) scanf("%d %d",&a,&b)
#define sfi3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfll(a) scanf("%lld",&a)
#define all(a) a.begin(),a.end()
#define keepu(a) a.erase(unique(all(a)),a.end())
#define inf 1e7
#define m_p make_pair
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define mem(x,val) memset(x,val,sizeof(x))
#define read freopen("output.txt","r",stdin)
#define write freopen("input.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)
#define sqr(x) ((x)*(x))
#define pi acos(-1);

typedef long long ll;
const ll M = 1e9+7;
const int sz = 500010;


int main(){
    ll n,m;
    cin >> n >> m;
    ll x;
    ll sum = 0;
    for(int i=0;i<m;i++){
        cin >> x;
        sum += x;
    }

    n -= sum;
    if(n<0) puts("-1");
    else cout << n << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0; (i) < (n); (i)++)
int main(){
  int N;
  cin >> N;
  int64_t ans = 0;
  int now = 0;
  vector<int> vec(N);
  for (int i = 0; i < N-1; i++) {
    cin >> now;
    vec.at(now-1)++;
  }
  rep(i,N){
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
#define int long long

int H,a[500001];

void maxheapify(int i){
  int l = 2 * i;
  int r = 2 * i + 1;
  int k;
  if(l <= H && a[l] > a[i]) k = l;
  else k = i;
  if(r <= H && a[r] > a[k]) k = r;

  if(k != i){
    swap(a[i],a[k]);
    maxheapify(k);
  }
}

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

  cin >> H;
  for(int i = 1; i <= H; i++){
    cin >> a[i];
  }
  for(int i = H/2; i >= 1; i--){
    maxheapify(i);
  }
  for(int i = 1; i <= H; i++){
    cout << " " << a[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 7040
C=[list(map(int,input().split())) for i in range(3)]
B=[C[0][0],C[0][1],C[0][2]]
A=[0,C[1][0]-B[0],C[2][0]-B[0]]
for i in range(3):
  for j in range(3):
    if C[i][j] != A[i]+B[j]:
      print("No")
      quit()
print("Yes")

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

int main() {
  int N;
  cin>>N;
  vector<int> P(N);
  int min=N+1;
  int ans=0;
  
  for(int i=0; i<N; i++){
    cin>>P.at(i);
    if(P.at(i)<min){
      ans++;
      min=P.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3980
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;
string s;
ll dp[20001][2][101],d,n;
ll solve(int i,int tight,int md)
{
  if(i==n)
    return md==0;
  if(dp[i][tight][md]!=-1)
    return dp[i][tight][md];
  int e=9;
  if(tight)
    e=s[i]-'0';
  int j;
  ll ans=0;
  fr(j,0,e+1)
  {
    int atight=0;
    if(j==e and tight)
      atight=1;
    ans=(ans+solve(i+1,atight,(md+j)%d))%mod;
  }
  return dp[i][tight][md]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
  //cin>>t;
    while(t--){
      cin>>s>>d;
      n=s.size();
      ms(dp,-1);
      ll ans=solve(0,1,0);
      ans=(ans-1+mod)%mod;
      cout<<ans;
      
       
    }
  return 0;
  }



Measured memory_bytes: 32640
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
s = sum(a2) + a1[0]
ans = s
for i in range(1, n):
    s = s + a1[i] - a2[i - 1]
    ans = max(ans, s)
print(ans)


Measured memory_bytes: 3060
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end


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

    string s;
    in >> s;
    ll ans = 0;
    REP (i, s.size()) {
        if(i % 2 == 1) continue;
        if(i < 2) continue;
        bool even = true;
        REP (j, i / 2){
            if(s[j] != s[i/2 + j]) even = false;
        }
        if (even) ans = max(ans, i);
    }
    out << ans << endl;
}


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

int main() {
  int n,k;
  while(cin>>n>>k, n|k) {
    vector<int> v(n);
    for(int i=0; i<n; ++i)
      cin>>v[i];

    int maxsum = 0,nsum = 0;
    for(int i=0; i<k; ++i) {
      maxsum += v[i];
      nsum += v[i];
    }
    for(int i=k; i<n; i++) {
      maxsum = max(nsum-v[i-k]+v[i], maxsum);
      nsum = nsum-v[i-k]+v[i];
    }

    cout<<maxsum<<endl;
  }
}

Measured memory_bytes: 1308
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A, B = map(int, input().split())

    print(A+B) if A+B < 10 else print('error')

if __name__ == '__main__':
    main()

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

using namespace std;

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

	int n;
	string s[300];
	cin >> n;
	for( int i = 0; i < n; i++ )cin >> s[i];
	int ret = 0;
	for( int mx = 0; mx < n; mx++ )
	{
		bool ok = true;
		for( int x = 0; x < n; x++ )
			for( int y = 0; y < x; y++ )
			{
				if( s[( x + mx ) % n][y] != s[( y + mx ) % n][x] )ok = false;
			}
		if( ok )ret++;
	}
	cout << ret * n << endl;

	return 0;
}


Measured memory_bytes: 384
n=int(input())
a=[[]]
for i in range(n):
    a.append([int(i) for i in input().split()])
dp=[[0,0,0] for i in range(n+1)]
for i in range(1,n+1):
    for j in range(3):
            dp[i][j]=a[i][j]+max(dp[i-1][k] for k in range(3) if k!=j)
print(max(dp[n]))

Measured memory_bytes: 45696
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
   ll a[n+1],b[n];
   for(int i=0;i<n+1;i++)
    cin>>a[i];
   for(int i=0;i<n;i++)
    cin>>b[i];

    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(b[i]>a[i])
        {
            ans+=a[i];
            b[i]-=a[i];
            ll tm=min(a[i+1],b[i]);
            ans+=tm;
            a[i+1]-=tm;
        }
        else
        {
            ans+= b[i];
        }
    }
    cout<<ans;

}


Measured memory_bytes: 5212
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = System.Console.ReadLine().Trim().Split(' ');
            List<long> lstA = new List<long>();
            for (int i = 0; i < sS.Length; i++) { lstA.Add(long.Parse(sS[i]) - (i + 1)); }      // A - i の数列

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstA.Sort();
            long iB = lstA[(int)Math.Ceiling((double)(lstA.Count / 2))];                        // 数列の中央値
            long iOut = 0;
            for (int i = 0; i < lstA.Count; i++) { iOut += Math.Abs(lstA[i] - iB); }            // ABS(A - (B + 1)) の合計

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

int main(){

  int i;

  char s[100];
  scanf("%s",s);

  for(i=0;i<100;i++){
    if(s[i]!='\0')  s[i] = 'x';
  }

  printf("%s",s);

  return 0;
}


Measured memory_bytes: 128
L,R=map(int,input().split())
if R - L > 2019:
      print(0)
else:
    D = R - L
    L = L % 2019
    R = L + D
    a = 2018
    for i in range(D):
        for j in range(i+1,D+1):
            if (L+i)*(L+j)%2019 < a:
                a =(L+i)*(L+j)%2019
    print(a)


Measured memory_bytes: 41964
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

bool p;
int n;

ll dp[100][100];

int main() {
	int cnt = 0;
	cin >> n >> p;
	ll even = 1, odd = 0;
	rep(i, n) {
		ll num;
		cin >> num;
		if (num % 2) {
			ll pe = even, po = odd;
			even = po + pe;
			odd = po + pe;
		}
		else {
			even *= 2;
			odd *= 2;
		}
		//cout << even << " " << odd << endl;
	}
	if (p % 2)cout << odd << endl;
	else cout << even << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long n,m,i,j,k,sum=0,a=0,b=0,c=0,d=1;
   char ch[6002];
   scanf("%lld",&n);
   for(m=0;m<=n;m++)
   {
       scanf("%c",&ch[m]);
       if(ch[m]=='R')
        a++;
       if(ch[m]=='G')
        b++;
       if(ch[m]=='B')
        c++;
   }
   sum=a*b*c;
   for(i=1;i<=n-2;i++)
   {
       for(d=1;i+d+d<=n;d++)
       {
           if(ch[i]!=ch[i+d]&&ch[i]!=ch[i+d+d]&&ch[i+d]!=ch[i+d+d])
            sum--;
       }
   }
   printf("%lld",sum);
   return 0;
}


Measured memory_bytes: 1740
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define VEC(kata, num) (kata*)calloc(num, sizeof(kata))
#define DB puts("ok")
#define SENTINEL 1000000007
typedef long long lli;

// 降順
int cmp(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int main()
{
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d",MIN(c,b/a));

    return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
		}
		HashSet<Integer> set = new HashSet<>();
		int[] g = new int[N];
		int[] f = new int[N];
		for (int i = 0; i < N; ++i) {
			B[i] = sc.nextInt();
			set.add(B[i]);
		}
		if (N == set.size()) {
			System.out.println("Yes");
			return;
		}
		for (int i = 0; i < N; ++i) {
			g[i] = A[i];
			f[i] = A[i];
		}
		for (int i = 0; i < N; ++i) {
			if (!set.contains(A[i])) {
				g[i] = A[(i + 1) % N];
			}
		}
		System.out.println("No");
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < N; ++i) {
			pw.print(f[i] + (i == N - 1 ? "\n" : " "));
		}
		for (int i = 0; i < N; ++i) {
			pw.print(g[i] + (i == N - 1 ? "\n" : " "));
		}
		pw.close();
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

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

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

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

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

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

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

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

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

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}



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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll p[maxn], q[maxn], r[maxn];

void solve() {
    ll x, y, a, b, c, res = 0;
    cin >> x >> y >> a >> b >> c;
    priority_queue<ll, vector<ll>, greater<ll> > Q;
    for (int i = 1; i <= a; i++) cin >> p[i];
    for (int i = 1; i <= b; i++) cin >> q[i];
    for (int i = 1; i <= c; i++) cin >> r[i];
    sort(p + 1, p + 1 + a, greater<ll>());
    sort(q + 1, q + 1 + b, greater<ll>());
    sort(r + 1, r + 1 + c, greater<ll>());
    for (int i = 1; i <= x; i++) res += p[i], Q.push(p[i]);
    for (int i = 1; i <= y; i++) res += q[i], Q.push(q[i]);

    int tot = 1;
    while (!Q.empty()) {
        ll tmp = Q.top();
        Q.pop();
        if (r[tot] <= tmp || tot > c) break;
        res -= tmp;
        res += r[tot++];
    }

    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


Measured memory_bytes: 11380
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Stack;
import java.util.function.Supplier;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out)) {
            char[] s = in.next().toCharArray();
            int n = s.length;

            Stack<Integer> elements = new Stack<>();
            elements.push(0);
            Stack<Integer> elementsBefore = new Stack<>();

            Runnable VALID_UNDO = () -> {
                elements.push(elements.pop() - 1);
                elements.push(elementsBefore.pop());
            };
            Runnable INVALID_UNDO = () -> {
                elements.pop();
                elements.push(elementsBefore.pop());
            };
            Runnable OPEN = () -> {
                elements.pop();
            };

            Stack<Runnable> undo = new Stack<>();
            Stack<OldState> oldStates = new Stack<>();

            int depth = 0;
            long ans = 0;


            for (int i = 0; i < n; i++) {
                if (s[i] != '-') oldStates.push(new OldState(depth, ans));
                if (s[i] == '(') {
                    depth++;
                    elements.push(0);
                    undo.push(OPEN);
                } else if (s[i] == ')') {
                    depth--;
                    elementsBefore.push(elements.pop());
                    if (depth < 0) {
                        depth = 0;
                        elements.push(0);
                        undo.push(INVALID_UNDO);
                    } else {
                        elements.push(elements.pop() + 1);
                        undo.push(VALID_UNDO);
                    }

                    int delta =  elements.peek();
                    ans += delta;
                } else {
                    OldState state = oldStates.pop();
                    ans = state.ans;
                    depth = state.depth;
                    undo.pop().run();
                }
                out.println(ans);
            }
        }
    }

    private static class OldState {
        int depth;
        long ans;

        OldState(int depth, long ans) {
            this.depth = depth;
            this.ans = ans;
        }
    }
}



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

int main() {
    ll N;
    cin >> N;
    vector<ll> P(N), Q(N), v(N);
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> Q[i];
    rep(i, N) v[i] = i + 1;
    ll p, q;
    ll i = 0;
    do {
        if (P == v) {
            p = i;
        }
        if (Q == v) {
            q = i;
        }
        i++;
    } while (next_permutation(v.begin(), v.end()));
    cout << abs(p - q) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
using namespace std;
 
int main(void){
  double a,b,c,min,tmp;
  int r,n;
 
  while(1){
    scanf("%lf%lf%lf",&a,&b,&c);
    if(!a && !b && !c) break;
 
    scanf("%d",&n);
    while(n--){
      scanf("%d",&r);
      min = 999999;
      if((tmp=sqrt(a*a+b*b)/2)<min) min=tmp;
      if((tmp=sqrt(a*a+c*c)/2)<min) min=tmp;
      if((tmp=sqrt(b*b+c*c)/2)<min) min=tmp;
 
      if(min<r) printf("OK\n");
      else printf("NA\n");
    }
  }
 
  return 0;
}

Measured memory_bytes: 2580
#include<stdio.h>
int main(){
    int x,y,i=0;
    while(1){
    	scanf("%d %d",&x,&y);
    	if(x==0&&y==0) break;
    	if(x<y){
    	    printf("%d %d\n",x,y);
    	}else{
    	    printf("%d %d\n",y,x);
    	}
    }
    return 0;
}


Measured memory_bytes: 2052
A = int(input())
B = int(input())
C = int(input())
X = int(input())
max_500 = min([A,X//500])
res = 0
for i in range(max_500+1):
    X_temp = X - (500*i)
    for j in range(min([B,X_temp//100])+1):
        if (X_temp - (100*j))//50 <= C:
            res += 1


print(res)

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

class unionfind {
public:
	vector<ll> a;
	unionfind(ll n) { a = vector<ll>(n); rep(i, n) a[i] = i; }
	ll root(ll i) { return (a[i] == i) ? i : ( a[i] = root(a[i]) ); }
	bool same(ll x, ll y) { return root(x) == root(y); }
	bool unite(ll x, ll y) { x = root(x); y = root(y); if(x == y) return false; a[x] = y; return true; }
};

const ll MAX = 100000;

int main(int argc, const char* argv[]) {
	unionfind uf(MAX * 2);

	ll n;
	cin >> n;

	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		uf.unite(x - 1, y - 1 + MAX);
	}

	map<ll, ll> mx, my;
	rep(i, ll(MAX)) {
		mx[uf.root(i)]++;
		my[uf.root(i + MAX)]++;
	}

	ll ret = -n;
	rep(i, MAX * 2) {
		ret += mx[i] * my[i];
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
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};

//親の場合parには，-(集合のサイズ)を格納
vector<int> par(1e5+5,-1),dep(1e5+5,0);

//木の根を求める
int find(int x){
    if(par[x]<0){
        return x;
    }else{
        //return find(par[x])でも可能だが
        //根をつなぎなおして計算量を落としている
        return par[x]=find(par[x]);
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x)==find(y);
}

//xとyの属する集合を併合
void unite(int x, int y){
    //同じ集合なら意味なし
    x=find(x);
    y=find(y);
    if(x==y) return;
    //rankの大小でどちらにくっつけるかを判定
    if(dep[x]<dep[y]){
        par[y]+=par[x];
        par[x]=y;
    }else{
        par[x]+=par[y];
        par[y]=x;
        //同じdepのときは，yをxにくっつけ
        //xのdepをプラスする
        if(dep[x]==dep[y]) dep[x]++;
    }
}

//クラスカル法の準備
struct edge{
    int u,v,cost;
};

bool comp(const edge& e1, const edge& e2){
    return e1.cost<e2.cost;
}

int main(){
    int n;
    cin>>n;
    vector<pair<int,pair<int,int>>> pa_x(n),pa_y(n);
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        pa_x[i]={x,{y,i}};
        pa_y[i]={y,{x,i}};
    }

    sort(pa_x.begin(),pa_x.end());
    sort(pa_y.begin(),pa_y.end());
    
    vector<edge> e;
    for(int i=0;i<n-1;i++){
        edge tmp={pa_x[i].second.second,pa_x[i+1].second.second,pa_x[i+1].first-pa_x[i].first};
        e.push_back(tmp);
        tmp={pa_x[i+1].second.second,pa_x[i].second.second,pa_x[i+1].first-pa_x[i].first};
        e.push_back(tmp);
    }
    
    for(int i=0;i<n-1;i++){
        edge tmp={pa_y[i].second.second,pa_y[i+1].second.second,pa_y[i+1].first-pa_y[i].first};
        e.push_back(tmp);
        tmp={pa_y[i+1].second.second,pa_y[i].second.second,pa_y[i+1].first-pa_y[i].first};
        e.push_back(tmp);
    }
    
    //クラスカル法
    sort(e.begin(),e.end(),comp);
    int ans=0;
    for(int i=0;i<e.size();i++){
        edge tmp=e[i];
        if(!same(tmp.u,tmp.v)){
            unite(tmp.u,tmp.v);
            ans+=tmp.cost;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int n = Integer.parseInt(br.readLine());
			Map<String, Integer> map = new TreeMap<>();
			int max = 0;
			for (int i = 0; i < n; i++) {
				String s = br.readLine();
				int val = map.containsKey(s) ? map.get(s) + 1 : 1;
				map.put(s, val);
				max = Math.max(max, val);
			}
			PrintWriter out = new PrintWriter(System.out);
			for (String key : map.keySet()) {
				if (map.get(key) == max) {
					out.println(key);
				}
			}
			out.flush();
		}
	}
}

Measured memory_bytes: 57532
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
    ll N;
    input(N);

    ll res = -1;
    rep(i, 1, N + 1)
    {
        if ((ll)(i * 1.08) == N)
        {
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long k = sc.nextLong();
		long len = 0;
		char[] c = s.toCharArray();
		for(int i = 0; i < c.length; i++) {
			long temp = c[i]-'0';
			k -= (long) Math.pow(temp, 5*Math.pow(10, 15));
			if(k <=0) {
				System.out.println(temp);
				break;
			}
		}
	}
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
int w,h,mx,ice[90][90];
void dfs(int y,int x,int n){
	if(mx<n)mx=n;
	for(int d=0;d<4;d++){
		int ny=y+dy[d],nx=x+dx[d];
		if(0<=ny&&ny<h&&0<=nx&&nx<h){
			if(ice[ny][nx]){
				ice[ny][nx]=0;
				dfs(ny,nx,n+1);
				ice[ny][nx]=1;
			}
		}
	}
}
int main()
{
	for(;;){
	cin >> w >> h;
	if(!w&&!h)return 0;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin >> ice[i][j];
	mx=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(ice[i][j]){
			ice[i][j]=0;
			dfs(i,j,1);
			ice[i][j]=1;
			}
		}
	}
	cout << mx << "\n";
	}
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
 
vector<pair<int, ll> > path[100005];
int par[100005];
int dep[100005];
int siz[100005];
ll cst[100005];
int hev[100005];
void dfs(int a){
	siz[a]=1;
	for(int i=0; i<path[a].size(); i++){
		int d=path[a][i].first;
		if(d==par[a]) continue;
		par[d]=a;
		dep[d]=dep[a]+1;
		cst[d]=path[a][i].second;
		dfs(d);
		siz[a]+=siz[d];
		if(!hev[a] || siz[hev[a]]<siz[d])
			hev[a]=d;
	}
}
 
ll k;
ll add[100005];
ll edgecost(int a){
	ll ret=add[a]+add[par[a]]+cst[a];
	return ret%k ? ret : 0;
}
 
int pos[100005];
int hl_par[100005];
 
ll bit[100005];
ll sum(int i){
	ll ret=0;
	while(i){
		ret+=bit[i];
		i-=i&-i;
	}
	return ret;
}
void set(int i, ll x){
	x-=sum(i+1)-sum(i);
	i++;
	while(i<100005){
		bit[i]+=x;
		i+=i&-i;
	}
}
 
int lca(int a, int b){
	int p=hl_par[a], q=hl_par[b];
	if(p==q) return dep[a]<dep[b]?a:b;
	if(dep[p]<dep[q]) return lca(a, par[q]);
	else return lca(par[p], b);
}
ll cost(int a){
	int p=hl_par[a];
	ll ret=sum(pos[a])-sum(pos[p]);
	if(p) ret+=edgecost(p)+cost(par[p]);
	return ret;
}
 
int main(){
	int n;
	cin >> n >> k;
	for(int i=0; i<n-1; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		path[a].push_back(make_pair(b, c));
		path[b].push_back(make_pair(a, c));
	}
	for(int i=0; i<n; i++) hev[i]=0;
	par[0]=dep[0]=cst[0]=0;
	dfs(0);
 
	for(int i=0; i<n; i++) add[i]=0;
 
	int cnt=0;
	for(int i=0; i<n; i++) pos[i]=-1;
	for(int i=0; i<n; i++){
		if(i && hev[par[i]]==i) continue;
		int j=i;
		do{
			pos[j]=cnt++;
			hl_par[j]=i;
		}while(j=hev[j]);
	}

	for(int i=0; i<100005; i++) bit[i]=0;
	for(int i=0; i<n; i++)
		set(pos[i], edgecost(hev[i]));
	 
	int q;
	cin >> q;
	for(int i=0; i<q; i++){
		string s;
		ll a, b;
		cin >> s >> a >> b;
		if(s[0]=='a'){
			add[a]+=b;
			set(pos[a], edgecost(hev[a]));
			if(a) set(pos[a]-1, edgecost(a));
		}else{
			cout << cost(a)+cost(b)-2*cost(lca(a, b)) << endl;
		}
	}
}

Measured memory_bytes: 21072
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
constexpr string join(const V &v, const string &sep) {
  stringstream ss;
  if (v.size()) ss << v[0];
  loop(i, 1, v.size()) ss << sep << v[i];
  return ss.str();
}

void solve() {
  int x;
  vs a;
  while (cin >> x, x) {
    vi v(4);
    rep(i, 4) cin >> v[3 - i];
    vi t  = {500, 100, 50, 10};
    int s = 0;
    rep(i, 4) s += v[i] * t[i];
    s -= x;
    rep(i, 4) while (s >= t[i]) s -= t[i], v[i]--;
    reverse(all(t)), reverse(all(v));
    stringstream ss;
    rep(i, 4) if (v[i] > 0) ss << t[i] << ' ' << v[i] << endl;
    a.pb(ss.str());
  }
  cout << join(a, "\n");
}

Measured memory_bytes: 3324
import math
import collections
from sys import exit
from itertools import product

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n, k = mi()
h = [ii() for i in range(n)]
h.sort()
ans = 10**12
for i in range(n):
    last = i + k - 1
    if last >= n:
        break
    ans = min(ans, h[last]-h[i])
print(ans)

Measured memory_bytes: 13644
#include <algorithm>
#include <utility>
#include <cstdio>
int arr[200005], app[200005], lazy[800005]; 
std::pair<int, int> seg[800005];
inline void paint(int u, int x)
{
	seg[u].first += x; 
	lazy[u] += x; 
}
inline void push_down(int u)
{
	if (lazy[u])
	{
		paint(u << 1, lazy[u]);
		paint(u << 1 | 1, lazy[u]); 
		lazy[u] = 0; 
	}
}
void build(int u, int l, int r)
{
	if (l == r)
	{
		seg[u] = {app[l], l}; 
		return; 
	}
	int m = l + r >> 1; 
	build(u << 1, l, m); 
	build(u << 1 | 1, m + 1, r); 
	seg[u] = std::min(seg[u << 1], seg[u << 1 | 1]); 
}
void modify(int u, int l, int r, int L, int R)
{
	if (L > R)
		return; 
	if (L <= l && r <= R)
	{
		paint(u, 1);
		return; 
	}
	push_down(u); 
	int m = l + r >> 1; 
	if (L <= m)
		modify(u << 1, l, m, L, R); 
	if (m < R)
		modify(u << 1 | 1, m + 1, r, L, R); 
	seg[u] = std::min(seg[u << 1], seg[u << 1 | 1]); 
}
std::pair<int, int> query(int u, int l, int r, int L, int R)
{
	if (L <= l && r <= R)
		return seg[u];
	push_down(u); 
	int m = l + r >> 1;
	if (R <= m)
		return query(u << 1, l, m, L, R); 
	if (m < L)
		return query(u << 1 | 1, m + 1, r, L, R); 
	return std::min(query(u << 1, l, m, L, R), query(u << 1 | 1, m + 1, r, L, R)); 
}
int main()
{
	// freopen("CF17-EX-B.in", "r", stdin); 
	int n;
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		app[i] = arr[i]; 
	}
	std::sort(app, app + n); 
	build(1, 0, n - 1); 
	long long ans = 0; 
	for (int i = 0; i < n; i++)
	{
		int pos = std::lower_bound(app, app + n, arr[i]) - app; 
		auto res = query(1, 0, n - 1, pos, n - 1); 
		ans += res.first - arr[i]; 
		modify(1, 0, n - 1, 0, res.second - 1); 
	}
	printf("%lld\n", ans);
	return 0; 
}


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

int main (void){
  int n;
  vector<long> h;
  cin >> n;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    h.push_back(x);
  }
  
  int lmax = 0;
  for(int i = 0; i < n; i++){
    int l = 0;
    if(i == 0  || h[i-1] < h[i]){
      for(int j = i; j < n-1; j++){
        if(h[j] >= h[j+1]){
          l++;
        } else{
          break;
        }
        lmax = max(lmax, l);
      }
    }
  }
  cout << lmax;
  return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
  
int main(){
  string s; cin >> s;
  string ans = "";
  int N = s.size();
  rep(i,N) {
    int ansN = ans.size();
    if (s[i] == '0') ans = ans + '0';
    if (s[i] == '1') ans = ans + '1';
    if (s[i] == 'B' && ansN != 0) ans.erase(ansN-1);
  }
  
  cout << ans << endl;
}

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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,x[510],a[250010]={};
		
int main(){
	cin >> n;
	REP(i,0,n){
		cin >> x[i]; x[i]--;
		a[x[i]]=i+1;
	}
	
	REP(i,0,n*n){
		if(a[i]){
			int c=a[i]-1;
			REP(j,0,i){
				if(!c) break;
				if(!a[j]) a[j]=a[i],c--;
			}
			if(c){cout << "No" << endl; return 0;}
		}
	}
	
	set<int> st; st.insert(0);
	RREP(i,n*n-1,0){
		if(!st.count(a[i])){
			st.insert(a[i]);
			int c=n-a[i];
			RREP(j,n*n-1,i){
				if(!c) break;
				if(!a[j]) a[j]=a[i],c--;
			}
			if(c){cout << "No" << endl; return 0;}
		}
	}	
	
	cout << "Yes" << endl;
	REP(i,0,n*n) cout << a[i] << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*

 5/24/2020

 20:51-21:00, 8:37-9:43 give up

 https://twitter.com/hanseilimak/status/1264961807359152134

 */

const int MAX_N=300+1;
string S[MAX_N];
int N;

void solve() {
  int res=0;
  REP(k,N) {
    vector<string> X(N,string(N,'?'));
    REP(i,N) REP(j,N) {
      X[(i+k)%N][j]=S[i][j];
    }
    bool ok=true;
    REP(i,N)REP(j,N) ok&=X[i][j]==X[j][i];
    if(ok) ++res;
  }
  cout<<res*N<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  REP(i,N) cin>>S[i];
  solve();

  return 0;
}


Measured memory_bytes: 512
# https://atcoder.jp/contests/abc135/tasks/abc135_b

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

count = 0

for i, p_i in enumerate(p):
    if (i+1) != p_i:
        count += 1

if count == 2 or count == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
S = input()

n = len(S) - 1
ans = ''

for i in range(1 << n):
    tmp = S[0]
    for j in range(n):
        if (i >> j) % 2:
            # もしビットが1だったら＋ことにする
            tmp += '+'+S[j+1]
        else:
            tmp += S[j+1]
    ans += '+'+tmp


print(eval(ans[1:]))


Measured memory_bytes: 4136
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#include <functional>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MOD1 1000000007;
#define MOD2 1000007
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int dic[11000000];
ull pow(ull x,ull n) {
  ull res = 1;
  while(n > 0) {
    if(n&1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
int dic_op(char str[14],int& key)
{
  int j;
  int f = 1;
  int g = 0;
  for(j = 0;j<10;j++) {
    if(str[j] == 'A')
      g += f * 1;
    else if(str[j] == 'C')
      g += f * 2;
    else if(str[j] == 'G')
      g += f * 3;
    else if(str[j] == 'T')
      g += f * 4;
    else break;
    f *= 5;
  }
  key = 0;
  if(j == 10) {
    f = 1;
    for(;j<10;j++) {
      if(str[j] == 'A')
        key += f * 1;
      else if(str[j] == 'C')
        key += f * 2;
      else if(str[j] == 'G')
        key += f * 3;
      else if(str[j] == 'T')
        key += f * 4;
      else break;
        f *= 5;
    }
  }
  return g;
}
int main()
{
  int i,j,k,l;
  long n;
  long ans = 0;
  char opstr[7];
  char str[13];
  int key;
  int a = 1;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%s %s",opstr,str);
    if(opstr[0] == 'i') {
      int tmp = dic_op(str,key);
      if( (dic[tmp] >> key) % 2 == 0) {
        dic[tmp] += 1 << key;
      }
    }
    else if(opstr[0] == 'f') {
      int tmp = dic_op(str,key);
      /*
      printf("tmp = %d\n",tmp);
      printf("key = %d\n",key);
      printf("dic[tmp] = %d\n",dic[tmp]);
      */
      if( (dic[tmp] >> key) % 2 == 1) {
        puts("yes");
      }
      else {
        puts("no");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 39168
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14) << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;
struct UnionFind{
	vector<int> d;
	UnionFind(int n=0): d(n, -1){}
	int find(int x){
		if(d[x] < 0) return x;
		return d[x] = find(d[x]);
	}
	bool unite(int x, int y){
		x = find(x); y = find(y);
		if(x == y) return false;
		if(d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y){ 
		return find(x) == find(y);
	}
	int size(int x){
		return -d[find(x)];
	}
};

int main(void){

	int N, M; cin >> N >> M;
	UnionFind u(N);
	REP(i, M){
		int X, Y, Z; cin >> X >> Y >> Z;
		u.unite(--X, --Y);
	}

	set<int> st;
	REP(i,N){
		st.insert(u.find(i));
	}

	int ans = st.size();
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 5376