akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

void RE(){cout<<1/0;}
void TLE(){sleep(100);}
void WA(){cout<<char(0);exit(0);}

const int N = 1e5;
ll a, b;
struct Prime{
  vector<ll> pl;
  void init(int a){ // a以下の素数列挙
    pl.resize(0);
    vector<bool> z(a+1, true);
    for(int i=2; i<=a; i++) if(z[i]){
      pl.push_back(i);
      for(int b=i*2; b <= a; b+=i) z[b]=false;
    }
  }
  void prime_division(ll a, vector<pair<ll, int>> &v){
    v.resize(0);
    for(ll b: pl){
      if(b*b > a) break;
      if(a%b) continue;
      int c = 0;
      while(a%b==0) a/=b, c++;
      v.push_back(make_pair(b, c));
    }
    if(a>1) v.push_back(make_pair(a, 1));
  }
} pl;
vector<pair<ll, int>> v;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  pl.init(1000000);
  cin >> a >> b;
  a = __gcd(a, b);
  pl.prime_division(a, v);
  cout << sz(v)+1 << endl;
}

Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;

int find2(ll a){
	int count = 0;
	while(a%2!=1){
		a = a/2;
		count++;
	}
	return count;
}

int main(){
	ll A, B, C;
	cin >> A >> B >> C;

	if(A%2 == 1 or B%2 == 1 or C%2 == 1){
		//printf("a\n");
		cout << 0 << endl;
		return 0;
	}
	if(A==B and B==C){
		cout << -1 << endl;
		return 0;
	}

	ll a,b,c;
	ll count = 0;
	while(A%2!=1 and B%2!=1 and C%2!=1){
		a = B/2 + C/2;
		b = A/2 + C/2;
		c = A/2 + B/2;
		A = a;
		B = b;
		C = c;
		count++;
		//printf("count : %d\n",count);
	}

	cout << count << endl;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 15
int a[N];
int n,ans=1,tt=1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	  ans*=3;
	for(int i=1;i<=n;i++)
	{
		int tmp=0;
		if((a[i]-1)&1) tmp++;
		if(a[i]&1) tmp++;
		if((a[i]+1)&1) tmp++;
		tt*=tmp;
	}
	printf("%d",ans-tt);
}

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

#define int long long
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}

int lcm(int a, int b){
	return a * b / gcd(max(a, b), min(a, b));
}

int divs(int a, int b, int c){
	int tmp = (b / c) - (a / c);
	if(a % c == 0) tmp++;
	return tmp;
}

signed main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (b - a + 1) - divs(a, b, c) - divs(a, b, d) + divs(a, b, lcm(c, d));
}


Measured memory_bytes: 256
program ABC069C
    implicit none
    integer(8)::N,i
    integer(8)::count4=0!4の倍数の個数
    integer(8)::count2=0!2の倍数の個数
    integer(8)::count1=0!奇数の個数
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)

    do i=1,N
        if(mod(A(i),4)==0)then
            count4=count4+1
        else if(mod(A(i),2)==0)then
            count2=count2+1
        else
            count1=count1+1
        end if
    end do

    if(count2==0)then
        if(count4+1>=count1)then
            print'(A)',"Yes"
        else
            print'(A)',"No"
        end if
    else
        if(count4>=count1)then
            print'(A)',"Yes"
        else
            print'(A)',"No"
        end if
    end if
end program ABC069C

Measured memory_bytes: 1536
s = gets.chomp.split('') + ['!']
a = 'AKIHABARA'.split('') + ['!']
while a.length > 0
    if s[0] == a[0]
        s.shift
        a.shift
    elsif a[0] == 'A'
        a.shift
    else
        puts 'NO'
        exit
    end
end
puts 'YES'

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const ll MOD = 1e9 + 7;

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

  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M);

  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];

  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());

  queue<int> qA, qB;

  rep(i, N) qA.push(A[i]);
  rep(i, M) qB.push(B[i]);

  int now = N * M;
  ll ans = 1;
  ll cnt_a = 0;
  ll cnt_b = 0;
  while(now > 0){

    int fa = -1;
    int fb = -1;
    if(qA.size() > 0){
      fa = qA.front();
    }
    if(qB.size() > 0){
      fb = qB.front();
    }

    if(fb == now && fa == fb){
      qA.pop();
      qB.pop();
      cnt_a++;
      cnt_b++;
      now--;
    }else if(fb == now){
      ans = (ans * cnt_a) % MOD;
      qB.pop();
      cnt_b++;
      now--;
    }else if(fa == now){
      ans = (ans * cnt_b) % MOD;
      qA.pop();
      cnt_a++;
      now--;
    }else{
      
      if(cnt_a * cnt_b - (N * M - now) <= 0){
        ans = 0;
      }else{

        ans = (ans * (cnt_a * cnt_b - (N * M - now))) % MOD;

      }
      now--;
    }
  }

  cout << ans << endl;



  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int x, t;
    
    scanf("%d%d", &x, &t);

    if (x<=t) {
        x=t;
    }
    
    printf("%d", x-t);
    
    return 0;
}



