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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int num;
    set<int> s;
    scanf("%d", &num);

    for(int i=0; i<num; i++){
        int a; cin >> a;
        s.insert(a);
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
bingo_card = []
for _ in range(3):
  bingo_card.extend(input().split())
  
N = int(input())

for _ in range(N):
  value = input()
  if value in bingo_card:
    bingo_card[bingo_card.index(value)] = '*'
    
row1 = bingo_card[0] + bingo_card[1] + bingo_card[2]
row2 = bingo_card[3] + bingo_card[4] + bingo_card[5]
row3 = bingo_card[6] + bingo_card[7] + bingo_card[8]
col1 = bingo_card[0] + bingo_card[3] + bingo_card[6]
col2 = bingo_card[1] + bingo_card[4] + bingo_card[7]
col3 = bingo_card[2] + bingo_card[5] + bingo_card[8]
dgn1 = bingo_card[0] + bingo_card[4] + bingo_card[8]
dgn2 = bingo_card[2] + bingo_card[4] + bingo_card[6]

bingo = '***'
if any([
  row1 == bingo,
  row2 == bingo,
  row3 == bingo,
  col1 == bingo, 
  col2 == bingo,
  col3 == bingo,
  dgn1 == bingo,
  dgn2 == bingo
]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, char *argv[]){

  for(;;){
    int count = 0;
    int n;
    scanf("%d", &n);

    if(n == 0){
      break;
    }

    while(n != 1){
      if(n % 2 == 0){
	n /= 2;
      }else{
	n = n*3 + 1;
      }
      count++;
    }

    printf("%d\n",count);
    
  }
  
  return 0;    
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int LLI;
 
int solution(int arr[], int & n)
{
	int sum = 1;
	sort(arr,arr+n);
	for(int i = 0; i < n-1; i++)
		if( arr[i] != arr[i+1] )
			sum++;
	return sum;
}
int main()
{
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	cout << solution(arr,n);
}

Measured memory_bytes: 3628
import sys

a = list(input())
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i % 2 == 0:
                sym1 = '+'
            else:
                sym1 = '-'
            if j % 2 == 0:
                sym2 = '+'
            else:
                sym2 = '-'
            if k % 2 == 0:
                sym3 = '+'
            else:
                sym3 = '-'
            word = a[0] + sym1 + a[1] + sym2 + a[2] + sym3 + a[3]

            ans = eval(word)
            if ans == 7:
                print(word+'=7')
                sys.exit()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
#include <queue>
#include <cstdio>
#include <deque>
#include <map>
#define fol(i,n) for(int i=0;i<n;i++)
#define db(a) cout << a<< endl;
using namespace std;

int main(){
    int n,a,b;
    string s;
    cin >> n >> a>> b>>s;
    int ps=a+b;
    fol(i,n){
        if (s[i]=='a'||s[i]=='b'){
            if (s[i]=='a'){
                if (ps!=0) {cout << "Yes" <<endl;ps--;}
                else cout << "No" <<endl;
            }else{
                if (ps!=0&&b!=0) {cout << "Yes" <<endl;b--;ps--;}
                else cout << "No" <<endl;
                }
        }
        else cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 896
<?php

fscanf(STDIN,"%d",$n);

$num = 0;
$count = 0;

//N以下の整数を配列にする
for ($i = $n; $i >= 1; $i--) {
    $num++;
    if (strlen($num) % 2 == 1) {
        $count++;
    }
}

echo $count;


Measured memory_bytes: 3576
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

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

#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--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	static int dp[1010][1010] = {};
	for (int n; cin >> n&&n;) {
		memset(dp, 0, sizeof(dp));
		REP(i, n)REP(j, n) {
			char c; cin >> c;
			if (c == '*')dp[i][j] = 0;
			else if (i == 0 || j == 0)dp[i][j] = 1;
			else dp[i][j] = min({ dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] }) + 1;
		}
		int ans = 0;
		REP(i, n)REP(j, n) {
			ans = max(dp[i][j], ans);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7092
import itertools
import math

n, d = map(int, input().split())
l = []
for _ in range(n):
    l.append(list(map(int, input().split())))

ll = [i for i in range(n)]
count = 0
for a1, a2 in itertools.combinations(ll, 2):
    # print(a1)
    # print(a2)
    
    sum_v = 0
    for i in range(d):
        sum_v += (l[a1][i] - l[a2][i]) ** 2
        
    dist = math.sqrt(sum_v)
    if dist == int(dist):
        # print(dist)
        count += 1
        
print(count)

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

int main(){
	string w;
	cin >> w;
	map<char,int> m;
	for(auto c:w) m[c]++;
	for(auto itr = m.begin();itr != m.end();itr++) if(itr->second & 1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long A,B;
int main(){
	scanf("%lld%lld",&A,&B);
	printf("%s\n",(max(A,B)-min(A,B))>1? "Alice":"Brown");
	return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {

	var s string
	var a_index = -1
	var z_index = -1

	fmt.Scanln(&s)
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' && a_index == -1 {
			a_index = i
		} else if s[i] == 'Z' {
			z_index = i
		}
	}

	fmt.Println(z_index - a_index + 1)

}

Measured memory_bytes: 2048
#include<stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    N = N % 10;
    if(N == 3) printf("bon");
    else {if(N == 0|| N == 1 || N == 6|| N == 8) printf("pon");
        else printf("hon");}
    
    return 0;

}


Measured memory_bytes: 1700
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n : usize = iter.next().unwrap().parse().unwrap();
    let k : usize = iter.next().unwrap().parse().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut s: Vec<char> = s.trim().chars().collect();
    s[k-1] = s[k-1].to_ascii_lowercase();
    print!("{}", s.iter().collect::<String>())
}

Measured memory_bytes: 2068
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using namespace atcoder;
using namespace boost::multiprecision;
using ll = long long;
using S = long long;
using F = long long;
const S INF = 8e18;

S op(S a, S b){ return std::max(a, b); }
S e(){ return -INF; }
S mapping(F f, S x){ return f+x; }
F composition(F f, F g){ return f+g; }
F id(){ return 0; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int MAX = 0;
    rep(i, n) {
        cin >> a[i];
        MAX = max(MAX, a[i]);
    }
    vector<S> v(MAX+2);
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    seg.set(a[0], 1);
    for (int i = 1; i < n; i++) {
        seg.set(a[i], seg.prod(max(0, a[i] - k), min(MAX+1, a[i] + k + 1))+1);
    }
    cout << seg.all_prod() << endl;
    // puts("===");
    // rep(i, MAX) {
    //     cout << seg.get(i) << endl;
    // }
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

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

int main(){
    int N;
    cin >> N;
    int w[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> w[i];
        sum += w[i];
    }
    int count = 0;
    int tmp = INT_MAX;
    for(int i = 0; i < N; i++){
        count += w[i];
        int ans = abs(sum - count*2);
        tmp = min(ans, tmp);
    }
    cout << tmp << endl;
}

Measured memory_bytes: 256
/*-- ILSH  --*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
//const ll mod =1e9+7;
const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


const ll N = 2e5+5;

void solve(){
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<'\n';

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
//	#ifndef ONLINE_JUDGE
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif

	int t=1;

	//cin>>t;

	for ( int i=1;i<=t;i++){
   // 	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3652
#include <stdio.h>
int main()
{
 int h,w,i,j;
 scanf("%d %d",&h,&w);
 while(h!=0 || w!=0)
 {
  for(i=0;i<h;i++)
  {
   for(j=0;j<w;j++)
   {
    if((i+j)%2==0)
     printf("#");
    else
     printf(".");
   }
   printf("\n");
  }
  printf("\n");
  scanf("%d %d",&h,&w);
 }
}
  


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

int main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy" << endl;
	} else if (s == "Cloudy") {
		cout << "Rainy" << endl;
	} else {
		cout << "Sunny" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- Coding: utf-8 -*-
import sys

L = [input()]
L = sorted(list(map(int,input().split())), key= lambda x: -x)
test = lambda L, S=0, f=lambda f, L, S : f(f,L[2:],S+L[1]) if L else print(S): f(f, L, S)
test(L)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int costb[2001][2001] = {}; int costw[2001][2001] = {};
int dp[2001][2001];
int main() {
	int n; cin >> n;
	int b[4000]; int w[4000]; int invb[2000], invw[2000];
	fill(b, b + 2*n, -1);
	fill(w, w + 2*n, -1);
	rep(i, 2*n) {
		char t; cin >> t;
		if (t == 'B') {
			cin >> b[i]; b[i]--;
			invb[b[i]] = i;
		}
		else if (t == 'W') {
			cin >> w[i]; w[i]--;
			invw[w[i]] = i;
		}
	}
	rep(i, n) {
		int x = invb[i];
		int cnt = 0;
		rep(j, x) {
			if (b[j] > i)cnt++;
		}
		rep(j, x) {
			if (w[j] < 0)continue;
			costb[i][w[j]]++;
		}
		per(j, n-1) {
			costb[i][j] += costb[i][j + 1];
		}
		rep(j, n) {
			costb[i][j] += cnt;
		}
		x = invw[i];
		cnt = 0;
		rep(j, x) {
			if (w[j] > i)cnt++;
		}
		rep(j, x) {
			if (b[j] < 0)continue;
			costw[i][b[j]]++;
		}
		per(j, n-1) {
			costw[i][j] += costw[i][j + 1];
		}
		rep(j, n) {
			costw[i][j] += cnt;
		}
	}
	rep(i, n) {
		int x = invb[i];
		rep(j, x) {
			if (b[j] > i)costb[i][n]++;
		}
		x = invw[i];
		rep(j, x) {
			if (w[j] > i)costw[i][n]++;
		}
	}
	dp[0][0] = 0;
	rep(i, n+1) {
		rep(j, n+1) {
			if (i == 0 && j == 0)continue;
			int nex = 1e+9;
			if (i > 0) {
				nex = min(nex,dp[i - 1][j] + costb[i-1][j]);
			}
			if (j > 0) {
				nex = min(nex,dp[i][j - 1] + costw[j-1][i]);
			}
			dp[i][j] = nex;
		}
	}
	cout << dp[n][n] << endl;
	stop
	return 0;
}

Measured memory_bytes: 47232
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359
 
int main() {
  ll N, A;
  cin >> N;
  map<ll, ll> count;
  ll ret = 0;
  for (auto i = 0; i < N; i++) {
    cin >> A;
    auto it = count.find(i - A);
    if (it != count.end()) {
      ret += it->second;
    }
    it = count.find(i + A);
    if (it != count.end()) {
      it->second ++;
    } else {
      count[i + A] = 1;
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 15996
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll a(n);
    ll x = 0;
    REP(i,n){
        cin >> a[i];
        x = (x^a[i]);
    }
    REP(i,n){
        ll ret = (x^a[i]);
        cout << ret << ((i==n-1)?("\n"):(" "));
    }

    return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; int ans=0;
    int B[N-1]; rep(i,N-1) cin >> B[i];
    rep(i,N){
        if(!i) ans+=B[i];
        else if(i==N-1) ans+=B[N-2];
        else ans+=min(B[i-1],B[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    #int(sys.stdin.readline())
    #s = sys.stdin.readline().rstrip()
    N, K = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    P.sort()
    print(sum(P[0:K]))




if __name__=='__main__':
    main()

Measured memory_bytes: 9248
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run() {

		for (;;) {

			int n = sc.nextInt();

			if (n == 0)

				break;

			boolean na = true;

			int[] order = new int[n];

			BigInteger[] map = new BigInteger[4001];

			boolean[] end = new boolean[4001];

			for(int i =0;i<4001;i++){

				map[i] = new BigInteger("0");

			}

			for (int i = 0; i < n; i++) {

				int b = sc.nextInt();

				long at = sc.nextLong();

				long p = sc.nextLong();

				map[b] = map[b].add(BigInteger.valueOf(at * p));

				order[i] = b;

			}



			for (int i = 0; i < n; i++) {

				if (order[i] != 0) {

					int e = order[i];

					if (!end[e]) {

						if (map[e].compareTo(BigInteger.valueOf(1000000))>=0) {

							end[e] = true;

							na = false;

							System.out.println(e);

						}

					}

				}

			}

			if (na)

				System.out.println("NA");

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var hash = new HashSet<char>();

            // 文字列の入力
            string s = Console.ReadLine();

            string result = "yes";

            foreach (var c in s) {
                if (hash.Contains(c)) {
                    result = "no";
                    break;
                }

                hash.Add(c);
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13280
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, M = map(int, input().split())
if N == 1 or N == 0:
    N_ans = 0
else:
    N_ans =combinations_count(N, 2)
if M == 1 or M == 0:
    M_ans = 0
else:
    M_ans = combinations_count(M, 2)

ans = N_ans + M_ans

print(str(ans))


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll H, W;
    string s[101];
    ll dp[101][101];
    cin>>H>>W;
    rep(i, H) cin>>s[i];
    rep(i, H) rep(j, W) dp[i][j]=H*W*10;
    if(s[0][0]=='#') dp[0][0]=1;
    else dp[0][0]=0;
    rep(i, H) rep(j, W){
        //cout<<i<<sp<<j<<sp<<s[i][j]<<endl;
        if(i<H-1){
            int fl=0;
            if(s[i][j]=='.' && s[i+1][j]=='#') fl=1;
            //cout<<fl<<endl;
            dp[i+1][j]=min(dp[i+1][j], dp[i][j]+fl);
        }
        if(j<W-1){
            int fl=0;
            if(s[i][j]=='.' && s[i][j+1]=='#') fl=1;
            //cout<<fl<<endl;
            dp[i][j+1]=min(dp[i][j+1], dp[i][j]+fl);
        }
        
        //rep(i, H){ rep(j, W) cout<<dp[i][j];cout<<endl;}
    }
    cout<<dp[H-1][W-1]<<endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
  "fmt"
)

func kaibun(str string) bool {
  N := len(str)
  h := int(N / 2)
  for i := 0; i < h; i++ {
    c0, c1 := str[i], str[N-i-1]
    if c0 != c1 {
      return false
    }
  }
  return true
}

func main() {
  var str string
  fmt.Scanf("%s\n", &str)
  
  if !kaibun(str) {
    fmt.Println("No")
    return
  }
  
  if !kaibun(str[:(len(str)-1)/2]) {
    fmt.Println("No")
    return
  }
  
  fmt.Println("Yes")
}

Measured memory_bytes: 512
pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let a: i64 = rd.get();
    let b: i64 = rd.get();
    let c: i64 = rd.get();
    let d: i64 = rd.get();

    let mut ans = std::cmp::max(a * c, a * d);
    ans = std::cmp::max(ans, b * c);
    ans = std::cmp::max(ans, b * d);
    println!("{}", ans);
}

Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;
ll mod=1000000007;

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

	double N;
	cin>>N;
	vector<double> A(N);
	for(int i=0;i<N;i++) cin>>A[i];
	double sum=0;
	for(int i=0;i<N;i++){
		sum+=1/A[i];
	}
	double Ans=1/sum;
	cout<<setprecision(16)<<Ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>
 
#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;
 
const ll inf = 1LL << 60;
 
template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll N;
    cin >> N;
 
    ll ans = 0;
    map<ll, ll> cnt;
    for (ll x = 1; x <= 200; x++) {
        for (ll y = 1; y <= 200; y++) {
            for (ll z = 1; z <= 200; z++) {
                cnt[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }
 
    for (ll i = 1; i <= N; i++) {
        cout << cnt[i] << "\n";
    }
}

Measured memory_bytes: 14076
N,M = map(int,input().split())
src = list(map(lambda x:int(x)-1,input().split()))

imos = [0] * (2*M+1)
ends = [0] * (2*M+1)
max_press = 0
for a,b in zip(src,src[1:]):
    if a > b:
        b += M
    if b-a > 1:
        imos[a+2] += 1
        imos[b+1] -= 1
        ends[b+1] += b-a-1
    max_press += b-a

for i in range(2*M):
    imos[i+1] += imos[i]

press = [max_press] * M
d = 0
for i,(dec,inc) in enumerate(zip(imos, ends)):
    d += inc - dec
    press[i%M] += d
print(min(press))

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

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> sum(n+1,0);
    for(ll i=1; i<=n;i++){
        ll p;
        cin >> p;
        sum.at(i) = sum.at(i-1)+p;
    }
    ll max=0;
    rp(i,n-k+1){
        if(max<sum.at(k+i)-sum.at(i))
        max=sum.at(k+i)-sum.at(i);
    }

    cout <<fixed << setprecision(12)<< (( long double)max+(long double)k)/(long double)2.0 << endl;

    return 0;
}

Measured memory_bytes: 1792
N, A, B = gets.split.map(&:to_i)
S = gets.chomp

qualifier_cnt = 0
foreigner_cnt = 0

S.each_char do |s|
  case s
  when 'a'
    if qualifier_cnt < A + B
      qualifier_cnt += 1
      puts 'Yes'
    else
      puts 'No'
    end
  when 'b'
    if qualifier_cnt < A + B && foreigner_cnt < B
      qualifier_cnt += 1
      foreigner_cnt += 1
      puts 'Yes'
    else
      puts 'No'
    end
  when 'c'
    puts 'No'
  end
end


Measured memory_bytes: 2428
l = list(int(i) for i in input().split())

if l[1]-l[0]+1 < 2*l[2]:
    for i in range(l[1]-l[0]+1):
        print("%d" % (i+l[0]))
else:
    for i in range(l[2]):
        print("%d" % (l[0]+i))
    for i in range(l[2]):
        print("%d" % (l[1]-l[2]+1+i))

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

using namespace std;

int main(int argc, const char * argv[]) {
    
    string b;
    cin >> b;
    
    if (b== "A")
    {
        cout << "T" << endl;
    }
    else if (b == "T")
    {
        cout << "A" << endl;
    }
    else if (b== "C")
    {
        cout << "G" << endl;
    }
    else if (b == "G")
    {
        cout << "C" << endl;
    }
    
    
    return 0;
}

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

int rec(int n, int k, int s) {
  
  if(k == 0) {
    if(s == 0) return 1;
    else return 0;
  }
  
  if(s < 0) return 0;
  
  int res = 0;
  for(int i=n; i>=1; i--) {
    res += rec(i-1, k-1, s-i);
  }
  
  return res;
}

int main() {
  int n, k, s;
  while(cin >> n >> k >> s, (n|k|s)) {
    cout << rec(n, k, s) << endl;
  }
  
  return 0;
}

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

int main () {
int K,N,i,j,k;
cin >> K >> N;
vector <int> A(N);
for (i = 0; i < N; i++) {
cin >> A[i];
}
  int min = K - A[N-1] +A[0] ;
vector <int> B(N);  
for (j = 0; j < N; j++) {
  if (j == N - 1) {
  B[N - 1] = K - A[N - 1] + A[0];
  }
  else{
  B[j] =abs(A[j] - A[j + 1]);
  }
}
for (k = 0; k < N; k++) {
min = max (B[k],min);
}
cout << K - min << endl;
}



Measured memory_bytes: 1792
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String[] substr = str.split(" ", 0);
		int n = Integer.parseInt(substr[0]);
		BigInteger k = new BigInteger(substr[1]);
		int [] a = new int[n+1];
		int [] b = new int[n+1];
		int [] c = new int[n+1];
		int [] d = new int[n+1];

		for (int i= 1; i<n+1; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		int i = 1;
		int j = 0;
		int count = 0;
		int count0 = 1;
		b[1] = 1;
		while(true) {
			if (b[a[i]] == 2) break;
			if (b[a[i]] == 1) {
				c[j]=a[i];
				b[a[i]] = 2;
				j+=1;
				i = a[i];
				count+=1;
			} else {
				b[a[i]]= 1;
				d[count0]= a[i];
				i= a[i];
				count0+=1;
			}
		}
	    int ans = 0;
		if (k.compareTo(BigInteger.valueOf(count0)) < 0) {
			ans = d[k.intValue()];
			System.out.println(ans);
			return;
		}

		BigInteger index = k.subtract(BigInteger.valueOf(count0)).mod(BigInteger.valueOf(count));
		int ind = index.intValue();

	    ans = c[ind];
		System.out.println(ans);
	}
}


Measured memory_bytes: 53732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> D(N);
    vector<ll> v(13),u(24);
    rep(i,N){
        cin >> D[i];
        v[D[i]]++;
    }
    if(v[0]){
        cout << 0 << endl;
        return 0;
    }
    v[0]++;
    u[0]++;
    bool flag = true;
    REP(i,1,13){
        if(v[i] >= 3){
            cout << 0 << endl;
            return 0;
        }
        if(v[i] == 2){
            u[i]++;
            u[(24-i)]++;
        }else if(v[i] == 1){
            if(flag){
                u[i]++;
            }else{
                u[24-i]++;
            }
            flag = !flag;
        }
    }
    ll m = 1e18;
    ll cnt = 1;
    REP(i,1,24){
        if(u[i] == 0){
            cnt++;
        }else{
            cmin(m,cnt);
            cnt = 1;
        } 
    }
    cmin(m,cnt);
    cout << m << endl;
}

Measured memory_bytes: 256
def solve(a, b):
    base = [1, 2, 3]
    base.remove(a)
    base.remove(b)
    return base[0]


def main():
    a = int(input())
    b = int(input())
    res = solve(a, b)
    print(res)


def test():
    assert solve(3, 1) == 2
    assert solve(1, 2) == 3


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 2940
n,m=map(int,input().split())
a=[list(map(int,input().split(" "))) for i in range(n)]

b=[]

for i in range(m):
    x=int(input())
    b.append(x)
c=[0]*n


for i in range(n):
    for k in range(m):
        c[i]=c[i]+a[i][k]*b[k]



for i in range(n):
    print(c[i])



    


Measured memory_bytes: 6016
#include <stdio.h>

int main (){
	int n1,n2;
	scanf ("%d %d",&n1,&n2);
	while (1){
		if (n1>=n2)printf ("%d %d\n",n2,n1);
		else printf ("%d %d\n",n1,n2);
		scanf ("%d %d",&n1,&n2);
		if (n1==0 && n2==0)break;
	}
	return 0;
}


Measured memory_bytes: 2076
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

/* 重みつきUnionFind木 */
struct UnionFindW {
    vector<int> parent;
    vector<int> value;
    static const int INF = 1<<28;
    UnionFindW(int N) {
        parent.clear(); parent.resize(N + 1, -1);
        value.clear(); value.resize(N + 1, 0);
    }
    /* 
     * root :: インデックス -> (ルートのインデックス, ルートとの距離)
     */
    pair<int, int> root(int x) {
        if (parent[x] == -1) return make_pair(x, 0);
        int p = parent[x];
        int v = value[x];
        pair<int, int> proot = root(p);
        parent[x] = proot.first;
        value[x] = v + proot.second;
        return make_pair(parent[x], value[x]);
    }
    /* 
     * query :: (インデックスx, インデックスy) -> yとxの差
     */
    int query(int x, int y) {
        pair<int, int> xroot = root(x),
                       yroot = root(y);
        if (xroot.first != yroot.first) return INF;
        return yroot.second - xroot.second;
    }
    /*
     * merge :: (インデックスx, インデックスy, yとxの差w) -> ()
     *
     * xとyがすでに親子関係を持っていて,その差がwでなければ異常終了
     */
    void merge(int x, int y, int w) {
        pair<int, int> xroot = root(x),
                       yroot = root(y);
        if (xroot.first == yroot.first) {
            assert(query(x, y) == w);
            return;
        }
        int px = xroot.first, py = yroot.first;
        int dx = xroot.second, dy = yroot.second;
        /* value[y] - value[x] = w
         * value[x] - value[px] = dx
         * value[y] - value[py] = dy
         * value[py] - value[px] = (value[y] - dy) - (value[x] - dx)
         *                       = (value[y] - value[x]) - (dy - dx)
         *                       = w - dy + dx
         */
        parent[py] = px;
        value[py] = w - dy + dx;
    }
};

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        UnionFindW uf(N);
        char c; int a, b, w;
        for (int i = 0; i < M; i++) {
            cin >> c;
            if (c == '?') {
                cin >> a >> b;
                int ans = uf.query(a, b);
                if (ans == UnionFindW::INF) {
                    cout << "UNKNOWN" << endl;
                } else {
                    cout << ans << endl;
                }
            } else {
                assert(c == '!');
                cin >> a >> b >> w;
                uf.merge(a, b, w);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3768
n = int(input())
p = list(map(int,input().split()))
count = 0

for i in range(n):
  if i != 0 and i != n-1:
    if p[i] > p[i-1]:
      if p[i] < p[i+1]:
        count += 1
    elif p[i] < p[i-1]:
      if p[i] > p[i+1]:
        count += 1
        
print(count)

Measured memory_bytes: 3188
n, k = map(int, input().split())
x = list(map(int, input().split()))

l = 0
t_min = 3 * 10 ** 8 + 1

while l + k -1 < n:
    x_l = x[l]
    x_r = x[l + k - 1]
    if x_l < 0 and x_r > 0:
        t = 2 * min(abs(x_l), abs(x_r)) + max(abs(x_l), abs(x_r))
    else:
        t = max(abs(x_l), abs(x_r))
    if t < t_min:
        t_min = t
    l += 1

print(t_min)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,t;
    cin >> n >> t;
    long tt[n];
    for(int i=0;i<n;i++)cin >> tt[i];
    long ans = 0;
    long time = 0;
    for(int i=1;i<n;i++){
        long tmp = min(t,tt[i]-tt[i-1]);
        ans += tmp;
        time = tt[i];
    }
    ans += t;
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  for (int i = 0; i < N; i++) {
    if ( i == (K-1)) cout << tolower(S.at(i),locale());
    else cout << S.at(i);
  }
}

Measured memory_bytes: 256
#include <iostream>
int main(void){
    int n,a,b,c,d,x,y;
    std::cin>>n>>a>>b>>c>>d;
    if(n%a>0){
        x=n/a+1;
        x=x*b;
    }else{
        x=n/a*b;
    }
    if(n%c>0){
        y=n/c+1;
        y=y*d;
    }else{
        y=n/c*d;
    }
    std::cout<<std::min(x,y)<<std::endl;
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>

int main(int argc, char *argv[]){
	std::string str;
	std::cin >> str;
	int num = 0;
	for(int i = 0; i < str.length() / 2; ++i){
		if(str[i] != str[str.length() - 1 - i]){
			num++;	
		}
	}
	std::cout << num << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string input;
    cin >> input;
    int size = input.length();
    int g = 0, p = 0;
    for(int i = 0 ; i < size; i++){
        if(input[i] == 'g') g++;
        else p++;
    }
    cout << -p + (int)(size/2) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iterator>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

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

    a = N/3;
    b = N/5;
    c = N/15;

    ans = N*(N+1)/2;
    ans = ans - 3*a*(a+1)/2 - 5*b*(b+1)/2 + 15*c*(c+1)/2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int main(){
    int Q, n = 0;
    cin >> Q;
    int y[Q];
    ll a[Q], b[Q];
    ll x, ans = 0;
    multiset<ll> s;
    multiset<ll>::iterator ite;;
    rep(i, Q){
        cin >> y[i];
        if(y[i] == 1) cin >> a[i] >> b[i];
    }
    rep(i, Q){
        if(y[i] == 2){
            cout << x << ' ' << ans << endl; 
            continue;
        }
        ans += b[i];
        s.insert(a[i]);
        n++;
        if(n == 1) x = a[i], ite = s.find(a[i]);
        elif(n%2 == 0){
            if(a[i] >= x) ans += a[i]-x;
            else ite--, ans += x-a[i], x = *ite;
        }
        else{
            if(a[i] < x) ans += x-a[i];
            else ite++, x = *ite, ans += a[i]-x;
        }
    }
}

Measured memory_bytes: 13568
import sys
N = int(input())
alist = list(map(int,input().split()))
flg = True
if N == 1:
    if alist[0] == 0:
        print(1)
    else:
        print(0)
    sys.exit()
inf = 10 ** 9 + 7
alist.sort()
if N % 2 == 0:
    for i in range(N)[1::2]:
        if alist[i-1] != i or alist[i] != i:
            flg = False
            break
else:
    if alist[0] != 0:
        flg = False
    for i in range(N)[2::2]:
        if alist[i-1] != i or alist[i] != i:
            flg = False
            break
if flg:
    print((2 ** (N // 2)) %  inf)
else:
    print(0)

Measured memory_bytes: 14008
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    string S, S_org;
    ll K;
    cin >> S >> K;

    S_org = S;

    ll ans_partial1 = 0, ans_partial2 = 0, seq = 1;
    ll seq_s0 = 1, seq_s0_left = 1, seq_s0_right = 0;
    bool constant = false;
    for(ll i=1; i<S_org.length(); i++) {
        if(S_org[i] == S[0]) {
            seq_s0++;
            seq_s0_left++;
            if( i == S_org.length()-1) constant = true;
        }
        else break;
    }

    if(!constant)
        for(ll i=S_org.length()-1; i>=0 ;i--) {
            // cerr << i << " " << S_org[i] << endl;
            if(S_org[i] == S[0]) {
                seq_s0++;
                seq_s0_right++;
            }
            else break;
        }
    ll ans_s0 = seq_s0/2;

    for(ll i=0; i<S.length(); i++) {
        if(i <seq_s0_left || i >= S.length() - seq_s0_right) continue;
        if(S[i] != S[i+1]){
            ans_partial1 += ll(seq/2);
            seq = ll(1);
        }
        else{
            seq++;
        }
    }
    
    cerr << "ans_partial1 = " << ans_partial1 << " ans_s0 = " << ans_s0  << " seq_s0_left = " << seq_s0_left << " seq_s0_right = " << seq_s0_right << endl;

    if(S.length()==1) {
        cout << K/2 << endl;
    }
    else if(constant) {
        cout << K*ll(S.length()) / ll(2) << endl;
    } else {
        cout << ans_partial1 * K + ans_s0 * (K-1) + seq_s0_right/ll(2) + seq_s0_left/ll(2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
//typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,k,m;
	cin>>n>>k;
	m=3*k;
	vvi in(m+1,vi(m+1));
	vvi an(m+1,vi(m+1));
	rep(i,n){
		int a,b;char c;
		cin>>a>>b>>c;
		if(c=='B')a+=k;
		in[a%(2*k)+1][b%(2*k)+1]++;
		an[a%(2*k)+1][(b+k)%(2*k)+1]++;
	}
	rep(i,m)rep(j,m)in[i+1][j+1]+=in[i][j+1]+in[i+1][j]-in[i][j];
	rep(i,m)rep(j,m)an[i+1][j+1]+=an[i][j+1]+an[i+1][j]-an[i][j];
//	rep(i,m+1){rep(j,m+1)cout<<" "<<in[i][j];cout<<endl;}
	
	int out=0;
	rep(i,k)rep(j,k){
//		int t=in[i][m]+in[m][j]-2*in[i][j];
		int t=0;
		t+=an[i][j];
		t+=an[i+k][j+k]-an[i][j+k]-an[i+k][j]+an[i][j];
		t+=an[i+k+k][j]-an[i+k][j];
		t+=an[i][j+k+k]-an[i][j+k];
		t+=an[i+k+k][j+k+k]-an[i+k][j+k+k]-an[i+k+k][j+k]+an[i+k][j+k];
		out=max(out,t);
		 t=0;
		t+=in[i][j];
		t+=in[i+k][j+k]-in[i][j+k]-in[i+k][j]+in[i][j];
		t+=in[i+k+k][j]-in[i+k][j];
		t+=in[i][j+k+k]-in[i][j+k];
		t+=in[i+k+k][j+k+k]-in[i+k][j+k+k]-in[i+k+k][j+k]+in[i+k][j+k];
		out=max(out,t);
	}
	cout<<out<<endl;
}






Measured memory_bytes: 70784
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#define dd double
#define ll long long
dd PI = acos(-1);
//ios::sync_with_stdio(false);
using namespace std;
const ll MAXN = 5e6 + 5;
const ll INF = 0xffffffff;

int main() {
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	ll t = max(a - b, a + b);
	cout << max(t, a * b) << endl;
}
	

Measured memory_bytes: 256
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2005;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	bool flag = true;
	int cnt[26] = { 0 };
	_for(i, 0, s.size())cnt[s[i] - 'a']++;
	_for(i, 0, 26)if (cnt[i] % 2) { flag = false; break; }
	if (flag)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

const li M=1e9+7;

void solve()
{
    li n,k;

    cin>>n>>k;

    li a[n];

    vi dp(k+1);

    dp[0]=1;

    f(i,0,n-1)
    {
        cin>>a[i];

        vi cum(k+1);      // cumulative

        fr(used,k,0)
        {
            li val=dp[used];

            li l=used+1;
            li r=used+min(a[i],k-used);

            if(l<=r)
            {
                cum[l]+=val;
                cum[l]%=M;

                if(r+1<=k)
                {
                    cum[r+1]-=val;
                    cum[r+1]+=M;
                    cum[r+1]%=M;
                }
            }
        }

        li sum=0;

        f(j,0,k)
        {
            sum+=cum[j];
            sum%=M;
            dp[j]+=sum;
            dp[j]%=M;
        }
    }

    cout<<dp[k];
}

int main()
{    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
main(){
  int tri[3];
  int s = 0, e = 0, t = 0, d = 0;
  while (cin>>tri[0]>>tri[1]>>tri[2]){
    sort(tri,tri+3);
    if (tri[2]>=tri[0]+tri[1]) break;
    s++;
    if (tri[2]*tri[2]==tri[0]*tri[0]+tri[1]*tri[1]) t++;
    if (tri[2]*tri[2]>tri[0]*tri[0]+tri[1]*tri[1]) d++;
    if (tri[2]*tri[2]<tri[0]*tri[0]+tri[1]*tri[1]) e++;
  } 
  cout <<s<<" "<<t<<" "<<e<<" "<<d<< endl;
  return 0;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)){
		VgetII(t,a);
		double minV=INF;
		int ans;
		F(i,0,n){
			double in;
			scanf("%lf",&in);
			double res=t-in*0.006;
			double diff=a-res;
			if(abs(diff)<minV) minV=abs(diff),ans=i+1;
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N,sum=0;
    cin >> N;
    string str;
    vector<string> data;
    for(long long i=0;i<N;i++){
        cin >> str;
        data.push_back(str);
        
    }
    
    sort(data.begin(),data.end());
    data.erase(unique(data.begin(),data.end()),data.end());
    for(auto i:data) sum++;
    
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 11604
H, N = [int(_) for _ in input().split()]

A = []
ma = None

for i in range(N):
    a, b = [int(_) for _ in input().split()]
    A.append((a, b, a / b))

A.sort(key=lambda x: -x[2])
ans = 0
# ans = (H // A[0][0]) * A[0][1]
h = H # % A[0][0]

if h > 0:
    memo = [10 ** 9 + 7] * (h + 1)
    memo[h] = 0
    for j in range(h, 0, -1):
        for i in range(N):
            a, b, c = A[i]
            x = j - a
            if x < 0:
                x = 0
            memo[x] = min(memo[x], memo[j] + b)

    ans += memo[0]

print(ans)


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

typedef long long ll;

int main(int argc, char* argv[])
{
  ll A, B, C;
  std::cin >> A >> B >> C;

  ll poison_num = std::min((A + B + 1), C);
  std::cout << poison_num + B << std::endl;

  return 0;
}


Measured memory_bytes: 256
#ifndef _WIN32
#include<iostream>
#endif

#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

typedef long long LL;
template<typename T>
bool chmin(T &l, T r){
	bool f = l>r; if (f)l = r; return f;
}
template<typename T>
bool chmax(T &l, T r){
	bool f = l<r; if (f)l = r; return f;
}
typedef vector<LL> V;
typedef vector<V> VV;


int a[11234];
int b[11234];
int d[11234];
LL e[11234];
typedef tuple<LL, int, int> TT;
#define DCtt(v,l,c,x) LL c;int v,l;tie(c,v,l)=x;c*=-1;
const LL INF = 1e15;
LL dijkstra(int s, int t,int L, VV &g){
	int N = g.size();
	VV dist(N, V(L + 1, INF));
	priority_queue<TT> que;
	que.push(TT(0, s, L));
	dist[s][L] = 0;
	while (que.size()){
		DCtt(v, l, cost, que.top()); que.pop();
		if (v == t){
			while (que.size())que.pop();
			return cost;
		}
		if (dist[v][l] < cost)continue;
		for (auto &ee : g[v]){
			int u = v^a[ee] ^ b[ee];
			if (d[ee] <= l){
				int nxt_l = l - d[ee];
				LL nxt_cost = cost;
				if (chmin(dist[u][nxt_l], nxt_cost)){
					que.push(TT(-nxt_cost, u, nxt_l));
				}
			}
			{
				int nxt_l = l;
				LL nxt_cost = cost+e[ee];
				if (chmin(dist[u][nxt_l], nxt_cost)){
					que.push(TT(-nxt_cost, u, nxt_l));
				}
			}
		}
	}
	return -1;
}

int main(){
	int N,M,L;
	while (cin>>N>>M>>L,N+M+L){
		VV g(N);
		REP(i, M){
			cin >> a[i] >> b[i] >> d[i] >> e[i];
			a[i]--; b[i]--;
			g[a[i]].push_back(i);
			g[b[i]].push_back(i);

		}
		cout << dijkstra(0, N - 1, L, g) << endl;
	}

	return 0;
}

Measured memory_bytes: 3456