akhauriyash/Code-Regression huggingface dataset:
def main():
    num = int(input())
    open_data = [list(map(int, input().split())) for i in range(num)]
    value_data = [list(map(int, input().split())) for i in range(num)]

    ans = -1 * 10 ** 10

    for i in range(1, 1024):
        open_list = list(map(int, list(bin(i)[2:].zfill(10))))
        kari = 0
        for j in range(num):
            onaji = 0
            for k in range(10):
                if open_list[k] and open_data[j][k]:
                    onaji += 1
            kari += value_data[j][onaji]

        if kari > ans:
            ans = kari

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 42588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	string x;
	cin >> x;
	int a = 0 ,b = 0;
	int ans = 0;
	for(int i=0;i<x.size();i++){
		if(x[i] == 'S') a++;
		if(x[i] == 'T'){
			if(a != 0){
				a--;
				ans+=2;
			}
		}
	}
	cout << x.size() - ans << "\n";
}



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

using namespace std;

auto solve(int d, int e)
{
    auto result = -1.0;
    double tmp;
    for (int i = 0; i <= d; i++) {
        tmp = fabs(sqrt(i*i+(d-i)*(d-i)) - e);
        if(result < 0) {
            result = tmp;
        } else {
            result = fmin(result, tmp);
        }
    }
    return result;
}

int main()
{
    int d, e;
    while(cin >> d >> e) {
        if (d == 0 && e == 0){
            break;
        }
        cout << solve(d, e) << endl;
    }
    return 0;
}


Measured memory_bytes: 3272
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep(i,n)    for(ll i=0; i<n; i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    ll i,j,n,m,a,b,c;
    string x;
    map<string,ll>s,t;
    cin>>n;
    rep(i,n)
    {
        cin>>x;
        s[x]++;
    }
    cin>>m;
       rep(i,m)
    {
        cin>>x;
        t[x]++;
    }
    ll ans=0,tmp;
    for(auto e:s)
    {
        tmp=e.se-t[e.fi];
        ans=max(ans,tmp);
    }
        cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3624
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstdint>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
int A , B , C , D; cin >> A >> B >> C >> D;
  int count = 0;
  int ans = 0;
  while(A > 0){
    A -= D;
    count++;
  }
  while(C > 0){
    C -= B;
    ans++;
  }
  if(count >= ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" <<  endl;
  }
}

Measured memory_bytes: 3632
use proconio::input;

fn main() {
    input!(mut a: u32, mut b: u32, mut c: u32);
    a += 50;
    b += 50;
    c += 50;
    let cost = |x: u32, y: u32| {
        if x < y {
            (y - x) / 2 + (y - x) % 2 * 2
        } else {
            x - y
        }
    };
    println!(
        "{}",
        (0..150)
            .map(|x| { cost(a, x) + cost(b, x) + cost(c, x) })
            .min()
            .unwrap()
    );
}


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

