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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll D;

ll hoge(ll A,ll t,int first) {
	if(t==0) return A==0;
	int v=(A%10+10)%10;
	// add
	ll ret=0;
	if(first) {
		ret+=(9-v)*hoge((A-t*v)/10,t/100,0);
		ret+=(v-1)*hoge((A+(10-v)*t)/10,t/100,0);
	}
	else {
		ret+=(10-v)*hoge((A-t*v)/10,t/100,0);
		ret+=(v)*hoge((A+(10-v)*t)/10,t/100,0);
	}
	return ret;
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>D;
	if(D%9) return _P("0\n");
	D/=9;
	ll ret=0;
	ll p10=10;
	for(i=2;i<=18;i++) {
		p10*=10;
		
		ll tot=(i%2)?10:1;
		ret += tot*hoge(D,p10/10/9,1);
	}
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main(){
  
  string s, t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
    
  //s' < t'になるようなs'とt'が作れるか判定
  
  if(s < t){
    cout << "Yes" << endl;
  }
    else{
      cout << "No" << endl;
   }
}
  

Measured memory_bytes: 256
//PLUS ULTRA

#include<bits/stdc++.h>
using namespace std;
     
     
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back 
#define mp make_pair
#define forn(i,st,n) for(int i = st; i < n ; i++)
#define nfor(i,st,n) for(int i = st; i >= n ; i--)
#define ss second
#define ff first

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

const int N = 1e5 + 10 , mod =  1000000007;

void solve(){

	int n , m; cin >> n >> m;

	int sum  = 0, inp;

	forn(i,0,m){
		cin >> inp;
		sum+= inp;
	}    

	if(n - sum < 0)cout << -1 << endl;
	else cout << n - sum << endl;
    



}

int main(){
    SPEED;

    solve();

    return 0;
}
      
       


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v<=w)
        cout<<"NO"<<endl;
    else
        cout<<((abs(a-b)+v-w-1)/(v-w)<=t?"YES":"NO")<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 12);
const int mod = (int)924844033;

int n, k;

void read()
{
	cin >> n >> k;
}

int dp[MAXN][2][2];
int fact[MAXN];
int answer[MAXN], tmp[MAXN];

void solve()
{
	answer[0] = 1;
	fact[0] = 1; for(int i = 1; i <= n; i++) fact[i] = (fact[i - 1] * 1ll * i) % mod;

	for(int frst = 0; frst < 2 * k; frst++)
	{
		int cnt = 0;
		for(int i = frst; i < n; i += 2 * k) 
			cnt++;
	
		for(int i = 0; i <= cnt; i++)
			for(int row = 0; row < 2; row++)
				for(int fl = 0; fl < 2; fl++)
					dp[i][row][fl] = 0;

		dp[0][0][0] = 1;

		int p = 0, curr = 0, nxt = 1;
		for(int i = frst; i < n; i += 2 * k)
		{
			for(int j = 0; j <= cnt; j++)
				for(int fl = 0; fl < 2; fl++)
					dp[j][nxt][fl] = 0;
					
			for(int j = 0; j <= cnt; j++)
				for(int last = 0; last < 2; last++)
				{
					dp[j][nxt][0] = (dp[j][curr][last] + dp[j][nxt][0]) % mod;
					if(i + k < n) dp[j + 1][nxt][1] = (dp[j + 1][nxt][1] + dp[j][curr][last]) % mod;
					if(i - k >= 0 && last == 0) dp[j + 1][nxt][0] = (dp[j + 1][nxt][0] + dp[j][curr][last]) % mod;
				}

			p++;
			curr ^= 1;
			nxt ^= 1;
		}

		for(int i = 0; i <= n; i++) tmp[i] = 0;
		for(int i = 0; i <= n; i++)
			for(int j = 0; j <= cnt; j++)
				tmp[i + j] = (tmp[i + j] + (answer[i] * 1ll * (dp[j][curr][0] + dp[j][curr][1])) % mod) % mod;

		for(int i = 0; i <= n; i++) answer[i] = tmp[i];
	}
	
	int ans = 0;
	for(int i = 0; i <= n; i++)
	{
		int c = (answer[i] * 1ll * fact[n - i]) % mod;
		if(i & 1) ans = (ans + mod - c) % mod;
		else ans = (ans + c) % mod;
	}

	cout << ans << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 256
S=input()
Sf = S+" "

Flag = True
for i in range(len(S)*2):
  se = set(S)
  p = -1
  for i in range(26):
    if chr(ord('a')+i) not in se and ord('a')+i > ord(Sf[len(S)]):
      p= i
      break
    p = -1
  #print ( S + chr(ord('a')+p) ) 
  if (p == -1):
    if ( len(S)==0 ):
        Flag = False
        break
    S = S[:-1]
  else:
    break
    
if ( Flag ):
  print ( S + chr(ord('a')+p) ) 
else:
  print ( -1 )

Measured memory_bytes: 38384
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
	int h, w;
	scanf("%d %d", &h, &w);
	char foo[51][51];
	for (int i = 0; i < h; ++i) {
		scanf("%s", foo[i]);
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (foo[i][j] == '#') {
				putchar('#');
				continue;
			}
			int count = 0;
			if (i != 0) {
				count += foo[i - 1][j] == '#' ? 1 : 0;
				if (j != w - 1) {
					count += foo[i - 1][j + 1] == '#' ? 1 : 0;
				}
				if (j != 0) {
					count += foo[i - 1][j - 1] == '#' ? 1 : 0;
				}
			}
			if (j != 0) {
				count += foo[i][j - 1] == '#' ? 1 : 0;
				if (i != h - 1) {
					count += foo[i + 1][j - 1] == '#' ? 1 : 0;
				}
			}
			if (i != h - 1) {
				count += foo[i + 1][j] == '#' ? 1 : 0;
				if (j != w - 1) {
					count += foo[i + 1][j + 1] == '#' ? 1 : 0;
				}
			}
			if (j != w - 1) {
				count += foo[i][j + 1] == '#' ? 1 : 0;
			}
			putchar(count + '0');
		}
		putchar('\n');
	}
}