Measured memory_bytes: 1728
from collections import deque

N = int(input())

edges = [[] for _ in range(N)]
edgeList = []
for _ in range(N - 1):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)
    edgeList.append((fr, to))

C = list(map(int, input().split()))
C.sort()

M = sum(C) - C[-1]

values = [-1] * N
que = deque([0])

while que:
    now = que.popleft()
    values[now] = C.pop()
    for to in edges[now]:
        if values[to] == -1:
            que.append(to)

print(M)
print(*values)

Measured memory_bytes: 7052
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int n;
    cin>>n;
    string s[n];
    map<char,int> m;
    rep(i,n){
        cin >> s[i];
        if(s[i][0]=='M'||s[i][0]=='A'||s[i][0]=='R'||s[i][0]=='C'||s[i][0]=='H'){
            m[s[i][0]]++;
        }
    }
    int64_t sum=0;
    int64_t a,b,c,d,e;
    a = m['M'],b= m['A'], c=m['R'], d=m['C'],e= m['H'];
    sum = a*(b*c + b*d + b*e + c*d + c*e+ d*e)+b*(c*d+c*e+d*e)+c*d*e;
    cout<<sum<<endl;
}

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n-1; i++) {
        int tmp;
        std::cin >> tmp;
        a[tmp-1]++;
    }

    for (int i = 0; i < n; i++) {
        std::cout << a[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 4048
N = int(input())
Ai = [0] * N
Ai = list(map(int,input().split()))
Ai.sort()
Ans = 1

for i in range(N):
  if Ai[i] == 0:
    Ans = 0
    break
    
  Ans = Ans * Ai[i]

  if Ans > 10 ** 18:
    Ans = -1
    break
  
if Ans <= 10**18:
  print(Ans)
else:
  print('-1')

Measured memory_bytes: 22376
using System;
using System.Linq;

class Amondai
{
    static void Main()
    {
        var num = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var max = num[0] < num[1] ? num[1] : num[0];
        var min = max == num[0] ? num[1] : num[0];
        var ans = -1L;
        var line1 = Console.ReadLine().ToCharArray();
        var line2 = Console.ReadLine().ToCharArray();
        if (line1[0] != line2[0])
        {
            Console.WriteLine(ans);
            return;
        }
        ans = GetS(max, min);
        if (max * min != ans)
        {
            var kankaku1 = ans / num[0];
            var kankaku2 = ans / num[1];
            var kankaku = GetS(kankaku1, kankaku2);
            for (long i = kankaku; i < ans; i += kankaku)
            {
                if (line1[i / kankaku1] != line2[i / kankaku2] || (line1.Count() < i / kankaku1) || (line2.Count() < i / kankaku2))
                {
                    ans = -1;
                    break;
                }
            }
        }
        Console.WriteLine(ans);
    }

    static long GetS(long max, long min)
    {
        var r = 0L;
        var a = max;
        var b = min;
        while ((r = max % min) != 0)
        {
            max = min;
            min = r;
        }
        return a * b / min;
    }
}

Measured memory_bytes: 13408
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;

int dy[5] = {-1, 0, 1, 0, 0};
int dx[5] = {0, -1, 0, 1, 0};

int main(void) {
    long long int r,g,b,n;
    long long int count=0;

    cin>>r>>g>>b>>n;
    FOR(i,0,INF){
        if(i*r>n){
            break;
        }
        FOR(k,0,INF){
            if(i*r+k*g>n){
                break;
            }
            if((n-i*r-k*g)%b==0){
                count++;
            }
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 768
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
ans=0
fac=[1]
for i in range(n):
	p=fac[-1]*(i+1)%mod
	fac.append(p)
def comb(a,b):
	if a-b<0:
		return 0
	else:
		r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
		return r*fac[a]%mod
for i in range(n):
	ans-=comb(n-i-1,k-1)*a[i]
	ans+=comb(i,k-1)*a[i]
	ans%=mod
print(ans)


Measured memory_bytes: 14416
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main () {
  queue<char> A,B,C;
  string s,t,u;
  cin >> s >> t >> u;
  rep(i,0,s.size()) A.push(s[i]);
  rep(i,0,t.size()) B.push(t[i]);
  rep(i,0,u.size()) C.push(u[i]);
  
  char now = 'a';
  
  rep(i,0,310){
    
//    cout << A.size() << ' ' << B.size() << ' ' << C.size() << endl;
    
    
    
    
    if(now=='a'){
      if(A.empty()) {
        cout << 'A' << endl;
        return 0;
      }
      now = A.front();
      A.pop();
      continue;
    }
    
    
    if(now=='b'){
      if(B.empty()) {
        cout << 'B' << endl;
        return 0;
      }
      now = B.front();
      B.pop();
      continue;
    }
    
    
    if(now=='c'){
      if(C.empty()) {
        cout << 'C' << endl;
        return 0;
      }
      now = C.front();
      C.pop();
      continue;
    }

  }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

public class Main{
    public static void main(String[] args){
        int count=0;
        Scanner sc = new Scanner(System.in);
        int a= sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        for(int i=a;i<=b;i++){
if(c%i==0) count++;
        }
        System.out.println(count);
            }
    }


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

const int INF=1e9;

int main() {
  ll n,h; cin>>n>>h;
  vector<ll> b(n);
  ll mx=0;
  rep(i, n) {
    ll a;
    cin>>a>>b[i];
    mx=max(mx, a);
  }
  sort(b.begin(), b.end(), greater<ll>());
  ll ans=0;
  rep(i, n) {
    if (b[i]>mx) {
      h-=b[i];
      ans++;
    }
    else break;
    if (h<=0) break;
  }
  if (h>0) ans+=(h+mx-1)/mx;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
n,k = map(int,input().split())
ans_l = 0
ans_r = n
for i in range(k):
    l,r = map(int,input().split())
    if l >= ans_l:
        ans_l = l
    if r <= ans_r:
        ans_r = r

if ans_r-ans_l+1 >= 0:
    print(ans_r-ans_l+1)
else:
    print("0")

Measured memory_bytes: 3060
/**Bismillahir Rahmanir Rahim**/


#include<bits/stdc++.h>
using namespace std;
#define ll long long

#define pb push_back
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define clr(v) v.clear()
vector<ll>v;
pair<ll,ll>p;
map<ll,ll>mp;
set<ll>st;
deque<ll>dq;
priority_queue<ll>pq;
#define f(i,b) for(i=0;i<b;i++)
#define f1(i,b) for(i=1;i<=b;i++)
#define fr(i,b)for(i=b-1;i>=0;i--)
ll mn=INT_MAX,mx=INT_MIN;
ll n,m,tc,i,j,tmp,sum,cn,ans,res,pos,flag,l,x,k,dif;

string s,str;


ll a[200007],b[200007];
int main()
{

   io;
ll n,m;
cin>>n>>m;
cout<<(n-1)*(m-1);
return 0;
}





Measured memory_bytes: 3624
#include<cstdio>
#include<vector>

#define	mp	make_pair
#define	pb	push_back

using namespace std;

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

int main(){
	static bool era[10000];
	for(int i=2;i<100;i++){
		if(!era[i])	for(int j=i*i;j<10000;j+=i)	era[j]=true;
	}

	vi pr;
	for(int i=2;i<10000;i++)	if(!era[i])	pr.pb(i);

	for(int n;scanf("%d",&n),n;){
		int nn=n;
		vector<pii> div;
		for(int i=0;i<pr.size()&&n>1;i++){
			if(n%pr[i]==0){
				int m=0;
				do{
					n/=pr[i];
					m++;
				}while(n%pr[i]==0);
				div.pb(mp(pr[i],m));
			}
		}
		if(n>1)	div.pb(mp(n,1));

		long long dsum=1;
		for(int i=0;i<div.size();i++){
			int d=div[i].first,m=div[i].second;
			long long tmp=1;
			for(int j=0;j<m+1;j++)	tmp*=d;
			dsum*=(1-tmp)/(1-d);
		}
		dsum-=nn;

		puts(nn==dsum?"perfect number":nn<dsum?"abundant number":"deficient number");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
#define chmax(x,y) x=max(x,y)
int sh,hmax,H,W,S,T,P;
vector<int> p;
map<char,int> d;
vector<int> n;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
string s[100];
int dp[1<<12];
int main(){
	while(true){
		cin>>sh>>hmax;
		if(sh==0) break;
		p.clear();
		d.clear();
		n.clear();
		cin>>H>>W;
		rep(i,H) cin>>s[i];
		cin>>T;
		rep(i,T){
			char c;
			int x;
			cin>>c>>x;
			d[c]=x;
		}
		cin>>S;
		rep(i,S){
			char c;
			int x,X;
			cin>>c>>x;
			if(c=='U') X=0;
			if(c=='R') X=1;
			if(c=='D') X=2;
			if(c=='L') X=3;
			rep(j,x) n.pb(X);
		}
		cin>>P;
		rep(i,P){
			int x;
			cin>>x;
			p.pb(x);
		}
		rep(j,1<<P) dp[j]=0;
		dp[0]=sh;
		int x=0,y=0;
		rep(i,n.size()){
			int di=n[i];
			x+=dx[di],y+=dy[di];
			int dam=d[s[x][y]];
			rep(j,1<<P){
				if(dp[j]==0||dp[j]>dam) continue;
				int a[12];
				rep(k,P) a[k]=(j>>k)&1;
				rep(k,P) if(a[k]==0) chmax(dp[j+(1<<k)],min(dp[j]+p[k],hmax));
			}
			rep(j,1<<P) dp[j]=max(dp[j]-dam,0);
		}
		bool ans=false;
		rep(j,1<<P) if(dp[j]>0) ans=true;
		if(ans) puts("YES");
		else puts("NO");
	}
}

Measured memory_bytes: 1240
import std.stdio, std.typecons, std.algorithm;

alias Tuple!(int, "top", int, "bottom") Bundle;

const int INF = (1 << 24);

void main() {
  uint times; scanf("%d", &times);
  uint[][] dp = new uint[][](times, times);
  Bundle[] cards;
  foreach(t; 0..times) {
    uint top, bottom; scanf("%d %d", &top, &bottom);
    cards ~= Bundle(top, bottom);
  }

  foreach(ref d; dp)
    foreach(ref x; d) x = INF;
  for(int i = 0; i < times - 1; i++) dp[i][i] = 0;
  dp[times - 1][times - 1] = 0;
  
  // dp[i][j] -> i 番目 から j 番目を計算する時の最適コスト
  for(uint len = 1; len < times; len++) {
    for(uint s = 0; s + len < times; s++) {
      int f = s + len;
      for(uint i = s; i < f; i++) {
        uint cost =
          (cards[s].top * cards[i].bottom) * (cards[i + 1].top * cards[f].bottom);
        cost += dp[s][i] + dp[i + 1][f];
        if (cost < dp[s][f]) dp[s][f] = cost;
      }
    }
  }
  writeln(dp[0][times - 1]);
}

Measured memory_bytes: 1056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115A
{
	class Program
	{
		static void Main(string[] args)
		{
			string n;
			n = Console.ReadLine();

			if (n[0] == '2' && n[1] == '5')
				Console.WriteLine("Christmas");
			else if (n[0] == '2' && n[1] == '4')
				Console.WriteLine("Christmas Eve");
			else if (n[0] == '2' && n[1] == '3')
				Console.WriteLine("Christmas Eve Eve");
			else if (n[0] == '2' && n[1] == '2')
				Console.WriteLine("Christmas Eve Eve Eve");
			else
				Console.WriteLine();
			Console.ReadKey();
		}
	}
}


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

using namespace std;

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

vector<vector<pair<int, int>>> dp;
vector<vector<int>> num;
vector<bool> P(1123456, true);
int n, m;
int sr, sc;
pair<int, int> ans;

bool init() {
	dp.clear();
	num.clear();
	ans = make_pair(0, 0);
	cin >> m >> n;
	if (m == 0) return false;
	dp.resize(1111, vector<pair<int, int>>(1111, make_pair(-1, 0)));
	num.resize(1111, vector<int>(1111, 0));
	int dr[] = {0, -1, 0, 1};
	int dc[] = {1, 0, -1, 0};
	int p = 2;
	int r = 505;
	int c = 505;
	reps(i, 1, m+1) {
		int np = (p + 1) % 4;
		if (num[r + dr[np]][c + dc[np]] == 0) {
			r += dr[np];
			c += dc[np];
			p = np;
		} else {
			r += dr[p];
			c += dc[p];
		}
		num[r][c] = i;
		if (i == n) {
			sr = r;
			sc = c;
		}
	}
	return true;
}

pair<int, int> dfs(int r, int c) {
	pair<int, int>& res = dp[r][c];
	if (res.first >= 0) return res;
	if (num[r][c] == 0) return res = make_pair(0, 0);
	res = max(dfs(r+1, c-1), dfs(r+1, c));
	res = max(res, dfs(r+1, c+1));
	res.first += P[num[r][c]];
	if (P[num[r][c]] && res.first == 1) res.second = num[r][c];
	return res;
}

void solve() {
	auto res = dfs(sr, sc);
	cout << res.first << " " << res.second << endl;
}

int main() {
	reps(i, 2, 1123456) {
		if (P[i]) {
			for (int j = i + i; j < 1123456; j += i) {
				P[j] = false;
			}
		}
	}
        P[1] = false;
	while (init()) {
		solve();
	}
}


Measured memory_bytes: 17776
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
// 小大
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}
typedef struct{
    llint aa;
    llint bb;
}frequent;
// 小大
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->bb - ((frequent*)q)->bb;
}


int main(void){
    char s[101],ans[1];
    llint i,k;
    scanf("%s%lld",s,&k);
    // llint [n];
    // n = strlen(s);
    if(k>100) k=100;
    for(i=0;i<k;i++){
        if(s[i]!='1'){
            ans[0] = s[i];
            break;
        }
    }
    if(i==k) ans[0]='1';



    printf("%c\n",ans[0]);
    return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h+2, vector<char>(w+2));
    for (int i = 0; i < h + 2; i++) s[0][i] = s[h+1][i] = '.';
    for (int i = 0; i < h + 2; i++) s[i][0] = s[i][w+1] = '.';
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) cin >> s[i][j];
    }

    string ans = "Yes";
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (s[i][j] == '#' && s[i+1][j] == '.' && s[i][j+1] == '.' && s[i-1][j] == '.' && s[i][j-1] == '.') ans = "No";
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if (flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    string S;
    cin >> S;
    cin >> x >> y;

    vl X[2];
    a = 0;
    b = 0;
    rep(i, S.length()) {
        if (S[i] == 'F') {
            b++;
        }
        else {
            X[a % 2].push_back(b);
            a++;
            b = 0;
        }
    }
X[a % 2].push_back(b);

    bitset<16001> xx, yy,now;
    x += 8000;
    y += 8000;
    xx.set(8000);
    yy.set(8000);
    rep(i, X[0].size()) {
        if (i == 0)xx=xx<<X[0][0];
        else {
            now = (xx << X[0][i]) | (xx >> X[0][i]);
            xx = now;
        }
    }
    rep(i, X[1].size()) {
        now = (yy << X[1][i]) | (yy >> X[1][i]);
        yy = now;
    }

    cout << (xx[x] && yy[y] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);

  if(c <= a+d && a-d <= c){
    printf("Yes\n");
    return 0;
  }else if(b <= a+d && a-d <= b){
    if(c <= b+d && b-d <= c){
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(n) for(int i=0;i<(n);i++)
#define rep1(n) for(int i=1;i<=(n);i++)
#define all(n) n.begin(),n.end()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define pb push_back
ll n;
const ll mod = 1000000007;
struct mat{
  ll a[55][55];
  mat(){
    memset(a,0,sizeof(a));
  }
  mat operator *(const mat &b){
    mat c;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        for(int k=0;k<n;k++){
          c.a[i][j] += a[i][k]%mod * b.a[k][j];
          c.a[i][j] %= mod;
        }
      }
    }
    return c;
  }
};
int main(){
    	ll k;
    	cin>>n>>k;
    	mat ori;
    	for(int i=0;i<n;i++){
        ori.a[i][i] = 1;
    	}
    	mat tra;
    	for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
          cin>>tra.a[i][j];
        }
    	}
      while(k){
        if(k&1) ori = ori * tra;
        tra = tra * tra;
        k>>=1;
      }
      ll ans = 0;
      for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
          //cout<<ori.a[i][j]<<" ";
          ans += ori.a[i][j];
          ans %= mod;
        }
        //cout<<'\n';
      }
      cout<<ans<<'\n';
}


Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	int n,max=0,a[64]={0};
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(abs(a[i])>abs(a[max])) max=i;
	}
	if(a[max]>0){
		printf("%d\n",2*n);
		printf("%d %d\n",max,n);
		printf("%d %d\n",max,n);
		for(int i=1;i<n;i++){
			printf("%d %d\n",n,i);
			printf("%d %d\n",n,n);
		}
	}
	else if(a[max]<0){
		printf("%d\n",2*n);
		printf("%d %d\n",max,1);
		printf("%d %d\n",max,1);
		for(int i=n;i>1;i--){
			printf("%d %d\n",1,i);
			printf("%d %d\n",1,1);
		}
	}
	else printf("0\n");
} 

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

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

    ll ans=-1e18;
    ans=max(ans, a*c);
    ans=max(ans, a*d);
    ans=max(ans, b*c);
    ans=max(ans, b*d);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main(){
  int n;
  cin >> n;
  string s,t,u;
  cin >> s >> t;
  for(int i=0;i<n;++i){
    u.push_back(s[i]);
    u.push_back(t[i]);
  }
  cout << u << endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn main() {
    let x1:i32 = read();
    let y1:i32 = read();
    let x2:i32 = read();
    let y2:i32 = read();

    let dx = x2-x1;
    let dy = y2-y1;

    println!("{} {} {} {}", x2-dy, y2+dx, x2-dy-dx, y2+dx-dy);

}


Measured memory_bytes: 4352
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<vector>
#include<list>
#include<queue>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

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

  priority_queue<long> A;
  long tmp;
  rep(i, N){
    cin >> tmp;
    A.push(tmp);
  }
  
  int rem = M;
  while(rem > 0){
    tmp = A.top() / 2;
    A.pop();
    A.push(tmp);
    rem--;
  }

  long total = 0;

  rep(i, N){
    total += A.top();
    A.pop();
  }

  cout << total << endl;
  
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

double r=3.14159265358979;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    r/=180;
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double alpha=m*6,beta=m,c,d,e,f;
    beta/=60;
    beta+=h;
    beta*=30;
    if (alpha==0||alpha==360)
    {
        c=0;
        d=b;
    }
    else if (alpha==90)
    {
        c=b;
        d=0;
    }
    else if (alpha==180)
    {
        c=0;
        d=-b;
    }
    else if (alpha==270)
    {
        c=-b;
        d=0;
    }
    else if (alpha<90)
    {
        c=b*sin(alpha*r);
        d=b*cos(alpha*r);
    }
    else if (alpha<180)
    {
        alpha-=90;
        c=b*cos(alpha*r);
        d=-b*sin(alpha*r);
    }
    else if (alpha<270)
    {
        alpha-=180;
        d=-b*cos(alpha*r);
        c=-b*sin(alpha*r);
    }
    else
    {
        alpha-=270;
        c=-b*cos(alpha*r);
        d=b*sin(alpha*r);
    }
    //now beta (hour)
    alpha=beta;
    e=c;
    f=d;
    b=a;
    if (alpha==0||alpha==360)
    {
        c=0;
        d=b;
    }
    else if (alpha==90)
    {
        c=b;
        d=0;
    }
    else if (alpha==180)
    {
        c=0;
        d=-b;
    }
    else if (alpha==270)
    {
        c=-b;
        d=0;
    }
    else if (alpha<90)
    {
        c=b*sin(alpha*r);
        d=b*cos(alpha*r);
    }
    else if (alpha<180)
    {
        alpha-=90;
        c=b*cos(alpha*r);
        d=-b*sin(alpha*r);
    }
    else if (alpha<270)
    {
        alpha-=180;
        d=-b*cos(alpha*r);
        c=-b*sin(alpha*r);
    }
    else
    {
        alpha-=270;
        c=-b*cos(alpha*r);
        d=b*sin(alpha*r);
    }
    cout<<fixed<<setprecision(15)<<sqrt((c-e)*(c-e)+(d-f)*(d-f));
    return 0;
}