int main() {
	int n,i;
	int *a;
	cin>>n;
	a=new int[n];
	for(i=0;i<n;i++) {
		cin>>a[i];
	}
	
	for(--i;i>=0;i--) {
		cout<<a[i];
		if(i) {
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}

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

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

    long long sum = 0;

    for (int i = 1; i <= n; i++) {
        int a = i;
        if (a % 3 == 0 || a % 5 == 0) {
            continue;
        }
        sum += a;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3636
package main

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

func main() {
	var wtr = bufio.NewWriter(os.Stdout)

	var N int
	fmt.Scan(&N)
	ans := N * (N - 1) / 2
	fmt.Fprintln(wtr, ans)
	_ = wtr.Flush()
}


Measured memory_bytes: 1840
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    a, b = map(int, rl().split())
    for p in range(1, 10001):
        if int(p * 0.08) == a and int(p * 0.1) == b:
            print(p)
            exit()
    print(-1)


if __name__ == '__main__':
    solve()


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

int a[500005];

int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int x;
        scanf("%d",&x);
        a[x]++;
        a[x-1]++;
        a[x+1]++;
    }
    int max=0;
    for(int i=0;i<=500000;i++)
        if(a[i]>max)
            max=a[i];
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 512
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<1000000007>;

template<class T>auto set_factorial(std::size_t N)
{
	std::vector<T> ret(N + 1);
	ret[0] = 1;
	for (auto i : boost::irange<index_t>(0, N))
	{
		ret[i + 1] = ret[i] * (i + 1);
	}
	return ret;
}

void Main()
{
	int X, Y;
	std::cin >> X >> Y;
	auto S = X + Y;
	if (S % 3 != 0)
	{
		std::cout << 0 << std::endl;
		return;
	}
	X -= S / 3;
	Y -= S / 3;
	if (X < 0 || Y < 0)
	{
		std::cout << 0 << std::endl;
		return;
	}
	auto fact = set_factorial<mod_t>(S / 3);
	std::cout << fact[X + Y] / (fact[X] * fact[Y]) << std::endl;

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 5504
#include <stdio.h>
#include <string.h>
#define LEN 100005
 
typedef struct pp{
  char name[100];
  int t;
} P;
 
P Q[LEN];
int head, tail,n;
 
void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}
 
P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}
 
int min(int a, int b){return a < b ? a : b;}
 
int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d", &n, &q);
 
  for( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
 
  while (head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 )enqueue(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }
 
  return 0;
}


Measured memory_bytes: 11896
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, D = map(int, input().split())
    print(ceil(N, (2 * D + 1)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4072
#include <bits/stdc++.h>
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

using namespace std;

string a;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    getline(cin, a);
    int counter = 0;
//    cout << a.size() << '\n';
    for (int i = 0; i < a.size()/2; ++i) {
        if (a[i] != a[a.size()-i-1])
            counter++;
    }
    cout << counter << '\n';
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count_list = [0]*10**5
for i in range(N):
  count_list[A[i]] += 1
Max = 0
for i in range(10**5-2):
  Max = max(Max, count_list[i]+count_list[i+1]+count_list[i+2])
print(Max)
  

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

using namespace std;

typedef long long ll;

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

  int n;
  while(cin>>n,n){
      int res=0;
      for(int i=0;i*i<=n;i++){
          for(int j=i;j*j<=n;j++){
              for(int k=j;k*k<=n;k++){
                  for(int l=k;l*l<=n;l++){
                      if(i*i+j*j+k*k+l*l==n) res++;
                  }
              }
          }
      }
      cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> H;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        H.push_back(t);
    }
    H[0]--;
    for (int i = 1; i < N; i++) {
        if (H[i] > H[i-1]) H[i]--;
        if (H[i] < H[i-1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

#define MOD 998244353

int main()
{
	int N;
	string S;
	cin >> N >> S;

	string ans = "No";
	if( N % 2 == 0 && S.substr( 0, N / 2 ) == S.substr( N / 2, N / 2 ) ) ans = "Yes";

	cout << ans << endl;
}


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

int main() {
  ll l, r;
  cin >> l >> r;
  if(r-l >= 2019) cout << 0 << endl;
  else {
    ll a = l/2019;
    l = l - a*2019;
    r = r - a*2019;
    int ans = INT_MAX;
    for(int i = l; i <= r-1; i++) {
      for(int j = i+1; j <= r; j++) {
        ans = min(ans, (i*j)%2019);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#define lowbit(x) (x)&(-x)
using namespace std;
int n,ans,tou,wei,a[5010],c[5010],dp[5010][5010];
char ch;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>ch,a[i]=ch-'a';
	for(int i=n;i>=1;i--)
		for(int j=i-1;j>=1;j--)
			if(a[i]==a[j]&&j+dp[j+1][i+1]<i)
				dp[j][i]=1+dp[j+1][i+1],ans=max(ans,dp[j][i]);
	printf("%lld",ans);
	return 0;
}

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

int H,W;
int c[10][10];
int countA[10];
int minpath[10][10];

int main(){
  cin >> H >> W;
  
  for(int i=0; i<100; i++){
    minpath[i/10][i%10]=10000000;
  }
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      cin >> minpath[i][j];
    }
  }
  
  for(int i=0; i<10; i++){
    countA[i]=0;
  }
  for(int i=0; i<H*W; i++){
    int c; cin >> c;
    if(c!=-1) countA[c]++;
  }
  
  //わーしゃるふろいど！
  for(int i=0; i<10; i++){
    for(int j=0; j<10; j++){
      for(int k=0; k<10; k++){
        minpath[j][k]=min(minpath[j][k],minpath[j][i]+minpath[i][k]);
      }
    }
  }
  
  int result=0;
  for(int i=0; i<10; i++){
    result+=(minpath[i][1]*countA[i]);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
N = int(input())
H = [0] + list(map(int, input().split())) + [0]

ans = 0
while any(H):
    water = min(h for h in H if h)

    cnt = 0
    bl = 0
    for x, y in zip(H[:-1], H[1:]):
        if x < y and x == 0:
            bl = 1
        elif x > y and y == 0 and bl:
            cnt += 1
            bl = 0
    ans += water * cnt
    H = [max(0, h-water) for h in H]


print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include <cstdlib>
#include<cctype>
#include <algorithm>    
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define VCOUT(num) for(auto& num:vec)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#define LLINF 1000000000000000000//10^18
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000
#define MAX 100
#define MX 10

//int main(int argc, char const* argv[]){
int main(){ 
    vector<int>vec;
     vector<char>cvec;
      vector<string>svec;
    
   int a,b,x,y,z,count=0;
   string str1,str2;
   char c;
   cin>>str1;
   cin>>str2;
   
   REP(i,str1.size()){
       if(str2[i]!=str1[i]){
           str2[i]==str1[i];
           count++;
       }
   }
   
    
  //std::sort(vec.begin(),vec.end());
  //for(auto& num:vec)cout<<num<<endl;
  auto answer=count;
  cout<<answer<<endl;
    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ls (o<<1)
#define rs (o<<1|1)
#define pb push_back
const double PI= acos(-1.0);
const int M = 1e5+7;
/*
int head[M],cnt=1;
void init(){cnt=1,memset(head,0,sizeof(head));}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
char s[10][10];
int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	int h,w,k;
  	cin>>h>>w>>k;
  	for(int i=0;i<h;i++)cin>>s[i];
  	int ans=0;
  	for(int i=0;i<(1<<h);i++)
  	for(int j=0;j<(1<<w);j++)
  	{
  		int tp=0;
  		for(int a=0;a<h;a++)
  		for(int b=0;b<w;b++)
  		{
  			if(i>>a&1)continue;
  			if(j>>b&1)continue;
  			if(s[a][b]=='#')tp++;
		}
		if(tp==k)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;


int gcd(int a,int b){
    if(a<b) gcd(b,a);
    while(a%b){
        int r=a%b;
        a=b;b=r;
    }
    return b;
}
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int pre[n],suf[n];
    pre[0]=a[0];suf[n-1]=a[n-1];
    for(int i=1;i<n;i++)
    pre[i]=gcd(pre[i-1],a[i]);
    for(int i=n-2;i>=0;i--)
    suf[i]=gcd(suf[i+1],a[i]);

    int ans=suf[1];
    for(int i=1;i<n-1;i++)
    {
        ans=max(ans,gcd(pre[i-1],suf[i+1]));
    }
    ans=max(ans,pre[n-2]);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    for (int i = 0; i < ty - sy; i++) {
        cout << 'U';
    }
    for (int i = 0; i < tx - sx; i++) {
        cout << 'R';
    }

    for (int i = 0; i < ty - sy; i++) {
        cout << 'D';
    }
    for (int i = 0; i < tx - sx; i++) {
        cout << 'L';
    }

    cout << 'L';
    for (int i = 0; i < ty - sy + 1; i++) {
        cout << 'U';
    }
    for (int i = 0; i < tx - sx + 1; i++) {
        cout << 'R';
    }
    cout << 'D';

    cout << 'R';
    for (int i = 0; i < ty - sy + 1; i++) {
        cout << 'D';
    }
    for (int i = 0; i < tx - sx + 1; i++) {
        cout << 'L';
    }
    cout << 'U' << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<map>

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

int p[10][10];
int cp[10][10];
int flag[10][10];
int h,w,c;

int sx[4]={0,1,0,-1};
int sy[4]={1,0,-1,0};
int col[7],res;

int bfs(int cc){
	memset(flag,0,sizeof(flag));
	queue<P> que;
	que.push(P(1,1));
	flag[1][1]=1;
	while(que.size()){
		P q=que.front();
		que.pop();
		int x=q.first,y=q.second;
		for(int i=0;i<4;i++){
			int nx=sx[i]+x,ny=sy[i]+y;
			if(flag[nx][ny]==0){
				if(cp[x][y]==cp[nx][ny]){
					flag[nx][ny]=1;
					que.push(P(nx,ny));
				}
			}
		}
	}
	int cnt=0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(flag[j][i]==1)cp[j][i]=cc;
			cnt+=flag[j][i];
		}
	}
	return cnt;
}

void dfs(int x){
	if(x<4){
		for(int i=1;i<=6;i++){
			col[x]=i;
			dfs(x+1);
		}
	}else{
		col[4]=c;
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				cp[j][i]=p[j][i];
			}
		}
		for(int i=0;i<5;i++){
			bfs(col[i]);
		}
		res=max(res,bfs(7));
	}
}

int main(void){
	while(1){
		scanf("%d %d %d",&h,&w,&c);
		if(h+w+c==0)break;
		res=0;
		memset(p,0,sizeof(p));
		for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				scanf("%d",&p[j][i]);
			}
		}
		dfs(0);
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1036
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <vector>
#include <algorithm>
#define inf INT_MAX/2
#define f first
#define s second
using namespace std;
typedef pair<int, int> P;
int n, m;
int main() {
    while (scanf("%d%d",&n,&m)) {
        if (!n&&!m) break;
        vector<P> riv[155];
        vector<vector<vector<int> > > dp(155);
        for (int i=0; i<n; i++) {
            int k; scanf("%d",&k);
            riv[i].clear();
            for (int j=0; j<k; j++) {
                int x, d; scanf("%d%d",&x,&d);
                riv[i].push_back(P(x,d));
            }
        }
        for (int i=0; i<n; i++) {
            dp[i].resize(riv[i].size(), vector<int>(m+1,inf));
        }
        for (int i=0; i<riv[0].size(); i++) {
            dp[0][i][0]=0;
        }
        for (int i=0; i<riv[1].size(); i++) {
            dp[1][i][1]=0;
        }
        int res=inf;
        for (int i=0; i<n; i++) {
            for (int j=0; j<riv[i].size(); j++) {
                for (int k=0; k<=m; k++) {
                    if (i+1==n) {
                        res=min(res,dp[i][j][k]);
                    } else {
                        for (int l=0; l<riv[i+1].size(); l++) {
                            dp[i+1][l][k]=min(dp[i+1][l][k],dp[i][j][k]+(int)abs(riv[i][j].f-riv[i+1][l].f)*(riv[i][j].s+riv[i+1][l].s));
                        }
                        if (i<n-1&&k<m) {
                            if (i+2==n) {
                                res=min(res,dp[i][j][k]);
                            } else {
                                for (int l=0; l<riv[i+2].size(); l++) {
                                    dp[i+2][l][k+1]=min(dp[i+2][l][k+1],dp[i][j][k]+(int)abs(riv[i][j].f-riv[i+2][l].f)*(riv[i][j].s+riv[i+2][l].s));
                                }
                            }
                        }
                    }
                }
            }
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int mid = n / 2;
    cout << d[n / 2] - d[n / 2 - 1];

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define N 200005

using namespace std;

inline int input() {
	int x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

long double n, d, x, ans;

int main() {
	n = input(), x = input(), d = input();

	while (n) {
		ans += (x * 2 + (n * 2 - 1) * d) / 2;
		x = ((n * 2 + 2) * x + d * 5) / n / 2;
		d = (n * 2 + 4) * d / n / 2;
		--n;
	}

	printf("%Lf\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<std::vector<int>> abc(n, std::vector<int>(3));
    for (int i = 0; i < n; i++) {
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }
    std::vector<std::vector<int>> dp(n, std::vector<int>(3, 0));
    dp[0][0] = abc[0][0];
    dp[0][1] = abc[0][1];
    dp[0][2] = abc[0][2];
    for (int i = 1; i < n; i++) {
        chmax(dp[i][0], max(dp[i - 1][1] + abc[i][0], dp[i - 1][2] + abc[i][0]));
        chmax(dp[i][1], max(dp[i - 1][0] + abc[i][1], dp[i - 1][2] + abc[i][1]));
        chmax(dp[i][2], max(dp[i - 1][0] + abc[i][2], dp[i - 1][1] + abc[i][2]));
    }
    int out = 0;
    chmax(out, dp[n - 1][0]);
    chmax(out, dp[n - 1][1]);
    chmax(out, dp[n - 1][2]);
    cout << out << endl;
    return 0;
}

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

typedef unsigned uint;
typedef unsigned long long ull;

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int N, i;
int h[100001];
int min_cost[100001];

int main() {
    fastio();
    cin >> N;
    for(i = 0; i < N; ++i) cin >> h[i];
    min_cost[0] = 0; min_cost[1] = abs(h[1]-h[0]);
    for(i = 2; i < N; ++i)
        min_cost[i] = min(min_cost[i-1]+abs(h[i]-h[i-1]), min_cost[i-2]+abs(h[i]-h[i-2]));
    cout << min_cost[N-1]-min_cost[0] << "\n";
	return(0);
}


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

typedef long long ll;

int h, n, t;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int sum = 0;
    cin >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        sum += t;
    }

    if (sum >= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N;
	int R;
	scanf("%d",&N);
	scanf("%d",&R);
	
	if(N>=10){
		printf("%d\n",R);
	}
	else if(N<10){
		printf("%d\n",R+100*(10-N));
	}
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repl(i, a, b) for (ll i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = b; i >= (a); --i)
#define repdl(i, a, b) for (ll i = b; i >= (a); --i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1'000'000'007LL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  ll a, b, c, d; cin >> a >> b >> c >> d;
  cout << max(a*c, max(max(a*d, b*c), b*d)) << endl;
}


Measured memory_bytes: 3648
var n:longint;
    i:longint;
    a,b:Array[0..15000]of int64;
    need,have:int64;
begin
  read(n);
  for i:=1 to n do
  read(a[i]);
  for i:=1 to n do
  read(b[i]);
  for i:=1 to n do
  if a[i]>b[i] then inc(need,(a[i]-b[i])) else inc(have,(b[i]-a[i]) div 2);
  if have>=need then writeln('Yes') else writeln('No');
end.

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

int N, Q;
vector<vector<int>> G;
vector<ll> c, res;

void dfs(int u, int p, ll w) {
  c[u] += w;
  for(int v: G[u]) {
    if(v != p) dfs(v, u, c[u]);
  }
}

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

  G.resize(N+1);
  rep(i,N-1) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  c.resize(N+1, 0);
  res.resize(N+1, 0);
  rep(i,Q) {
    int p, x;
    cin >> p >> x;
    c[p] += x;
  }

  dfs(1, -1, 0);

  rep(i,N) {
    if(i != 0) cout << " ";
    cout << c[i+1];
  }
  cout << endl;

  return 0;
}


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

struct point
{
	int x,y,d;
};

deque<point> D;
int n,m,sx,sy,ex,ey,dist[1010][1010];
int xgo[4]={-1,0,1,0},ygo[4]={0,1,0,-1};
char pan[1010][1010];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>m>>sx>>sy>>ex>>ey;
	for(int i=1;i<=n;i++)cin>>pan[i]+1;
	D.push_back({sx,sy,1}); dist[sx][sy]=1;
	while(!D.empty())
	{
		int dx,dy;
		point p=D.front(); D.pop_front();
		if(p.d!=dist[p.x][p.y]) continue;
		for(int i=0;i<4;i++)
		{
			dx=p.x+xgo[i],dy=p.y+ygo[i];
			if(dx<1||dx>n||dy<1||dy>m||pan[dx][dy]=='#') continue;
			if(dist[dx][dy]==0 || dist[dx][dy]>p.d)
			{
				dist[dx][dy]=p.d;
				D.push_front({dx,dy,p.d});
			}
		}
		for(int i=-2;i<=2;i++)for(int j=-2;j<=2;j++)
		{
			dx=p.x+i,dy=p.y+j;
			if(dx<1||dx>n||dy<1||dy>m||pan[dx][dy]=='#') continue;
			if(dist[dx][dy]==0 || dist[dx][dy]>p.d+1)
			{
				dist[dx][dy]=p.d+1;
				D.push_back({dx,dy,p.d+1});
			}
		}
	}
	if(dist[ex][ey]==0) cout<<-1;
	else cout<<dist[ex][ey]-1;
}


Measured memory_bytes: 8660
#include <iostream>
#include <vector>

using namespace std;

long long f[110][11] = {};
long long p[110][12] = {};
long long n;
long long total = -1000000000000;

vector<int> v;

long long calc_score(){
  long long tmp_total = 0;
  for (long long i=0;i<n;i++) {
    long long simul_open = 0;
    for (long long j=0;j<10;j++) {
      if (v[j] == 1 && f[i][j] == 1) {
	simul_open++;
      }
    }
    tmp_total += p[i][simul_open];
  }
  return(tmp_total);
}

void dfs(long long k){
  if (k==10) {
    long long open_sum = 0;
    for (long long i=0;i<10;i++) {
      open_sum += v[i];
    }
    if (open_sum > 0) {
      long long tmp_total = calc_score();
      if (tmp_total > total) {
	total = tmp_total;
      }
    }
    return;
  }
  v.push_back(1);
  dfs(k+1);
  v.pop_back();
  v.push_back(0);
  dfs(k+1);
  v.pop_back();
  return;
}

int main(){
  cin >> n;
  for (long long i=0;i<n;i++) {
    for (long long j=0;j<10;j++) {
      long long tmp;
      cin >> tmp;
      f[i][j] = tmp;
    }
  }
  for (long long i=0;i<n;i++) {
    for (long long j=0;j<=10;j++) {
      long long tmp;
      cin >> tmp;
      p[i][j] = tmp;
    }
  }
  dfs(0);
  cout << total << endl;
  return(0);
}



Measured memory_bytes: 256
// Problem : C - Sum of product of pairs
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=1e9+7;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }

signed main() {

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	int n;
   	cin>>n;
   	vector<int> v(n),tmp(n+1);
   	int ans=0;
   	for (int i=0;i<n;++i)
   		cin>>v[i];
   	for (int i=n-1;i>0;--i)
   		tmp[i]=(tmp[i+1]+v[i])%mod;
   	for (int i=1;i<n;++i){
   		ans=(ans%mod+(tmp[i]*v[i-1])%mod)%mod;
   	}
	cout<<ans<<endl;
   	return 0;
}

Measured memory_bytes: 6328
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


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

ll lcm( ll m, ll n )//最小公倍数
{
  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm


int main()
{
  int a, b, n;
  string s;
  cin  >> n;
  vector <ll> v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
  }

  ll min = 1;

  for (int i = 0; i < n; ++i)
  {
    // if (min % v[i] == 0)continue;
    min = lcm(min, v[i]);
    // cout << min << endl;
  }

  cout << min << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    rate_list = [0] * 9

    for a in a_list:
        rate = a // 400
        if rate < 8:
            rate_list[rate] += 1
        else:
            rate_list[-1] += 1

    min_cnt = 0
    for i in range(8):
        if rate_list[i] > 0:
            min_cnt += 1

    print(max(min_cnt, 1), min_cnt + rate_list[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 61904
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
vector<P> vec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if((i+j)%2 == 0) continue;
			if(i == 0 || j%3 == 0 || j == n-1) vec.push_back(P(i, j));
		}
	}
	cout << vec.size() << endl;
	for(int i = 0; i < vec.size(); i++) cout << vec[i].first << " " << vec[i].second << endl;
	
	return 0;
}

Measured memory_bytes: 7396
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long h){
    i64 ans = 0;
    i64 cnt = 1;
    while(h){
        ans += cnt;
        h /= 2;
        cnt *= 2;
    }
    cout << ans << endl;
}


signed main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


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

const int INF = 1001001001;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m){
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    int s, t;
    cin >> s >> t;
    s--; t--;

    vector<vector<int>> dist(n, vector<int>(3, INF));
    queue<P> que;

    que.push(P(s,0));
    dist[s][0] = 0;

    while(!que.empty()){
        int v = que.front().first;
        int l = que.front().second;
        que.pop();
        for(int u : g[v]){
            int nl = (l+1)%3;
            if(dist[u][nl] != INF) continue;
            dist[u][nl] = dist[v][l] + 1;
            que.push(P(u,nl));
        }
    }
    int ans = dist[t][0];
    if(ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
}

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

typedef long long LL;

const int N=6005;

int n,MOD,f[N][N*2],ny[N];

int main()
{
	scanf("%d%d",&n,&MOD);
	n*=3;
	ny[0]=ny[1]=1;
	for (int i=2;i<=n;i++) ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
	f[0][0+n]=1;
	for (int i=0;i<n;i++)
		for (int j=-i;j<=i;j++)
			if (f[i][j+n])
			{
				(f[i+1][j+n+1]+=(LL)f[i][j+n]*ny[i+1]%MOD)%=MOD;
				(f[i+2][j+n-1]+=(LL)f[i][j+n]*ny[i+2]%MOD)%=MOD;
				(f[i+3][j+n]+=(LL)f[i][j+n]*ny[i+3]%MOD)%=MOD;
			}
	int s=0;
	for (int i=0;i<=n;i++) (s+=f[n][i+n])%=MOD;
	for (int i=1;i<=n;i++) s=(LL)s*i%MOD;
	printf("%d\n",s);
	return 0;
}

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

int main()
{
	int n = 0;
	cin >> n;
	vector<int> list(n);
	for (int i = 0; i < n; i++)
	{
		cin >> list[i];
	}
	sort(list.begin(), list.end(), greater<int>());
	int buf = list[0];
	int ans = 1;
	for (int i = 0; i < n; i++)
	{
		if (buf != list[i])
		{
			ans++;
		}
		buf = list[i];
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	priority_queue<double, vector<double>, greater<double>> Q;
	double in;
	for (int i = 0; i < n; ++i)
	{
		cin >> in;
		Q.push(in);
	}
	double l, r;
	while (Q.size() != 1)
	{
		l = Q.top();
		Q.pop();
		r = Q.top();
		Q.pop();
		Q.push((l + r) / 2);
	}
	cout << Q.top() << endl;
	return 0;
}

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

int main()
{
    int n,su=0; cin>>n;
    vector<int> ar(n);
    for(int i=0;i<n;i++) cin>>ar[i];
    sort(ar.begin(),ar.end());
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            for(int k=j+1;k<n;k++)
            {
                if(((ar[i]+ar[j])>ar[k])&&((ar[j]+ar[k])>ar[i])&&((ar[i]+ar[k])>ar[j]))
                {
                    su++;
                }
            }
    cout<<su;
    return 0;
}


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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int a,b;
	cin >> a >> b;
	cout << 6-a-b << endl;
}

Measured memory_bytes: 3572
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let x: usize = read();
    let mut sum = 0;
    for i in 1..x+1 {
        sum += i;
        if sum >= x {
            println!("{}", i);
            break
        }
    }
}

Measured memory_bytes: 4352
s = input()

def is_palindrome(s):
  if s == s[::-1]:
    return True
  else:
    return False

l = len(s)
s_1 = s[0:l//2]
s_2 = s[l//2+1:]

if is_palindrome(s) and is_palindrome(s_1) and is_palindrome(s_2):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38384
a =int(input())
b =int(input())
c =int(input())
d =int(input())
e =int(input())
k =int(input())
if max(e-d, e-c, e-b, e-a, d-c, d-b, d-a, c-b, c-a, b-a)>k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include<string.h>
int a[200005];
int b[200005];
int num[200005]={0};
int sum[200005]={0};
int main ()
{
	int n,m,i,j,s=0,d=0,g=0; 
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		if(a[i]==1)
			num[b[i]]++;
		    s++;
		if(b[i]==n)
		    sum[a[i]]++;
		    d++;
	}
	if(s==0||m==0)
	{
		printf("IMPOSSIBILE\n");
	}
	else
	{
		for(i=1;i<n;i++)
		{
			if(num[i]>=1&&sum[i]>=1)
			{
				printf("POSSIBLE\n");
				return 0;
			}
		}
		printf("IMPOSSIBLE\n");
	} 
	return 0;
}

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


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


    int n;
    cin >> n;

    map <string, int> S;
    int maior = 1;

    for (int i = 0; i < n; ++i)
    {
    	string s;
    	cin >> s;

    	if(S.find(s) == S.end()) {
    		S[s] = 1;
       	}
    	else {
    		S[s]++;

    		maior = max(maior, S.find(s) -> second);
    	}
    }

    for (auto it = S.begin(); it != S.end(); ++it)
    {
    	if(it -> second == maior)
    	{
    		cout << it -> first << endl;
    		// cout << " " << it -> second << endl;
    	}
    }

    return 0;
}

Measured memory_bytes: 19304
n = int(input())
h = list(map(int,input().split()))
dp = [0]*(n)
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 20564
#include<stdio.h>
long long a[100010];
int main(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)scanf("%lld",&a[i]);
int zero=0;

for(int i=0;i<n;i++)if(a[i]==0)zero++;
if(zero>0){
// a[i] contains 0
printf("0\n");
return 0;
}
long long prod=1;
for(int i=0;i<n;i++){
if(a[i]<=1000000000000000000/prod){
// This condition is equivalent to prod*a[i]<=10ˆ18
prod*=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod);
}


Measured memory_bytes: 2484
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int aaa = Math.max(a-b,0);
		System.out.println(Math.max(c-aaa,0));

	}
}


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

int n;
int d[100005];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}
	sort(d, d + n);
	cout << d[n / 2] - d[n / 2 - 1];
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>
 
using namespace std;
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
//#define viadj[n+1] vector<int>adj[n+1] 
#define sortA(arr)   sort(arr.begin(),arr.end())
#define sortC(arr,n)   sort(arr,arr+n,comparefunc())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define LCM(a,b) boost::math::lcm(a,b)
#define mp make_pair
#define pll pair<long long int,long long int>
 vb isprime(1e7+1,true);
 
struct node{
     ll lenght;};
        
void Sieve(ll maxn){ 
    ll j;isprime[0]=isprime[1]=false;
    rep(i,2,sqrt(maxn)+1)
    {
        if(isprime[i]){
            for(j=i*i;j<=maxn;j+=i){
                isprime[j]=false;
            }
        }
    }
} 
 struct comparefunction{
bool operator()(const pll c,const pll d)const{
    ll lenc=c.second-c.first+1;
    ll lend=d.second-d.first+1;
    if(lenc!=lend)
    return lenc>lend;
    else
    return c.first<d.first;
   
     
}};
 
  
 
   void dfs(ll v,vb visited,vi adj[]) {
    visited[v] = true;
 
    
    for (int u : adj[v]) {
       if (!visited[u])
            dfs(u,visited,adj);
    }
   
    
}
 
 ll modpow(ll x, ll n,ll p){
     if(n==0)
     return 1;
     if(n==1)
     return x%p;
     if(n%2==0)
     return (modpow(x,n/2,p)%p)*(modpow(x,n/2,p)%p);
     else
     return (x%p)* (modpow(x,n/2,p)%p)*(modpow(x,n/2,p)%p);
 }
 
 
 
int main()
{
    
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
   
    ll check1=0,check2=0,check3=0;
    ll counti=0, i=0,j;
    ll sum=0,count=0;ll t;ll p;
  // cin>>t;
  //while(t--){
  ll k;
  cin>>k;
 string s;
 cin>>s;
 string temp="...";
 if(s.length()<=k)
 cout<<s;
 else
 cout<<s.substr(0,k)<<temp;
//}
    
}
  



 
   
 
 

Measured memory_bytes: 4316
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
// 15min
int main(void){
  int n;
  int cnt = 0;
  int max = 0;
  int h_f, h_b;
  
  scanf("%d", &n);

  scanf("%d", &h_f);
  for(int i = 1; i < n; i++){
    scanf("%d", &h_b);
    if(h_f >= h_b){
      cnt++;
      if(cnt > max){
	max = cnt;
      }
    }else{
      cnt = 0;
    }

    h_f = h_b;
  }
  
  printf("%d\n", max);
  
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int i,j,N;
    scanf("%d\n",&N);
    int W[N-1];
    int min,s[1],t,x;
    for(i=0;i<N;i++){
        scanf("%d",&W[i]);
    }
    
    for(t=1;t<N;t++)
    {   
        s[0]=0;
        s[1]=0;
         
        for(j=0;j<N;j++)
        {
            if(j<t){s[0] += W[j];}
            else{s[1] += W[j];}
        }    
        if(s[0]>s[1]){x = s[0] - s[1];}
        else{x = s[1] - s[0];}

        if(t==1||min > x){min = x;}
    }
        
    printf("%d",min);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("2")

#define ll long long
#define reg register
#define mk make_pair
#define PI pair<int, int>
#define rep(i, a, b) for(reg int i = a; i <= b; ++i)
#define per(i, a, b) for(reg int i = a; i >= b; --i)

using namespace std;

#define N 2005

int n;
int a[N], in[N];
bool vis[N], can[N][N];

vector<int> G[N];
priority_queue<int> q;

void Dfs(int x) {
    vis[x] = 1;
    rep (i, 1, n) {
        if (!vis[i] && can[x][i]) {
            ++in[i];
            G[x].push_back(i);
            Dfs(i);
        }
    }
}

int main() {
    scanf ("%d", &n);
    rep (i, 1, n) scanf ("%d", &a[i]);
    sort(a + 1, a + n + 1);
    rep (i, 1, n) per (j, i - 1, 1) if (__gcd(a[i], a[j]) != 1) can[i][j] = can[j][i] = 1;
    rep (i, 1, n) if (!vis[i]) Dfs(i);
    rep (i, 1, n) if (in[i] == 0) q.push(i);
    while (!q.empty()) {
        int now = q.top();
        q.pop();
        printf("%d ", a[now]);
        int len = G[now].size();
        rep (i, 0, len - 1) q.push(G[now][i]);
    }
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){

  int i, j;
  int month, day;
  int daycount = 0;

  while(1){
    daycount = 0;
    scanf("%d", &month);
    scanf("%d", &day);
    if((month == 0) && (day == 0)){
      return 0;
    }


    for(i = 1; i < month; i++){
      if((i == 11) || (i == 4) || (i == 6) || (i == 9)){
        daycount += 30;
      }else if((i == 1) || (i == 3) || (i == 5) || (i == 7) || (i == 8) || (i == 10) || (i == 12)){
        daycount += 31;
      }else if(i == 2){
        daycount += 29;
      }
    }

    daycount += day;

    daycount = daycount % 7;

    if(daycount == 0){
      printf("Wednesday\n");
    }else if(daycount == 1){
      printf("Thursday\n");
    }else if(daycount == 2){
      printf("Friday\n");
    }else if(daycount == 3){
      printf("Saturday\n");
    }else if(daycount == 4){
      printf("Sunday\n");
    }else if(daycount == 5){
      printf("Monday\n");
    }else if(daycount == 6){
      printf("Tuesday\n");
    }
 }


  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    IOS
    int a, b;
    cin >> a >> b;
    cout << ceil((a + (double)b) / 2) << endl;
}

Measured memory_bytes: 256
// CPP to find nim-game winner
#include <iostream>
#include <math.h>
using namespace std;

// function to find winner of NIM-game
int main(){

    long long int a,b,i,res,ans,j,n;
    cin >> n;
    for(i=sqrt(n);i>1;i--){
        if(n%i==0) break;
    }
    a = i;
    b = n/i;
    ans = a+b-2;
    cout << ans;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
const ll mod =   1e9+7;
int n;string s;
int x=0;int y=0;
int main()
{  fast
cin>>n>>s;
y=n-1;int ans=0;
while(x<y){
	while(x<y&&s[x]=='R')x++;

		while(y>x&&s[y]=='W')y--;
	if(x<y){

	ans++;
	x++;y--;}
}

cout<<ans;
}

Measured memory_bytes: 3776