Measured memory_bytes: 128
A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())
if A - B >= 0:
  C = A - B
else:
  C = B - A
if V - W <= 0:
  print('NO')
elif C/(V - W) <= T:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define ub upper_bound
#define pp push_back
#define ep emplace_back
#define all(v) (v).begin(),(v).end()
#define szz(v) ((int)(v).size())
#define psm partial_sum
#define acm accumulate
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const lf PI = 3.14159265358979323846264338L;

ll a[10005];
int n;
const int E = 32000;
bool isc[E];
vector<int> p({2});

int main(){
    fio;
    cin >> n;
    int g = 0;
    for(int i = n; i >= 0; i--){
        cin >> a[i];
        g = __gcd(a[i], ll(g));
    }

    for(ll i = 3; i < E; i += 2){
        if(isc[i]) continue;
        p.pp(i);
        for(ll j = i * i; j < E; j += i + i) isc[j] = 1;
    }
    //cout << "gcd = " << g << '\n';
    int k = abs(g);
    vector<int> f;
    for(int u : p){
        if(u * u > k) break;
        if(k % u == 0){
            f.pp(u);
            while(k % u == 0) k = k / u;
        }
    }
    if(k > 1) f.pp(k);
    sort(all(f));

    for(int u : p){
        if(u > n+1) break;
        if(a[0] % u || binary_search(all(f), u)) continue;
        vector<int> b(u-1);
        for(int i = 0; i <= n; i++) b[i % (u-1)] = (b[i % (u-1)] + a[i]) % u;
        for(int i = 0; i < u-1; i++) if(b[i]) goto FAIL;
        f.pp(u);
        FAIL: continue;
    }
    sort(all(f));
    for(int u : f) cout << u << '\n';
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
static const int64_t INF=1000000000000000000;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int64_t dp[N][N];
  for(int i=0;i<N;i++)
    dp[i][i]=0;
  for(int l=1;l<=N-1;l++){
    int64_t sum=0;
    for(int a=0;a<=l;a++)
      sum+=A[a];
  for(int i=0;i<N-l;i++){
  int j=i+l;
      int64_t ans=INF;
    for(int k=i;k<j;k++)
      if(dp[i][k]+dp[k+1][j]<ans)
        ans=dp[i][k]+dp[k+1][j];
    dp[i][j]=sum+ans;
  
     sum+=(A[i+l+1]-A[i]);
  }
  
  
  }cout<<dp[0][N-1]<<endl;
    return 0;
}

Measured memory_bytes: 1536
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let a:Vec<i32> = read_vec();
    let s = a[0] * a[1];
    let syuu = a[0] * 2 + a[1] * 2; 
    println!("{} {}", s, syuu);
    // println!("{:?}", a);
}