Measured memory_bytes: 4056
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, A, B, C, D = read_ints()
S = input()

A -= 1
B -= 1
C -= 1
D -= 1
# 大小関係の実装
plan = 1  # ひっくり返らない処理が1,ヒックリ変えるのが2、領域が二分割されるのが3

if D < C:
    plan = 2

if C < B:
    plan = 3

from sys import exit

# 入れ替わるかの条件ごとに実装する
if plan == 1:
    for s_left, s_right in zip(S[A:], S[A + 1:D]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')
elif plan == 2:
    # 入れ替わる場
    for s_left, s_right in zip(S[A:], S[A + 1:C]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()

    for s_left, s_center, s_right in zip(S[B-1:D], S[B:D+1], S[B+1:D+2]):
        if s_left == '.' and s_center == '.' and s_right == '.':
            print('Yes')
            exit()
    print('No')
elif plan == 3:
    # print(plan)
    # AC,BD間に##の存在を確かめれば良い
    for s_left, s_right in zip(S[A:], S[A+1:C]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    for s_left, s_right in zip(S[B:], S[B+1:D]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')


Measured memory_bytes: 3708
x,y=input().split()
s="ABCDEF"
for i in range(0,6):
  if s[i]==x:
    x=int(i)
  if s[i]==y:
    y=int(i)
if x>y:
  print(">")
elif x<y:
  print("<")
else:
  print("=")


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int l=scn.nextInt();
		int r=scn.nextInt();
		if((2019<l||r<2019)&&r-l<2019) {
			l=l%2019;
			r=r%2019;
			if(l<r)
			func(l,r);
			else {
				System.out.println(0);
			}
		}
		else {
			System.out.println(0);
		}
	}
	
	public static void func(int l, int r) {
		
		int min=Integer.MAX_VALUE;
		for(int i=l;i<r;i++) {
			for(int j=i+1;j<=r;j++) {
				int x=(i*j)%2019;
				if(x<min) {
					min=x;
				}
			}
		}
		System.out.println(min);

	}

}


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

const int N = 200228;

vector<int> v[N];
int fen[N];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int h, w, n;
    cin >> h >> w >> n;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        v[y].push_back(x);
    }

    int p = 0;
    int ans = h + 1;

    for (int i = 1; i <= w; ++i) {
        v[i].push_back(h + 1);
        sort(v[i].begin(), v[i].end());

        for (;;) {
            if (++p > h) {
                break;
            }

            int c = *lower_bound(v[i].begin(), v[i].end(), p);
            if (c != p) {
                ans = min(ans, c);
                break;
            }
        }

        if (p > h) {
            break;
        }

    }

    cout << ans - 1 << "\n";
}



