akhauriyash/Code-Regression huggingface dataset:
#include <iostream> //üoÍ
#include <vector>   //®Izñ

using namespace std;

int main(){
	int n;
	cin >> n;
	for(int k=0;k<n;k++){
		vector<int> vec;
		for(int i=0;i<3;i++){
			int num;
			cin >> num;
			vec.push_back(num);
		}

		
		
		for(int i=0;i<vec.size();i++){
			for(int j=0;j<vec.size()-1;j++){
				if(vec[j] < vec[j+1]){
					int num = vec[j];
					vec[j] = vec[j+1];
					vec[j+1] = num;
				}
			}
		}

		if((vec[1]*vec[1])+(vec[2]*vec[2]) == vec[0]*vec[0]){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
	
}

Measured memory_bytes: 0
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
//#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;
int m;
int d[10001], p[10001];

int main() {
	while (cin >> n >> m, n) {
		vector<pair<int, int>> v;
		for (int i = 0; i < n; i++) {
			cin >> d[i] >> p[i];
			v.push_back(pair<int, int>(p[i], d[i]));
		}
		sort(v.rbegin(), v.rend());
		for (int i = 0; i < n; i++) {
			if (v[i].second <= m) {
				m -= v[i].second;
				v[i].second = 0;
			}
			else {
				v[i].second -= m;
				m = 0;
			}
		}
		ll ans = 0;
		for (int i = 0; i < n; i++) {
			ans += (v[i].first)*(v[i].second);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
package main

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

func main() {
	sc := NewScanner()
	X := sc.NextInt()
	i := 0
	A := 100
	for ; A < X; i++ {
		T := A / 100
		A = A + T
	}
	fmt.Println(i)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1756
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int fie[20][20];
int R,C;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
void printfie(){
  for(int y=0;y<R;y++){
    for(int x=0;x<C;x++)
      printf("%d ",fie[x][y]);
    puts("");
  }
}
int main(){
  while(1){
    scanf("%d %d",&R,&C);
    if(!R && !C) break;
    memset(fie,0,sizeof(fie));
    for(int y=0;y<R;y++){
      for(int x=0;x<C;x++){
	for(int i=0;i<4;i++){
	  int nx = x+dx[i];
	  int ny = y+dy[i];
	  if(nx < 0 || ny < 0 || nx>=C || ny>=R) continue;
	  if(fie[nx][ny]==0){
	    fie[nx][ny]=1;
	    break;
	  }
	}
	//	printfie();
	//	sleep(1);
      }
    }
    bool f=true;
    for(int x=0;x<C;x++)
      for(int y=0;y<R;y++)
	if(fie[x][y]==0) f=false;
    if(f) puts("yes");
    else puts("no");
  }
}

Measured memory_bytes: 1168
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> n(N, false);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            n[a - 1] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (!n[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}



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

int main()
{
  int n;int m;int k;cin>>n>>m>>k;
  vector<vector<char>>arr(n,vector<char>(m));
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
      cin>>arr[i][j];
  }
  int ans=0;
  for(int maskx=0;maskx<(1<<n);maskx++)
  {
    for(int masky=0;masky<(1<<m);masky++)
    {
      int black=0;
      for(int i=0;i<n;i++)
      {
        for(int j=0;j<m;j++)
        {
          if(!(maskx & 1<<i)&&!(masky & 1<<j)&&(arr[i][j]=='#'))
            black++;
        }
      }
      if(black==k)
        ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int solve(int debt, int n);
int addInterest(int debt);

int main (int argc, char* argv[])
{
    int n;
    int debt = 100000;
    cin >> n;
    cout << solve(debt, n) << endl;
	return 0;
}

int solve(int debt, int n){
    if(n == 0){
        return debt;
    }
    return solve(addInterest(debt), n - 1);
}

int addInterest(int debt){
    double interest = 0.05;
    return ((int)(debt * (1 + interest)) + 999) / 1000 * 1000;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 58;
// const int INF = 1 << 29;
const int MOD = 1000000007;
const int MAX_N = 200100;

int fn(int a)
{
    int ans = 1;
    while (a > 0)
    {
        a--;
        ans *= 2;
    }
    return ans;
}

int dp[51][51][50 * 50 + 10];

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    // std::ifstream in("F/in/dense_01.txt");
    // std::cin.rdbuf(in.rdbuf());
    int N, A;
    cin >> N >> A;
    int v[50];
    REP(i, N)
    {
        cin >> v[i];
    }

    REP(i, 51)
    {
        REP(j, 51)
        {
            REP(k, 50 * 50 + 10)
            {
                dp[i][j][k] = 0;
            }
        }
    }

    dp[0][0][0] = 1;
    dp[0][1][v[0]] = 1;
    REP(i, N - 1)
    {
        REP(j, N)
        {
            REP(k, 50 * 50 + 10)
            {
                if (dp[i][j][k] > 0)
                {
                    dp[i + 1][j][k] += dp[i][j][k];
                    dp[i + 1][j + 1][k + v[i + 1]] += dp[i][j][k];
                }
            }
        }
    }
    int ans = 0;
    for (int j = 1; j < N + 1; j++)
    {
        REP(k, 50 * 50 + 10)
        {
            if (dp[N - 1][j][k] > 0)
            {
                if (j * A == k)
                {
                    ans += dp[N - 1][j][k];
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
  int a,b,c; cin >> a >> b >> c;
  if(a!=b && b!=c && c!=a) cout << 3 << endl;
  else if(a==b && b==c && c==a) cout << 1 << endl;
  else cout << 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Dec 30 21:25:38 2018
//
package main

import "fmt"

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func main() {
	var N, K int
	_, _ = fmt.Scan(&N, &K)

	ans := 0
	for b := K + 1; b <= N; b++ {
		ans += max(0, N/b*(b-K)) + max(0, (N%b)-K+1)
	}

	if K == 0 {
		ans -= N - K
	}

	fmt.Println(ans)
}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s == "ARC")
        cout << "ABC" << ln;
    else
        cout << "ARC" << ln;
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll H, W, A, B;

int main() {
	cin >> H >> W >> A >> B;
	rep(i, B) {
		rep(j, A)cout << 0;
		rep(j, W - A)cout << 1;
		cout << endl;
	}
	rep(i, H - B) {
		rep(j, A)cout << 1;
		rep(j, W - A)cout << 0;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int C = scan.nextInt();
    int K = scan.nextInt();
    int sum = 0;
    if (A > K) {
      sum = K;
    }
    else if (A + B > K) {
      sum = A;
    }
    else{
      C = K - B - A;
      sum = A - C;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 35740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
   
  while(A>0&&C>0){
    C -=B;
     if (C>0){
        A -=D;
     }
    }
  if(A>0&&C<=0){
    cout << "Yes" << endl;
  }
  else { cout << "No" << endl; }
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

  ll N, K;

  cin >> N >> K;

  vl a(N, 0);
  // 0 Taro
  // 1 Other
  vector<vb> dp(2, vb(K+1, false));

  ll minimum = oo;
  FOR(i, 0, N){
    cin >> a[i];
    minimum = min(minimum, a[i]);
  }

  FOR(i, minimum, K+1)FOR(j, 0, N){
    if(i-a[j] >= 0 && !dp[1][i-a[j]]){
      dp[0][i] = true;
    }
    if(i-a[j] >= 0 && !dp[0][i-a[j]]){
      dp[1][i] = true;
    }
  }

  if(dp[0][K]){
    cout << "First" << endl;
  }
  else{
    cout << "Second" << endl;
  }


}


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

using namespace std;
using ll = long long;


int main()
{
    int h, w, a, b; cin >> h >> w >> a >> b;
    vector<vector<int>> g(h, vector<int>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if((i < b && j < a) || (i >= b && j >= a))g[i][j] = 1;
            else g[i][j] = 0;
        }
    }

    for(auto i : g) {
        for(auto j : i)cout << j;
        cout << endl;
    }
}

Measured memory_bytes: 5120
n = gets.chomp.to_i #=> d.size
a = gets.chomp.split(" ").map(&:to_i)
arr = []
a.each do |i|
  arr << [i-1,i,i+1]
end

if a.size == 1
  puts a[0] % 2 == 0 ? "1" : "2"
  exit
end

cp = []
arr.each_with_index do |carr,i|
  if i == 0
    cp = carr
  else
    cp = cp.product(carr)
  end
end

cp.each do |c|
  c.flatten!
end

count = 0
cp.each do |arr|
  if arr.count{|item| item % 2 == 0} > 0
    count += 1
  end
end

puts count

#puts cp.count do |arr|
#  arr.count{|item| item % 2 == 0} > 0
#end


Measured memory_bytes: 22012
def main():

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

    for i in range(N):
        if A[i] % 2 == 0 and (A[i] % 3 != 0 and A[i] % 5 != 0):
            return "DENIED"
    return "APPROVED"

if __name__ == '__main__':
    print(main())


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

int main(){
    int N, z_integer;
    double z, z_decimal;
    cin >> N;
    vector<int> f(N + 1);
    for(int n = 6; n <= N; n++){
        for(int x = 1; x < sqrt(n); x++){
            for(int y = 1; y < sqrt(n); y++){
                if(- 3 * (pow(x, 2) + pow(y, 2)) - 2 * x * y + 4 * n < 0) continue;
                z = (-(y + x) + sqrt(- 3.0 * (pow(x, 2) + pow(y, 2)) - 2.0 * x * y + 4.0 * n)) / 2.0;
                z_integer = z;
                z_decimal = z - z_integer * 1.0;
                if(z_decimal != 0 or z <= 0) continue;
                if(pow(x, 2) + pow(y, 2) + pow(z_integer, 2) + x * y + y * z + z * x == n){
                    f[n]++;
                }
            }
        }
    }
    for(int n = 1; n <= N; n++) cout << f[n] << endl;
}

Measured memory_bytes: 3484
n,k =input().split()
K = int(k)
N = int(n)

s = input()
S =[]
for i in range(len(s)):
    S.append(s[i])

if S[K-1] == 'A':
    S[K-1] = 'a'
if S[K-1] == 'B':
    S[K-1] = 'b'
if S[K-1] == 'C':
    S[K-1] = 'c'

ans = str()
for i in range(len(S)):
    ans += S[i]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<=n;i++)
typedef long long ll;
using namespace std;
int main()
{
  while(true)
  {
     int N;
     cin >> N;
     if(N==0){return 0;}

     vector<pair<int,char> >c(26);
     int res=N;
     rep(i,0,26){
        c[i]=make_pair(0,'A'+i);
     }
     vector<char>v(N);
     rep(i,0,N){
        cin >> v[i];
     }
     rep(i,0,N){
        ++c[v[i]-'A'].first;
        --res;
        int M1=0; int M2=0;
        rep(j,0,26){
           if(M1<c[j].first){
              M2=M1;
              M1=c[j].first;
           }
           else{
              M2=max(M2,c[j].first);
           }
        }
        if(M1>M2+res){
           break;
        }
     }
     sort(c.begin(),c.end(),greater<pair<int,char> >());
     if(c[0].first==c[1].first){
        cout << "TIE" << endl;
     }
     else{
      cout << c[0].second << " " << N-res << endl;
     }
  }
  return 0;
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 1e5+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

int a[maxN];
int main()
{
	ll n;
	cin>>n;
	//n--;
	string ans = "";
//	if(n == 0)
//	{
//		ans = "a";
//		cout<<ans<<endl;
//		return 0;
//	}
	while(n)
	{
		n--;
		int y = n%26;
		ans.push_back('a'+y);
		n /= 26;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] townPlace = new int[N][2];
		for(int i = 0; i<N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			townPlace[i][0] = x;
			townPlace[i][1] = y;
		}
		double totalLength = 0; 
		for( int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) {
				int x1 = townPlace[j][0];
				int y1 = townPlace[j][1];
				int x2 = townPlace[k][0];
				int y2 = townPlace[k][1];
				double length= Math.sqrt((x1 - x2)*(x1 - x2)+(y1 - y2)*(y1 - y2));
				totalLength = totalLength + length;
			}
		}
		
		System.out.println(totalLength/N);	
	}
}

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	string str;
	for (auto i = 0; i < 3; ++i)
	{
		for (auto j = 0; j < 3; ++j)
		{
			char c;
			cin >> c;
			if (i == j)
			{
				str += c;
			}
		}
	}
	cout << str << endl;

	return 0;
}


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

int main(){
  int N;cin >> N;
  vector<ll> A(N);
  vector<ll> B(N,0);
  for(ll i=0;i<N;i++){
    cin >> A[i];
    ll k = i - A[i];
    if(0<=k&&k<N){
      B[k] ++;
    }
  }
  ll sum = 0;
  for(ll i=0;i<N;i++){
    ll s = i + A[i];
    ll k = i - A[i];
    if(0<=k&&k<N){
      B[k] --;
    }
    if(0<=s&&s<N){
      sum += B[s];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,M;
int a[100011];
LL MOD=1e9+7;
LL ans[100011];
map<int,int>m;
int main(){
	cin>>N>>M;
	REP(i,M){
		cin>>a[i];
		m[a[i]]++;
	}
	ans[0]=1;
	if(m.count(1)==0){
		ans[1]=1;
	}
	REP(i,N+1){
		if(i==0)continue;
		if(i==1)continue;
		if(m.count(i)==0){
			ans[i]=ans[i-1]+ans[i-2];
			ans[i]%=MOD;
		}
	}
	cout<<ans[N]<<endl;
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int y, t;
    cin >> y >> t;
    for(int i = 0; i < 21; i++){
        if((y - 1)*i + 1 >= t){
           
            cout << i <<endl;
            break;
        }
        
    }
       return 0;
        
    
        
    
   
    
    
    
    
    
}



Measured memory_bytes: 3536
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static Scanner sc;
    static PrintWriter out;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        out = new PrintWriter(System.out);
        new Main().solve();
        out.flush();
    }

    public void solve() {
        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();


        long res = b * c;
        res = Math.max(res, b * d);
        res = Math.max(res, a * c);
        res = Math.max(res, a * d);

        out.println(res);
    }



}

Measured memory_bytes: 35776
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    ll n,c,x[100010],v[100010];
    ll sum[100010]={},sumr[100010]={};
    ll s1[100010]={},s2[100010]={},r1[100010]={},r2[100010]={};
    ll smax[100010]={},rmax[100010]={};
    cin>>n>>c;
    rep(i,n){
        cin>>x[i]>>v[i];
        sum[i+1]=sum[i]+v[i];
    }
    // cout<<endl;
    // rep(i,n+1)         cout<<sum[i]<<endl;
    // cout<<endl;
    repr(i,n){
        sumr[i]=sumr[i+1]+v[i];
        // cout<<sumr[i]<<endl;
    }
    // cout<<endl;
    rep2(i,1,n+1){
        s1[i]=sum[i]-x[i-1];
        s2[i]=sum[i]-x[i-1]*2;
        // cout<<s1[i]<<" "<<s2[i]<<endl;
    }
    // cout<<endl;
    repr(i,n){
        r1[i]=sumr[i]-(c-x[i]);
        r2[i]=sumr[i]-2*(c-x[i]);
        // cout<<r1[i]<<" "<<r2[i]<<endl;
    }
    // cout<<endl;
    rep2(i,1,n+1){
        smax[i]=max(smax[i-1],s1[i]);
        rmax[i]=max(rmax[i-1],r1[n-i]);
        // cout<<smax[i]<<" "<<rmax[i]<<endl;
    }
    // cout<<endl;
    ll ans1=0,ans2=0,ans3=0;
    ans1=max(smax[n],rmax[n]);
    // cout<<ans1<<endl;
    rep2(i,1,n+1){
        ans2=max(ans2,s2[i]+rmax[n-i]);
        // cout<<ans2<<endl;
    }
    // cout<<endl;
    rep(i,n){
        ans3=max(ans3,r2[i]+smax[i]);
        // cout<<ans3<<endl;
    }
    // cout<<endl;
    ans1=max(max(ans2,ans3),ans1);
    cout<<ans1<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;

int work() {
	int a=rd(), k=rd(), lim=sqrt(a);
	while(a/k>lim&&a%k!=0) a-=a/k+1;
	while(a%k!=0) {
		a-=a/k+1;
		a-=a%k/(a/k+1)*(a/k+1);
	}
	return a/k;
}
int main() {
	int n=rd(), ans=0;
	while(n--) ans^=work();
	puts(ans?"Takahashi":"Aoki");
	return 0;
}


Measured memory_bytes: 256
#include<iostream> 

using namespace std;

int main()
{
	int a;
	cin>>a;
	int ans=a%10;
	if(ans==3)
	{
		cout<<"bon"<<endl;
	}
	else if(ans==0||ans==1||ans==6||ans==8)
	{
		cout<<"pon"<<endl;
	}
	else
	{
		cout<<"hon"<<endl;
	}

return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long int H;
    cin>>H;
    int count=0;
    while(H>1){
        H=H/2;
        count++;
    }
    long int ans=1;
    for(int i=0;i<count;i++){
        ans=(2*ans)+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m %= n, n);
  return m;
}

int main() {
  intmax_t a, b;
  scanf("%jd %jd", &a, &b);

  intmax_t g = gcd(a, b);

  int res = 1;
  for (intmax_t i = 2; i*i <= g; ++i) {
    if (g % i != 0) continue;
    ++res;
    do g /= i; while (g % i == 0);
  }
  if (g > 1) ++res;
  printf("%d\n", res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    string s;cin >> s;
    int a=0;
    REP(i, s.size()){
        if(s[i]=='o')a++;
    }
    a += 15 - s.size();
    YES(a>=8);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,m;
  scanf("%d %d",&n,&m);
  int ans=0;
  if(n>=2)
  {
    ans+=(n*(n-1))/2;
  }
  if(m>=2)
  {
    ans+=(m*(m-1))/2;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
      	int n = sc.nextInt();
		int d[] = new int[n];
      	int sum = 0;
      
      	for(int i = 0;i < n;i++){
        	d[i] = sc.nextInt();
        }
      
      	for(int i = 0; i < n;i++){
          for(int j = i+1;j < n;j++) sum += d[i]*d[j];
        }
      
      	System.out.println(sum);
	}
}

Measured memory_bytes: 35700
import sys
input = sys.stdin.buffer.readline
import copy

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    MOD = 10**9+7
    A.sort()
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD
        
    def coef(x,y):
        num = (((fac[x]*invfac[y])%MOD)*invfac[x-y]%MOD)
        return num

    up = 0
    down = 0
    for i in range(K-1,N):
        up += A[i]*coef(i,K-1)
        down += A[i-(K-1)]*coef(N-i+K-2,K-1)

    print((up-down)%MOD)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 19824
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
using namespace std;


int main(){
  int h,w;
  cin >>h>>w;
  string s[60];
  for(int i=0; i<h;i++)
  cin >>s[i];
  string ss[60];
  int dx[8]={1,0,-1,0,1,-1,-1,1};
  int dy[8]={0,1,0,-1,1,1,-1,-1};
  for(int i=0; i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='#') continue;
      int num=0;

        for(int k=0;k<8;k++){
        int ni=i+dy[k];
        int nj=j+dx[k];

        if(ni<0 || h<=ni) continue;
        if(nj<0 || w<=nj) continue;

        if(s[ni][nj]=='#') num++;
      }
      s[i][j]=char(num+'0');
    }}
    for (int i=0 ; i<h;i++) cout<<s[i] <<endl;

  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, M;
    cin >> N >> M;
    if(M == N)  cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  VI v(n);
  VI c(n);
  rep(i,n) cin >> v.at(i);
  rep(i,n) cin >> c.at(i);
  int x=0;
  int y=0;
  rep(i,n){
    if(v.at(i)>c.at(i)){
      x+=v.at(i);
      y+=c.at(i);
    }
  }
  cout << x-y << endl;
}

Measured memory_bytes: 256
import java.util.*;


public class Main{
    public static void main(String [] args){
        Scanner sc=new Scanner(System.in);
        int H=sc.nextInt();
        int A=sc.nextInt();
        int rem=H%A;
        int div=H/A;
        if(rem==0)System.out.println(div);
        else System.out.println(div+1);
    
    }
}
      

Measured memory_bytes: 21716
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

    string S;
    cin >> S;

    const string abc = "ABC";
    int ans = 0;
    for (int i = 0; i < N; i++) {
        string str = S.substr(i, 3);
        if (str == abc) {
            ans++;
            i += abc.size() - 1;
        }
    }

    cout << ans << endl;

    return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

// ????????´??°, ???????????§

/*
const int DATA_NIL = 0;
template <class T>
class SegmentTree {
private:
    const int n;
    vector<T> dat;
    void prop_to(int i) { dat[i] = max(dat[i<<1], dat[i<<1|1]); }

public:
    SegmentTree(int _n) : n(_n), dat(2*n, DATA_NIL) {}

    void fill(int l, int r, T x)
    {
        l += n, r += n;
        for (; l<r; l >>= 1, r >>= 1) {
            if (l & 1) dat[l++] += x;
            if (r & 1) dat[r-1] += x;
        }
    }

    T get(int i)
    {
        T res = dat[i += n];
        while (i >>= 1) { res += dat[i]; }
        return res;
    }

    void push()
    {
        for (int i=1; i<n; i++) {
            dat[i<<1] += dat[i];
            dat[i<<1|1] += dat[i];
            dat[i] = DATA_NIL;
        }
    }

    void dump()
    {
        cerr << "-----------" << endl;
        int h = __lg(2*n);
        for (int i=1; i<=h; i++) {
            for (int j=0; j<1<<(i-1); j++) cerr << dat[(1<<(i-1)) + j].second << " ";
            cerr << endl;
        }
        cerr << "-----------" << endl;
    }
};
*/

// ????????´??°, ???????????§
template<class Monoid>
class SegmentTree {
private:
    using T = typename Monoid::T;
    Monoid op;
    const int n;
    vector<T> dat;
    void prop_to(int i) { dat[i] = op(dat[2*i], dat[2*i+1]); }

public:
    SegmentTree(int _n) : n(_n), dat(2*_n, op.identity()) {}
    SegmentTree(const vector<T> &v) : n(v.size()), dat(2*n)
    {
        copy(v.begin(), v.end(), dat.begin() + n);
        for (int i=n-1; i>0; i--) prop_to(i);
    }

    T get(int i)
    {
        T res = dat[i += n];
        while (i >>= 1) res = op(res, dat[i]);
        return res;
    }

    void update(int l, int r, const T &x) // [l, r)
    {
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) {dat[l] = op(dat[l], x); l++; }
            if (r & 1) {dat[r-1] = op(x, dat[r-1]); }
        }
    }
};

struct RSQ {
    using T = int;
    T operator() (const T &a, const T &b) { return a + b; }
    static constexpr T identity() { return 0; }
};

int main()
{
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;
    SegmentTree<RSQ> seg_tree(N);

    rep(q, Q) {
        int T; cin >> T;
        if (T == 0) {
            int A, B, X; 
            cin >> A >> B >> X;
            A--, B--;
            seg_tree.update(A, B+1, X);
        } else {
            int I; cin >> I;
            I--;
            cout << seg_tree.get(I) << endl;
        }
    }
}

Measured memory_bytes: 3568
import sys
n,m,x,y =  list(map(int,input().split()))
xxx =  list(map(int,input().split()))
yyy =  list(map(int,input().split()))
if x < y:
  for i in range(x+1,y):
    if max(xxx) < i <= min(yyy):
      print("No War")
      sys.exit()
print("War")

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }





int main() {
	vci p, s;
	
	int p_, s_; char c;
	while (cin >> p_ >> c >> s_) {
		p.pb(p_); s.pb(s_);
	}
	
	int sum = 0, avg = 0, n = (int)s.sz;
	for_(i, 0, n) {
		sum += p[i]*s[i];
		avg += s[i];
	}
	
	cout << sum << endl;
	cout << (int)((double)avg/(double)n + 0.5) << endl;
	
	return 0;
}

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

int dn(int n){
    int cnt=0;
    for(int i=1; i<=n; i++){
        if(!(n%i)) cnt++;
    }
    return cnt;
}

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    for (int i = 1; i <= N; i++){
        if(dn(i) == 8 && i%2) cnt++;
    }
    
    cout << cnt << endl;
}   

Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

K = ni()
S = ns()
if len(S)<= K:
    print(S)
else:
    print(S[0:K]+'...')


Measured memory_bytes: 9188
// Peace Of SHIT
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 5;
int n, si[maxn];
int sum = 0;
vector<int> e[maxn];
pii d[maxn];

void impossible() {
	cout << -1;
	exit(0);
}

void dfs(int u, int x) {
	sum += x;
	for(int i = 0; i < e[u].size(); i++) {
		dfs(e[u][i], x + 1);
	}
}

int32_t main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		int a;
		cin >> a;
		d[i] = {a, i};
	}
	sort(d, d + n);
	reverse(d, d + n);
	
	vector <pii> k (d, d + n);
	
	for(int q = 0; q < n - 1; q++) {
		int leaf = d[q].second;
		int parD = d[q].first - (n - (2 * (si[leaf] + 1)));
		auto it = lower_bound(k.rbegin(), k.rend(), pii(parD, 0));
//		cout << "PAR : " <<it->first << " : " << parD << '\n';
		if(it -> first != parD) {
//			cerr << "AVALI\n";
			impossible();
		}
		int par = it -> second;
		si[par] += si[leaf] + 1;
		if((si[leaf] + 1) * 2 > n) {
//			cout << "DOVOMI\n";
			impossible();
		}
		//SEVOMI HAM MISHE D[I] ROOT OK E ?
		e[par].push_back(leaf);
	}
	int D = d[n - 1].second;
	dfs(D, 0);
	if(sum != d[n - 1].first)
		impossible();
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < e[i].size(); j++)
			cout << i + 1 << " " << e[i][j] + 1 <<'\n';
	}
	return 0;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
  int d;
  cin >>d;
  Vi ans(d,0);
  Vi c(26,0);
  rep(i,26){
    cin>>c[i];
  }
  VVi s(d,Vi(26,0));
  rep(i,d){
    rep(j,26){
      cin>>s[i][j];
    }
  }
  int up=1;
  int val=-INF;
  rep(i,d){
    val=-INF;
    rep(j,26){
      if(chmax(val,s[i][j])){
        up=j;
      }
    }
    ans[i]=up;
  }
  rep(i,d){
    cout<<ans[i]+1<<endl;
  }
  
}

Measured memory_bytes: 3680
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        for (int i = n; i <= 999; i++) {
            if (i % 111 == 0) {
                System.out.println(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 21716
//ソートを導入
using System;

namespace tst
{
    class Program
    {
        public static void Quicksort(int[] A, int p, int r)
        {
            if (p < r)
            {
                //対象の部分配列を前後二つの部分配列に分割（Divide）
                int q = Partition(A, p, r);
                //前方の部分配列についてソート
                Quicksort(A, p, q - 1);
                //後方の部分配列についてソート
                Quicksort(A, q + 1, r);
            }
        }
        public static int Partition(int[] A, int p, int r)
        {
            int x = A[r];
            int i = p - 1;
            for (int j = p; j < r; j++)
            {
                if (A[j] <= x)
                {
                    i++;
                    int temp = A[i];
                    A[i] = A[j];
                    A[j] = temp;
                }
            }
            int temp2 = A[i + 1];
            A[i + 1] = A[r];
            A[r] = temp2;
            return i + 1;
        }
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for(int i=0; i<n; i++)
            {
                A[i] = int.Parse(In[i]);
            }
            Quicksort(A, 0, n - 1);
            bool flag = true;
            for(int i=0; i<n-1; i++)
            {
                if (A[i] == A[i + 1])
                {
                    flag = false;
                    break;
                }
            }
            if (flag) { Console.WriteLine("YES"); }
            else { Console.WriteLine("NO"); }
        }
    }
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

int N, A, B, C, D;
string s;

bool check() {
  if (C < D) {
    for (int i = A; i < C; i++) {
      if (s.at(i) == '#' && s.at(i+1) == '#') return false;
    }
    for (int i = B; i < D; i++) {
      if (s.at(i) == '#' && s.at(i+1) == '#') return false;
    }
    return true;
  }else {
    for (int i = A; i < C; i++) {
      if (s.at(i) == '#' && s.at(i+1) == '#') return false;
    }
    for (int i = B; i <= D; i++) {
      if (s.at(i-1) == '.' && s.at(i) == '.' && s.at(i+1) == '.')  return true;
    }
    return false;
  }
}

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> A >> B >> C >> D >> s;
  A--;
  B--;
  C--;
  D--;
  cout << (check() ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 592
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
//include<kyawa>


//--------------------

int main() {

	long N, A, B; cin >> N >> A >> B;
	long res;

	res = A + B * (N - 1) - (A * (N - 1) + B) + 1;

	if (N == 1) res = 0;
	if (N == 2) res = 1;
	if (A > B) res = 0;
	if (A == B) res = 1;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    int N;
    cin >> N;
    float a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    float bunbo = 0;
    for (int i = 0; i < N; i++) {
        bunbo += 1/a[i];
    }

    cout << (1/bunbo);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    for(int i = 0; i<n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int next = 0;
    ll s = 0;
    for(int i = 0; i<n; i++){
        s += a[i];
        next = i;
        if(s>sum/2)
            break;
    }
    
    ll dist = min(2*s-sum, sum - 2*(s-a[next]));
    cout << dist << endl;
    // int cost = dist/2;
    // if(dist%2!=0)
    //     cost += 1;
    // cout << cost << endl;
   return 0;
}

Measured memory_bytes: 1024
import string
abc = string.ascii_uppercase

while True:
  s = input()
  if s==".":
    break

  num = 0
  rev = 0
  nest = ["" for i in range(80)]

  for e in s:
    if e=="+":
      num += 1
    elif e=="-":
      num -= 1
    elif e=="[":
      rev += 1
    elif e=="]":
      t = nest[rev]
      nest[rev-1] += t[::-1]
      nest[rev] = ""
      rev -= 1
    elif e=="?":
      nest[rev] += "A"
      num = 0
    else:
      t = abc[(ord(e)+num-65)%26]
      nest[rev] += t
      num = 0
  print(nest[0])


Measured memory_bytes: 6680
import sys
import itertools
from functools import reduce
import math
import fractions
#import numpy as np


def calc_double(n):
    return n//2

def calc_num(n):
    c=0
    while n%2==0: #evenなら
        n=n//2
        c+=1
    return c


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    #AA=[0 for i in range(N)]    
    AA=list(map(calc_double,A))

    calAA=list(map(calc_num,AA))
    if all([True if calAA[0]==calAA[i] else False for i in range(N)])==False:
        print(0)
        return

    
    """
    for i in range(N):
        buf=A[i]//2
        if buf%2==0:
            print("0")
            return
        AA[i]=buf
    """

    a=lcm_list(AA)
    

    odd=M//a
    count=(odd+1)//2

    print(count)

    

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

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

int main() {
  int n,ans = 0;
  cin >> n;
  unordered_map<std::string, int> mp;
  rep(i,n){
    string s;
    cin >> s;
    auto itr = mp.find(s);        // "xyz" が設定されているか？
    if( itr != mp.end() ) {
        continue;
    } else {
        ans++;
        mp[s] = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 17704
n = gets.to_i

points = []

color = {}

n.times do
  r = gets.split(" ").map(&:to_i)
  color[r[0]] = "red"
  points << r
end

n.times do
  b = gets.split(" ").map(&:to_i)
  color[b[0]] = "blue"
  points << b
end

points.sort!{|a,b| a[1] <=> b[1]}

pending = []
count = 0

(n*2).times do |i|
  if color[points[i][0]] == "red"
    pending << points[i]
  else
    next if pending.empty?
    hoge = pending.sort{|a,b| b[0] <=> a[0]}
    flg = false
    hoge.each do |h|
      if !flg && h[0] < points[i][0]
        pending -= [h]
        count += 1
        flg = true
      end
    end
  end
end

puts count

Measured memory_bytes: 3836
import fileinput


def knapsack(capacity, item_weights, item_values):
    no_current_item_values = [0] * (capacity + 1)
    for i, val in enumerate(item_values):
        with_current_item_values = [0] * (capacity + 1)
        for current_capacity in range(1, capacity + 1):
            if current_capacity < item_weights[i]:
                with_current_item_values[current_capacity] = no_current_item_values[current_capacity]
            else:
                with_current_item_values[current_capacity] = max(
                    no_current_item_values[current_capacity],
                    no_current_item_values[current_capacity - item_weights[i]] + val
                )
        no_current_item_values = with_current_item_values

    return no_current_item_values[-1]


inp = fileinput.input()

first_line_split = inp.readline().split(" ")

item_count = int(first_line_split[0])
capacity = int(first_line_split[1])

item_weights = []
item_values = []
for _ in range(item_count):
    split = inp.readline().split(" ")
    item_weights.append(int(split[0]))
    item_values.append(int(split[1]))

print(knapsack(capacity, item_weights, item_values))

Measured memory_bytes: 117360
N, M = map(int, input().split())
suki_list = list(map(int, input().split()))
suki_list = suki_list[1:]
suki_set = set(suki_list)
for i in range(N-1):
    suki_list = list(map(int, input().split()))
    suki_list = suki_list[1:]
    remove_list = []
    for num in suki_set:
        if num not in suki_list:
            remove_list.append(num)
    for i in remove_list:
        suki_set.remove(i)

print(len(suki_set))

Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int d[100005],m[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&d[i]);
	for(int i=1;i<=n;i++){
		if(i&1) m[1]+=d[i];
		else m[1]-=d[i];
	}
	for(int i=2;i<=n;i++) m[i]=d[i-1]*2-m[i-1];
	for(int i=1;i<=n;i++) printf("%d ",m[i]);
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
typedef vector<int> vi;
set<string> cands;
int dy[]={-1,-1,-1,0,0,1,1,1};
int dx[]={-1,0,1,-1,1,-1,0,1};
int maxlength=0,h,w;
string ans="";
void check(int y,int x,string *board)
{
  for(int k=0;k<8;k++)
  {
    bool visited[h][w];
    memset(visited,false,sizeof(visited));
    int yy=y,xx=x;
    string str="";
    while(!visited[yy][xx])
    {
      str+=board[yy][xx];
      if(cands.find(str)!=cands.end())
      {
				int str_len=str.length();
				if(maxlength<str_len)
				{
	  			ans=str;
					maxlength=str_len;
				}
				else if(maxlength==str_len && str<ans)
				{
	  			ans=str;
					maxlength=str_len;
				}
      }
      else
      {
				cands.insert(str);
      }
      visited[yy][xx]=true;
      yy=(yy+dy[k]+h)%h;
      xx=(xx+dx[k]+w)%w;
    }
  }
}

int main()
{
  while(1) 
  {
    cin >> h >> w;
    if(h==0) break;
    string board[h];
    cands.clear();
    for(int i=0;i<h;i++)
    {
      cin >> board[i];
    }
    maxlength=0;
    ans="0";
    for(int i=0;i<h;i++)
    {
      for(int j=0;j<w;j++)
      {
				check(i,j,board);
      }
    }
    if(maxlength>=2)
    {
      cout << ans << endl;
     }
    else
    {
      cout << "0" << endl;
    }
  }
}


Measured memory_bytes: 35668