Measured memory_bytes: 5028
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String X = sc.nextLine();
    char[] num = new char[4];
    boolean judge = true;

    for(int i = 0; i < 4; i++) {
    	num[i] = X.charAt(i);
    }

    for(int i = 0; i < 3; i++) {
    	if(num[i] == num[i+1]) {
    		judge = false;
    		break;
    	}
    }

    if(judge) {
    	System.out.println("Good");
    } else {
    	System.out.println("Bad");
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>

int main(int argc, char *argv[])
{
    int a, b, c;

    std::cin >> a >>  b >> c;

    if (a + b + c >= 22) {
        std::cout << "bust" << std::endl;
    } else {
        std::cout << "win" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, l[10], v1, v2, sum;
  double x;
  char c;

  while(scanf("%d %c", &l[0], &c) != EOF){
    for(i=1, sum=l[0]; i<10; i++){
      scanf("%d %c", &l[i], &c);
      sum += l[i];
    }
    scanf("%d %c %d", &v1, &c, &v2);

    x = sum * v1 / (double)(v1 + v2);

    for(i=0, sum=0; i<10; i++){
      sum += l[i];
      if(x <= sum){
	printf("%d\n", i+1);
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	lld a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	lld d = (a/b);
	if(a%b) d++;
	printf("%lld",d*c);
	return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000001;

int main(){
  long long n;
  vector<long long > t = vector<long long>(5);

  cin >> n;

  long long min = 1000000000000001;
  REP(i,5){
    cin >> t[i];
    if (t[i] < min) {
      min = t[i];
    }
  }

  long long ans = n / min + 4;
  if (n % min != 0) {
    ans++;
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
s = gets.chomp
if s == 'SUN'
    p 7
elsif s == 'MON'
    p 6
elsif s == 'TUE'
    p 5
elsif s == 'WED'
    p 4
elsif s =='THU'
    p 3
elsif s == 'FRI'
    p 2
elsif s == 'SAT'
    p 1
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define mod 1e9+7
typedef long long ll;

int main()
{
	int n;
	std::cin>>n;
	int a[n+5];
	for(int i=2;i<=n;i++)
		std::cin>>a[i];
	int sum[n]={0};
	for(int i=2;i<=n;i++)
	{
		sum[a[i]-1]++;
	}
	for(int i=0;i<n;i++)
		std::cout<<sum[i]<<'\n';
}

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

int main()
{
  int w,a,b; cin >> w >> a >> b;
  int ans,p;
  
  if( a <= b && b <= (w+a) ){
    ans = 0;
    p = 1;
  }
  if( a <= (b+w) && (b+w) <= (w+a) ){
    ans = 0;
    p = 2;
  }
  
  if( (a+w) < b ){
    ans = b-(a+w);
    p=3;
  }
  if( (b+w) < a ){
    ans = a-(b+w);
    p=4;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  int n=s.size();
  int d[n];
  mem(d);
  int c[2];
  mem(c);
  rep(i,n-1) {
    if(s[i]=='R') c[0]++;
    if(s[i+1]=='L') {
      d[i]+=c[0];
      d[i+1]+=c[1];
      mem(c);
    }
    swap(c[0],c[1]);
  }
  mem(c);
  rrep(i,n) {
    if(!i) break;
    if(s[i]=='L') c[0]++;
    if(s[i-1]=='R') {
      d[i]+=c[0];
      d[i-1]+=c[1];
      mem(c);
    }
    swap(c[0],c[1]);
  }
  PR(d,n);
}

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


Measured memory_bytes: 1104
#include <iostream>

int main() {
    int a, b, c, d;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> d;

    int train = std::min(a, b);
    int bus = std::min(c, d);

    std::cout << train+bus << std::endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <limits>
#include <cassert>

using lint = long long;
constexpr lint MIN = std::numeric_limits<lint>::min();

int main() {
    lint n, x, d;
    std::cin >> n >> x >> d;
    lint ad = std::abs(d);

    if (d == 0) {
        std::cout << (x == 0 ? 1 : n + 1) << std::endl;
        return 0;
    }

    std::map<lint, std::vector<std::pair<lint, lint>>> segss;
    for (lint k = 0; k <= n; ++k) {
        lint b = k * x + d * k * (k - 1) / 2;

        lint r = b % ad;
        if (r < 0) r += ad;

        lint q = (b - r) / d;
        auto& segs = segss[r];
        segs.emplace_back(q, q + k * (n - k));
    }

    lint ans = 0;
    for (auto& p : segss) {
        auto& segs = p.second;
        std::sort(segs.begin(), segs.end());

        lint unused = MIN;
        for (auto seg : segs) {
            if (seg.second < unused) {
                continue;
            }
            lint l = std::max(seg.first, unused);
            lint r = seg.second;

            ans += r - l + 1;
            unused = r + 1;
        }
    }

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


Measured memory_bytes: 22144
# bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# import math
# from itertools import *
# import random
# import calendar
import datetime
# import webbrowser

# f = open("input.txt", 'r')
# g = open("output.txt", 'w')
# n, m = map(int, f.readline().split())

n, k = map(int, input().split())
arr = []
for i in range(n):
    arr.append(input())
arr.sort()
print("".join(arr))


Measured memory_bytes: 9340
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{  int n,i,ans=0;
   cin >> n;int A[n+5],dp[n+5];
   for(i=0;i<n;i++)
   cin>>A[i];
   dp[0]=A[0];
   for(i=1;i<n;i++)
   dp[i]=min(dp[i-1],A[i]);

   for(i=0;i<n;i++)
   if(dp[i]>=A[i])ans++;

   cout << ans;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=1;i<=x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
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 main(){
    double r;
    cin >> r;

    cout << 2*M_PI*r << endl;

    return 0;
}

Measured memory_bytes: 3788
//
//  main.cpp
//  ProgrammingContestChallengeBook2
//
//  Created by Hisaki Kobayashi on 2020/04/04.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>
//#include "mylibrary.hpp"



using namespace std;

int ANS[3][3]={};

bool check(int A[3][3], int x){
    int i,j;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(x==A[i][j]){
                ANS[i][j] = 1;
                return true;
            }
        }
    }
    return false;
}
int main(){
    int N;
    int A[3][3];
    
    vector<int> b;
    
    int i,j;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            cin >> A[i][j];
        }
    }
    
    cin >> N;
    
    for(i=0;i<N;i++){
        int temp;
        cin >> temp;
        b.push_back(temp);
    }
    
    for(i=0;i<N;i++){
        check(A, b.at(i));
    }
    
//    ビンゴ稼働価格に
    int sum1=0;
    int sum2=0;
    int sum3=0;
    int sum4=0;
    
    for(i=0;i<3;i++){
        for(j=0; j<3;j++){
            sum1 += ANS[i][j];
            sum2 += ANS[j][i];
        }
        if(sum1==3 || sum2==3){
            cout << "Yes" << endl;
            return 0;
        }
        sum1 = 0;
        sum2 = 0;
    }
    
    for(i=0;i<3;i++){
        sum3 += ANS[i][i];
    }
   
    for(i=0;i<3;i++){
        sum4 += ANS[i][2-i];
    }
    
    if(sum3==3 || sum4==3)
        cout << "Yes" << endl;
    else{
        cout << "No" << endl;
    }
   
    
    
    
    return 0;
 
}


Measured memory_bytes: 256
# coding: utf-8
ns = [int(input()) for _ in range(6)]
ans = 0
min_n = min(ns[1:])
if ns[0] % min_n != 0:
    ans = 5 + ns[0] // min_n
else:
    ans = 5 + ns[0] // min_n - 1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vector<vpll> path;
void dijkstra(ll s) {
	priority_queue<pll> PQ;
	vl D(N*3000), color(N*3000);
	for (ll i = 0; i < N*3000; i++) {
		D[i] = INF;
		color[i] = 0;
	}
	D[s] = 0;
	PQ.push(make_pair(0, s));
	color[s] = 1;
	ll q = -1;
	while (!PQ.empty()) {
		pll f = PQ.top();
		PQ.pop();
		ll u = f.second;
		color[u] = 2;
		if (D[u] < f.first * q) {
			continue;
		}
		for (ll j = 0; j < path[u].size(); j++) {
			ll v = path[u][j].first;
			if (color[v] == 2) {
				continue;
			}
			if (D[v] > D[u] + path[u][j].second) {
				D[v] = D[u] + path[u][j].second;
				color[v] = 1;
				PQ.push(make_pair(D[v] * q, v));
			}
		}
	}
	for (k = 1; k < N; k++) {
		ll Ans = INF;
		for (i = k; i < N * 3000; i += N) {
			//debug(D[i]);
			Ans = min(Ans, D[i]);
		}
		cout << Ans << endl;
	}
}
int main() {
	ll S;
	cin >> N >> M >> S;
	S = min(S, (ll)2999);
	path.resize(N * 3000);
	//所持金iで頂点jにいる場合の頂点番号をi*N+jと定義(iは2999まで)
	for (k = 0; k < M; k++) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		for (i = a; i < 3000; i++) {
			path[u + i * N].push_back(make_pair(v + (i - a) * N, b));
			path[v + i * N].push_back(make_pair(u + (i - a) * N, b));
		}
	}
	for (k = 0; k < N; k++) {
		ll c, d;
		cin >> c >> d;
		for (i = 0; i <= 2999-c; i++) {
			path[k + i * N].push_back(make_pair(k + (i + c) * N, d));
			path[k + i * N].push_back(make_pair(k + (i + c) * N, d));
		}
	}
	dijkstra(S*N);
}

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

void solve() {
	int s, w; cin >> s >> w;
	cout << (s <= w ? "unsafe\n" : "safe\n");


	//cout << "Case #" << t + 1 << ": " << count << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	/*int t; cin >> t;
	for (int i = 0; i < t; i++) {
		solve(i);
	}*/

	solve();

    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define MAXN 1e6+5;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
  	long long a,b;
  	cin>>a>>b;

  	for(int i = 10*b; i <= (10*b+9); i++) {
  		if(floor(i*0.08) == a) {
  			cout<<i;
  			return 0;
  		}
  	}

  	cout<<-1;


	return 0;		
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int c=0;
  while(true){
    if(c%2==0)C-=B;
    else A-=D;
    if(A<=0||C<=0)break;
    c++;
  }
  if(A<=0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#define _CRT_SECURE_NO_WARNINGS
#endif
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x) {x = 0;register bool _=0;register T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void print(T n) {register bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);pc(10);}
template<typename First, typename ... Ints>
void scan(First &arg, Ints&... rest) { scan(arg);scan(rest...); }

using namespace std;
typedef long long ll;
const int MM = 1e5+2;

int N;
ll dp[MM], W;

int main(){
    
    memset(dp, 0x3f, sizeof dp);
    
    scan(N, W);
    dp[0] = 0;
    
    for(int i = 0,v; i < N; i++){
        ll w;
        scan(w, v);
        for(int j = MM-2; j >= v; j--){
            dp[j] = min(dp[j], dp[j-v] + w);
        }
    }
    
    int ans = 0;
    for(int i = 0; i < MM; i++){
        if(dp[i] <= W)
            ans = i;
    }
    print(ans);
    
    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val s = Array(3) { "" }

    for (i in 0..s.lastIndex) {
        s[i] = readLine()!!
    }

    var turn = 0

    while (s[turn] != "") {
        val pre = turn
        turn = s[turn][0] - 'a'

        s[pre] = s[pre].removeRange(0, 1)
    }

    println('A' + turn)
}

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

int main()
{
int i;
int j;
int k;
int R;
int G;
int B;
int N;
int iR;
int jG;
int kB;
long long iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> R;
	cin >> G;
	cin >> B;
	cin >> N;

	iSum = 0;
	for( i = 0; ; i++ )
	{
		iR = i * R;
		if( iR > N ) break;

		for( j = 0; ; j++ )
		{
			jG = j * G;
			if( iR + jG > N ) break;

			k = N - ( iR + jG );
			if( k % B == 0 ) iSum++;
		}
	}

	cout << iSum << endl;

	return 0;
}



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

int main(){
  int A,B;
    cin>>A>>B;
  if(A<0){
    if(B>=0){
      cout<<"Zero"<<endl;
    }
    if(A==B){
      cout<<"Negative"<<endl;
    }
    if(A!=B&&B<0){
      if((B-A)%2==0){
        cout<<"Negative"<<endl;
      }
      if((B-A)%2==1){
        cout<<"Positive"<<endl;
      }
    }
  }
if(A==0){
  cout<<"Zero"<<endl;
}
      if(A>0){
        cout<<"Positive"<<endl;
      }
    }

Measured memory_bytes: 256
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

void solve();

Int W, H;
vector<vector<bool> > M(51, vector<bool>(51, false));

void input() {
  while (true) {
    cin >> W >> H;
    if (W == 0 && H == 0) return;
    bool b;
    loop(h,0,H) {
      loop(w,0,W) {
        cin >> b;
        if (b) M.at(w).at(h) = true;
      }
    }
    solve();
  }
}

void dfs(Int h, Int w) {
  M.at(w).at(h) = false;
  for (int x=-1; x<=1; x++) {
    for (int y=-1; y<=1; y++) {
      if (x == 0 && y == 0) continue;
      Int x1 = w + x, y1 = h + y;
      if (x1 < 0 || W <= x1) continue;
      if (y1 < 0 || H <= y1) continue;
      if (!M.at(x1).at(y1)) continue;
      dfs(y1, x1);
    }
  }
}

void solve() {
  Int count = 0;
  loop(h,0,H) {
    loop(w,0,W) {
      bool b = M.at(w).at(h);
      if (b) {
        count++;
        dfs(h, w);
      }
    }
  }
  cout << count << endl;
}

int main() {
  input();
  return 0;
}



Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int r, c, n; cin >> r >> c >> n;
  V<> x1(n), y1(n), x2(n), y2(n); for (int i = 0; i < n; i++) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
  V<> t = x1; t.insert(t.end(), x2.begin(), x2.end()); t.push_back(0), t.push_back(r);
  sort(t.begin(), t.end()); t.erase(unique(t.begin(), t.end()), t.end());
  r = lower_bound(t.begin(), t.end(), r) - t.begin();
  for (auto&& x : x1) x = lower_bound(t.begin(), t.end(), x) - t.begin();
  for (auto&& x : x2) x = lower_bound(t.begin(), t.end(), x) - t.begin();
  t = y1; t.insert(t.end(), y2.begin(), y2.end()); t.push_back(0), t.push_back(c);
  sort(t.begin(), t.end()); t.erase(unique(t.begin(), t.end()), t.end());
  c = lower_bound(t.begin(), t.end(), c) - t.begin();
  for (auto&& y : y1) y = lower_bound(t.begin(), t.end(), y) - t.begin();
  for (auto&& y : y2) y = lower_bound(t.begin(), t.end(), y) - t.begin();
  V<> a(2 * (r + c), -1);
  for (int i = 0; i < n; i++) if ((x1[i] == 0 or x1[i] == r or y1[i] == 0 or y1[i] == c) and (x2[i] == 0 or x2[i] == r or y2[i] == 0 or y2[i] == c)) {
    if (y1[i] == 0 and x1[i] < r) a[x1[i]] = i;
    else if (x1[i] == r and y1[i] < c) a[r + y1[i]] = i;
    else if (y1[i] == c and x1[i] > 0) a[2 * r + c - x1[i]] = i;
    else a[2 * (r + c) - y1[i]] = i;
    if (y2[i] == 0 and x2[i] < r) a[x2[i]] = i;
    else if (x2[i] == r and y2[i] < c) a[r + y2[i]] = i;
    else if (y2[i] == c and x2[i] > 0) a[2 * r + c - x2[i]] = i;
    else a[2 * (r + c) - y2[i]] = i;
  }
  t = a, V<>().swap(a);
  for (int i : t) if (i != -1) a.push_back(i);
  int m = a.size();
  if (m <= 2) return cout << "YES" << '\n', 0;
  int s;
  bool be = false;
  for (int i = 0; i < m - 1; i++) if (a[i] == a[i + 1]) {
    s = i + 1;
    be = true;
    break;
  }
  if (!be) return cout << "NO" << '\n', 0;
  stack<int> st;
  for (int i = 0; i < m; i++) {
    if (st.empty() or st.top() != a[(s + i) % m]) st.push(a[(s + i) % m]);
    else st.pop();
  }
  cout << (st.empty() ? "YES" : "NO") << '\n';
}

Measured memory_bytes: 8808
#Dubious Document 2
S1 = input()
T = input()
n = len(S1)-len(T)
S = ""
p = 0
for i in range(n+1):
    k = 1
    for j in range(len(T)):
        if T[j] == S1[i+j] or S1[i+j] == "?":
            pass
        else:
            k = k - 1
    if k == 1:
        S = S1[0:i] + T + S1[i+len(T):len(S1)]
        p = 1
for i in range(len(S)):
    if S[i] == "?":
        S = S[0:i] + "a" + S[i+1:len(S)]
if p == 0:
    print("UNRESTORABLE")
else:
    print(S)

Measured memory_bytes: 3064
#include <iostream>

int main(){
    using namespace std;
    int H, W;
    cin >> H >> W ;
    while(!(H==0)&&!(W==0)){
        for(int i{0}; i<H; i++){
            for(int j{0}; j<W; j++){
                if((i==0)|(i==H-1)|(j==0)|(j==W-1)){cout << "#";}
                else {cout << "." ;}
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W ;
    }
    return 0;
}


Measured memory_bytes: 3020
import bisect
import sys
input=sys.stdin.readline

dic={'U':'R','R':'D','D':'L','L':'U'}
def turn(arr):
  for i in range(len(arr)):
    arr[i][0],arr[i][1],arr[i][2]=[arr[i][1],200000-arr[i][0],dic[arr[i][2]]]
  return arr

n=int(input())
arr=[list(input().split()) for _ in range(n)]
for i in range(n):
  arr[i][0]=int(arr[i][0])
  arr[i][1]=int(arr[i][1])
ds=[[] for _ in range(200001)]
ls=[[] for _ in range(200001)]
arr=sorted(arr,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
for x,y,d in arr:
  if d=='D':
    ds[x].append(y)
  elif d=='L':
    ls[y].append(x)
ans=10**18
for x,y,d in arr:
  if d=='U':
    pos=bisect.bisect_left(ds[x],y)
    if pos==len(ds[x]):
      continue
    else:
      ans=min(ans,abs(ds[x][pos]-y)*5)
  elif d=='R':
    pos=bisect.bisect_left(ls[y],x)
    if pos==len(ls[y]):
      continue
    else:
      ans=min(ans,abs(ls[y][pos]-x)*5)
for _ in range(4):
  rs=[[] for _ in range(400001)]
  for x,y,d in arr:
    if d=='R':
      rs[x+y].append(y)
  for x,y,d in arr:
    if d=='U':
      pos=bisect.bisect_left(rs[x+y],y)
      if pos==len(rs[x+y]):
        continue
      else:
        ans=min(ans,abs(rs[x+y][pos]-y)*10)
  arr=turn(arr)
  arr=sorted(arr,key=lambda x:x[1])
if ans==10**18:
  print('SAFE')
else:
  print(ans)

Measured memory_bytes: 264928
#include <bits/stdc++.h>
#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,r,l) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define INF (1LL<<62)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
const double PI = atan(1)*4;
const double EPS = 1e-9;

// Maximo numero de objetos
const int MAXN = 105;
// Maximo tama~no de la mochila
const int MAXW = 1e5+5;
// w[i] = peso del objeto i (i comienza en 1)
ll w[MAXN];
// v[i] = valor del objeto i (i comienza en 1)
ll v[MAXN];
// dp[i][j] maxima ganancia si se toman un subconjunto de los
// objetos 1 .. i y se tiene una capacidad de j
ll dp[MAXN][MAXW];

ll knapsack(int n, int W){
    for (int j = 0; j <= W; ++j) dp[0][j] = 0;
    for (int i = 1; i <= n; ++i){
        for (int j = 0; j <= W; ++j){
            dp[i][j] = dp[i-1][j];
            if (j - w[i] >= 0){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }
    return dp[n][W];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<< setprecision(2)<< fixed;
    int n, W;
    cin>>n>>W;
    for1(i,n){
        cin>>w[i]>>v[i];
    }
    cout<<knapsack(n,W);
}


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


int main() {
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(rng(a));
  cout << a[0] + a[1] << endl;
  return 0;
}

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

signed main(){
  
  string N;
  cin>>N;
  
  for(int i=0;i<3;i++){
    if( N[i] == '7' ){
      cout<<"Yes"<<endl;
      return 0;
    }
  }

  cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e18
    
const int N=1e6+5;
const int M=1e9+7;
void solve()
{
	int n,k;
	cin>>n>>k;
	int a[n+2];
	f(i,1,n) cin>>a[i];
	int pre[n+2]={0};
	int f=0;
	while(k--)
	{
		memset(pre,0,sizeof(pre));
		for(int i=1;i<=n;i++)
		{
			int l=max(1LL,i-a[i]);
			int r=min(n,i+a[i]);
			pre[l]++;
			pre[r+1]--;
		}
		for(int i=1;i<=n;i++)
		pre[i]+=pre[i-1];
		memcpy(a,pre,sizeof(pre));
		for(int i=1;i<=n;i++)
		{
			if(pre[i]!=n)
			break;
			if(i==n)
			f=1;
		}
		if(f)
		break;
		
	}
	// cout<<k<<endl;
	f(i,1,n)
	cout<<pre[i]<<" ";
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


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

int main() {
    string s;
    cin >> s;
    int size = s.size();
    s = " " + s;
    int ans = (1 << 30);
    for (int i = 1; i <= size; i++) {
        if(s[i] != s[i+1]) {
            int Max = max(i, size - i);
            ans = min(ans, Max);
        }
    }
    if(ans == (1 << 30)) ans = 0;
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>




int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2572
# 区間[i,j]における最小値を返す
# 値の更新をする
import sys,fractions
input = sys.stdin.readline
class segment_tree:
    '''
    init_val(int): 初期化値
    Input(array):  入力
    '''
    def __init__(self, init_val, Input):
        #self.num:n以上の最小の2のべき乗(一番下のNodeの数)
        n=len(Input)
        self.init_val = init_val
        self.num = 2 ** (n - 1).bit_length()
        self.seg = [init_val] * 2 * self.num
        for i in range(n):
            self.seg[i + self.num - 1] = Input[i]
        for i in range(self.num - 2, -1, -1):
            self.seg[i]=self._segfunc(self.seg[2*i+1],self.seg[2*i+2])
    def _segfunc(self, left, right):
        '''
        ここに求めたい関数を入れる
        ex)最小値問題→min, 
        left:左の子
        right:右の子
        '''
        res=fractions.gcd(left,right)
        return res
    def update(self, k, x):
        '''
        k番目の値をxに書き換える
        '''
        k += self.num - 1
        self.seg[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.seg[k] = self._segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])
    def query(self, p, q):
        '''
        区間[p,q)の目的の値を取り出す
        '''
        if q <= p:
            return self.init_val
        p += self.num - 1
        q += self.num - 2
        res = self.init_val
        while q - p > 1:
            if p % 2 == 0: #始点が偶数or終点が奇数だと端っこが余る
                res = self._segfunc(res, self.seg[p])
            if q % 2 == 1:
                res = self._segfunc(res, self.seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        res = self._segfunc(res, self.seg[p])
        res = self._segfunc(res, self.seg[q])
        return res
INF = 10 ** 10
n=int(input())
a=list(map(int,input().split()))

# a = [randint(0,N*2) for _ in range(N)]
dp = segment_tree(0, a)
ans=-1
for i in range(n):
  ans=max(ans,fractions.gcd(dp.query(0,i),dp.query(i+1,n)))
print(ans)

Measured memory_bytes: 87264
#include<bits/stdc++.h>
using namespace std;
#define    For(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    nl     "\n"
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

int main()
{
   int a,b,c,p=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++)
    {
        if(i%c==0)p++;
    }
    cout<<p;

}


Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
	int keta,n,i;
	int kai[100000];
	while(0==0){
		scanf("%d",&n); 
		keta=0;
		if(n==-1)break;
		while(n>3){
			kai[keta]=n%4;
			n=n/4;
			keta++;
		}
	  kai[keta]=n;
	  for(i=keta;i>0;i--) printf("%d",kai[i]);
	  printf("%d\n",kai[0]);
	}
	return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  long long X,K,D;
  cin>>X>>K>>D;
  if(abs(X)/D>=K) cout<<abs(X)-K*D<<endl;
  else{
    K-=abs(X)/D;
    if(K%2==0) cout<<abs(X)-(abs(X)/D)*D<<endl;
    else cout<<(abs(X)/D)*D+D-abs(X)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3192
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int userCount = sc.nextInt();

        List<Integer> totals = new ArrayList<>();
        for (int i = 0; i < userCount; i++) {
            totals.add(sc.nextInt());
        }

        int overBuyer = 0;
        int[] count = new int[8];
        for (int j = 0; j < totals.size(); j++) {
            int total = totals.get(j);
            if (total <= 399) {
                count[0]++;
            } else if (total <= 799) {
                count[1]++;
            } else if (total <= 1199) {
                count[2]++;
            } else if (total <= 1599) {
                count[3]++;
            } else if (total <= 1999) {
                count[4]++;
            } else if (total <= 2399) {
                count[5]++;
            } else if (total <= 2799) {
                count[6]++;
            } else if (total <= 3199) {
                count[7]++;
            } else if (3200 <= total) {
                overBuyer++;
            }
        }

        int min = 0;
        int max = 0;
        int exist = 0;
        for (int c = 0; c < count.length; c++) {
            if (count[c] != 0) {
                exist++;
            }
        }
        max = exist + overBuyer;
        if (exist != 0) {
            min = exist;
        } else {
            min = 1;
        }

        System.out.println(min + " " + max);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.size();i++)
        if(s[i]=='R')
            cnt++;
    if(cnt>(s.size()/2))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) {
	if os.Getenv("ONLINE_JUDGE") == "false" {
		fmt.Fprintln(os.Stderr, a...)
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, q := scanInt(), scanInt()
	uf := newUnionFind(n)

	for i := 0; i < q; i++ {
		t, u, v := scanInt(), scanInt(), scanInt()
		if t == 0 {
			uf.unite(u, v)
		} else {
			if uf.find(u) == uf.find(v) {
				fmt.Fprintln(wr, 1)
			} else {
				fmt.Fprintln(wr, 0)
			}
		}
	}
}

type unionFind []int

func newUnionFind(n int) *unionFind {
	uf := make(unionFind, n)
	for i := 0; i < n; i++ {
		uf[i] = -1
	}
	return &uf
}

func (uf unionFind) find(x int) int {
	if uf[x] < 0 {
		return x
	}
	uf[x] = uf.find(uf[x])
	return uf[x]
}

func (uf unionFind) unite(x, y int) {
	x, y = uf.find(x), uf.find(y)
	if x != y {
		if uf[x] > uf[y] {
			x, y = y, x
		}
		uf[x] += uf[y]
		uf[y] = x
	}
}

func (uf unionFind) size(x int) int {
	return -uf[uf.find(x)]
}


Measured memory_bytes: 4892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define int ll
#define INF 999999999

signed main(){
    int edge[110][110];
    int v,e,s,g1,g2;
    while(cin>>v>>e>>s>>g1>>g2&&v&&e&&s&&g1&&g2){
        rep(i,110)rep(j,110)edge[i][j]=INF;
        rep(i,110)edge[i][i]=0;
        s--,g1--,g2--;
        rep(i,e){
            int a,b,c;
            cin>>a>>b>>c;
            a--,b--;
            edge[a][b]=c;
        }
        
        
        rep(k,v){
            rep(i,v){
                rep(j,v){
                    edge[i][j] = min(edge[i][j],edge[i][k]+edge[k][j]);
                }
            }
        }
        int mini=INF;
        rep(i,v){
            mini = min(edge[s][i]+edge[i][g1]+edge[i][g2],mini);
        }
        cout<<mini<<endl;
    }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
  int a = 0;
  int b = 0;
  
  cin >> a;
  cin >> b;
  if ((( 0 <= a ) && ( a <= 100 )) &&
      (( 0 <= b ) && ( b <= 100 )))
  {
    cout << ceil(((float)a+b) / 2.0) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 100000000000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N;
    int A[300][300];
    cin >> N;
    REP(i,N){
        REP(j,N){
            cin >> A[i][j];
        }
    }
    
    REP(k,N){
        REP(i,N){
            REP(j,N){
                if(A[i][k]+A[k][j]<A[i][j]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    
    
    bool D[300][300]={};
    int Ans=0;
    
    REP(k,N){
        REP(i,N){
            REP(j,N){
                if(A[i][k]+A[k][j]==A[i][j] && A[i][k]>0 && A[k][j]>0){
                    D[i][j]=1;
                }
            }
        }
    }
    REP(j,N){
        REP(i,j){
            if(D[i][j]==0){
                Ans+=A[i][j];
            }
        }
    }
    
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <limits>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    vector<uint> upper(N, numeric_limits<uint>::max());
    vector<uint> lower(N, numeric_limits<uint>::max());
    for (auto &&i: irange((unsigned int) 0, N)){
        cin >> upper.at(i);
    }
    for (auto &&i: irange((unsigned int) 0, N)){
        cin >> lower.at(i);
    }
    vector<uint> upper_left_sum(N, numeric_limits<uint>::min());
    for (auto &&i: irange((unsigned int) 0, N)){
        if (i == 0){
            upper_left_sum.at(i) = upper.at(i);
        } else {
            upper_left_sum.at(i) = upper_left_sum.at(i - 1) + upper.at(i);
        }
    }

    vector<uint> lower_right_sum(N, numeric_limits<uint>::min());
    for (auto &&i: irange((unsigned int) 0, N) | reversed){
        if (i == N-1){
            lower_right_sum.at(i) = lower.at(i);
        } else {
            lower_right_sum.at(i) = lower_right_sum.at(i+1) + lower.at(i);
        }
    }

    vector<uint> sum(N, numeric_limits<uint>::min());
    for (auto &&i: irange((unsigned int) 0, N)){
        sum.at(i) = upper_left_sum.at(i) + lower_right_sum.at(i);
    }

    uint maximum{numeric_limits<uint>::min()};
    for (auto &&i: irange((unsigned int) 0, N)){
        maximum = max(maximum, sum.at(i));
    }

    cout << maximum << endl;

    return 0;
}

Measured memory_bytes: 256