Measured memory_bytes: 11264
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_isu(void) {
	int x, y, z;
	cin >> x >> y >> z;

	int num = x/(y + z);
	int sub = x - (y + z) * num;
	if (sub < z) num--;
	cout << num << endl;

}

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

Measured memory_bytes: 3560
#include<stdio.h>
 
int main(void){
    double  a,b,c,d,e,f,x,y;

    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
        x = (c*e-b*f)/(a*e-b*d);
        y = (c*d-a*f)/(b*d-a*e);

        if(x == -0.000){
            x = 0.000;
        }
        if(y == -0.000){
            y = 0.000;
        }

        printf("%.3lf %.3lf\n",x,y);

    }
    return 0;
}

Measured memory_bytes: 652
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
ll n;
int main(void){
	scanf("%lld",&n);
	ll ans = 0;
	ll ct = 1;
	ll t = n;
	while(n!=1){
		n/=2;
		ans = ans+ct;
		ct *=2;
	}
	printf("%lld\n",ans+ct);
	return 0;
}
//1000000000000
//1099511627775

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

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

  if ( a >= 500 || n % 500 == 0) {
    cout << "Yes" << endl;
  } else {
    if ( n % 500 < a ) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  

}

Measured memory_bytes: 256
N,M=map(int,input().split())
mod = 10**9+7

factorial=[1 for i in range(10**5+5)]
for i in range(1,10**5+5):
    if i==1:factorial[i]=1
    else:factorial[i] = factorial[i-1]*i % mod
      
if abs(N-M)>1:
  print(0)
  exit()

if N==M:
  print(factorial[M]**2*2%mod)
else:
  print(factorial[M]*factorial[N]%mod)

Measured memory_bytes: 12996
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,t,a,b,n,c,d,y,temp,m,r,sum,count,k,l,ans;
    t=1;
    // cin>>t;
    while(t--)
    {
        float p,q,s;
        cin>>p>>q;
        cout<<2.0*(q)-p;
    }
}

Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2017年04月17日 星期一 00时41分15秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1e5+10;
int a[N];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
   	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);

	int flag;
	int id=1,ans=0;

	while(id<=n){
		flag=-1,ans++;
		while(id+1<=n){
			if(a[id+1]==a[id]) id++;
			else if(a[id+1]<a[id]){
				if(flag!=1){
					flag=0,id++;
					continue;
				}
				else break;
			}
			else{
				if(flag!=0){
					flag=1,id++;
					continue;
				}
				else break;
			}
		}
		id++;
	}

	printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M,count=-1,ans=0;
    char s[200005];
    int i=0;


    cin>>s;

    M=strlen(s);
    for(int i=0;i<M;i++){
        if(s[i]=='A'&&count<0)count=i;
        if(s[i]=='Z'){
            ans=i+1;
        }
    }



        cout<<ans-count<<endl;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

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

    int h, w;
    cin >> h >> w;
    vector<string> s(h + 2);
    rep(i, 0, h) {
        string t;
        cin >> t;
        s[i + 1] = '#' + t + '#';
    }
    rep(i, 0, w + 2) s[0] += '#';
    s[h + 1] = s[0];

    int ans = 0;
    rep(i, 1, h + 1) rep(j, 1, w + 1) {
        if (s[i][j] == '#') continue;

        int cnt = 0;
        queue<int> q;
        set<int> st;
        q.push(100 * i + j);
        st.insert(100 * i + j);
        while (!q.empty()) {
            cnt++;
            for (int k = q.size(); k > 0; k--) {
                int p = q.front();
                int x = p / 100, y = p % 100;
                q.pop();
                if (s[x][y - 1] == '.' && st.count(p - 1) == 0) {
                    q.push(p - 1);
                    st.insert(p - 1);
                }
                if (s[x][y + 1] == '.' && st.count(p + 1) == 0) {
                    q.push(p + 1);
                    st.insert(p + 1);
                }
                if (s[x - 1][y] == '.' && st.count(p - 100) == 0) {
                    q.push(p - 100);
                    st.insert(p - 100);
                }
                if (s[x + 1][y] == '.' && st.count(p + 100) == 0) {
                    q.push(p + 100);
                    st.insert(p + 100);
                }
            }
        }
        ans = max(ans, cnt - 1);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
  int a,b;

  cin >> a >> b;

  if(a + b == 15)
    {
      cout << "+" << endl;
    }
  else if(a * b == 15)
    {
      cout << "*" << endl;
    }
  else
    {
      cout << "x" << 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);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = a-(b*2);
    if(c<0){
      c = 0;
    }
    System.out.println(c);
  }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main() {
    ll s, w;
    cin >> s >> w;

    if (s > w) {
        MSG("safe")
    } else {
        MSG("unsafe")
    }


}


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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n;
    string s;
    cin>>n>>s;
    ll ans=0,x=0;
    rep(i,n){
        if(s[i]=='I') x++;
        else x--;
        ans=max(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = k; i < n; i++) {
		if(a[i] > a[i - k])
			cout << "Yes" << '\n';
		else
			cout << "No" << '\n';
	}
}


Measured memory_bytes: 4044
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String Sn[] = new String[N];
		for(int sGet = 0;sGet < N;sGet++){
			Sn[sGet] = sc.next();
			//char[] chars = Sn[sGet].toCharArray();
			//並べ替えを行う
			//Arrays.sort(chars);
			//String newSget = new String(chars); 
			//Sn[sGet] = newSget;
			//System.out.println(Sn[sGet]);
		}
		Arrays.sort(Sn);
		for(int num = 0;num < Sn.length;num++){
			System.out.print(Sn[num]);
		}
		System.out.println();


	}
}


Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e9
typedef long long ll;
typedef pair<ll,ll> P;

int n;

set<int>g[110];

int main(void){
    cin>>n;
    int m=0;
    if(n%2==1){
        for(int i=1;i<n;i++){
            g[n].insert(i);
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(i==j)continue;
                if(j==n-i)continue;
                if(g[j].count(i))continue;
                g[i].insert(j);
            }
        }
        for(int i=1;i<=n;i++){
            m+=(int)g[i].size();
        }
        cout<<m<<endl;
        for(int i=1;i<=n;i++){
            for(auto itr=g[i].begin();itr!=g[i].end();++itr){
                cout<<i<<" "<<(*itr)<<endl;
            }
        }
    }
    else{
        for(int i=2;i<=n-1;i++){
            g[1].insert(i);
            g[n].insert(i);
        }
        for(int i=2;i<=n-1;i++){
            for(int j=1;j<=n;j++){
                if(i==j)continue;
                if(i+j==n+1)continue;
                if(g[j].count(i))continue;
                g[i].insert(j);
            }
        }
        for(int i=1;i<=n;i++)m+=(int)g[i].size();
        cout<<m<<endl;
        for(int i=1;i<=n;i++){
            for(auto itr=g[i].begin();itr!=g[i].end();++itr){
                cout<<i<<" "<<(*itr)<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    edge_count = 0
    for i in range(N - 1):
        u, v = sorted(inl())
        edge_count += u * (N - v + 1)

    node_count = 0
    for i in range(N):
        node_count += (i + 1) * (N - i)
    return node_count - edge_count


print(solve())


Measured memory_bytes: 9208
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**10
for i in range(n-k+1):
    s,e = x[i],x[i+k-1]
    if e<0:
        ans = min(ans,abs(s))
    elif s>0:
        ans = min(ans,e)
    else:
        ans = min(ans,abs(s)*2+e,abs(s)+e*2)
print(ans)

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

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;
  char target = s.at(k - 1);

  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) != target) s.at(i) = '*';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
 int main(void){
 int i,n; 
int number;
 long long int sum=0;
 int min=0; int max=0;

scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%d",&number);

if(i==0){
 min = number;
 max = number; 
} 
if(number<min) min = number;
 if(number>max) max = number;

sum += number; 
} 
printf("%d %d %lld\n",min,max,sum);

return 0; 
}

Measured memory_bytes: 600
#include<stdio.h>

#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs();
void visit(int );

int n,time;
int color[N],d[N],f[N],G[N][N];

int main(){
int i,j;
int u,k,v;

scanf("%d",&n);

for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
        G[i][j]=0;
    }
}

for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
        scanf("%d",&v);
        G[u][v]=1;
    }
}

dfs();

for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
}

return 0;

}

void dfs(){
    int i;

    for(i=1;i<=n;i++) color[i]=0;

    time=0;

    for(i=1;i<=n;i++){
        if(color[i]==0) visit(i);
    }

}

void visit(int u){
    int i;

    color[u]=1;

    d[u]=++time;

    for(i=1;i<=n;i++){
        if(G[u][i]==0) continue;
        if(color[i]==0) visit(i);
    }

    color[u]=2;
    f[u]=++time;

}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

int main(){
    long long l, r;
    std::cin >> l >> r;

    long long min = 2 * std::pow(10, 9);
    if(r - l + 1 < 2018){
        for(long long i = l; i < r; ++i){
            for(long long j = i + 1; j <= r; ++j){
                min = std::min(min, (i * j) % 2019);
            }
        }
    }else{
        min = 0;
    }

    std::cout << min << std::endl;

    return 0;
}


Measured memory_bytes: 256