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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main(){ _

	int n; cin >> n;
	vector<vector<int>> v(n, vector<int>(3));

	for(auto& w : v) for(int& i : w) cin >> i;

	vector<vector<int>> memo(n, vector<int>(3,0));
	
	memo[0][0] = v[0][0], memo[0][1] = v[0][1], memo[0][2] = v[0][2];
	for(int i=1; i<n; i++) {
		for(int j=0; j<3; j++) {
			for(int k=0; k<3; k++) if(j != k) 
				memo[i][j] = max(memo[i][j], memo[i-1][k] + v[i][j]);
		}
	}

	cout << max({memo[n-1][0], memo[n-1][1], memo[n-1][2]}) << endl;

	return 0;
}


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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int solve(){
 	int n;cin>>n;
 	vector<int>a(n+1);
 	vector<int>vis(1e6+1);
 	int g=0;
 	rep(i,1,n+1){
 		cin>>a[i];
 		g=gcd(a[i],g);
 		vis[a[i]]=1;
 	}
 	if(g>1){
 		cout<<"not coprime"<<endl;return 0;
 	}
 	for(int i=2;i<=1e6;i++){
 		int cnt=0;
 		for(int j=i;j<=1e6;j+=i){
 			if(vis[j])cnt++;
 		}
 		if(cnt>1){
 			cout<<"setwise coprime"<<endl;return 0;
 		}
 	}
 	cout<<"pairwise coprime"<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 18772
a,b,red,green,cl = map(int,input().split())
r = sorted(list(map(int,input().split())))[::-1]
g = sorted(list(map(int,input().split())))[::-1]
c = sorted(list(map(int,input().split())))[::-1]
s = sorted(r[:a]+g[:b]+c)[::-1]
print(sum(s[:a+b]))


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll y;
  cin >> n >> y;
  for(int i = 0; i <= n; ++i) {
    for(int j = 0; i+j <= n; ++j) {
      if(1000ll*i + 5000ll*j + 10000*ll(n-i-j) == y) {
        cout << n-i-j << " " << j << " " << i << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3624
from collections import deque as D
line, stack = D(input().split()), D()
while line:
    hoge = line.popleft()
    if hoge.isdigit():
        stack.append(hoge)
    else:
        a, b = int(stack.pop()),int(stack.pop())
        if hoge =="*":
            stack.append(a*b)
        elif hoge == "+":
            stack.append(a+b)
        elif hoge == "-":
            stack.append(b-a)
        else:
            stack.append(b//a)
print(stack.popleft())


Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r)	for(int i=l;i<=r;i++)
#define REP(i,n)	for(int i=1;i<=n;i++)
#define REP0(i,n)	for(int i=0;i<n;i++)
#define PB			push_back
#define MP			make_pair
#define PII			pair<int,int>
#define VI			vector<int>
#define ALL(x)		(x).begin(),(x).end()
#define MAKE1(a)	int a;
#define MAKE2(a,b)	int a,b;
#define MAKE3(a,b,c) int a,b,c;
#define MAKE4(a,b,c,d) int a,b,c,d;
#define DR1(a)		MAKE1(a);cin>>a;
#define DR2(a,b)	MAKE2(a,b);cin>>a>>b;
#define DR3(a,b,c)	MAKE3(a,b,c);cin>>a>>b>>c;
#define DR4(a,b,c,d) MAKE4(a,b,c,d);cin>>a>>b>>c>>d;
#define int long long
string s;
const int MOD=1e9+7;
int dp[100005][14];
signed main(){
	cin>>s;
	dp[0][0]=1;
	s=" "+s;
	for(int i=1;i<s.size();i++){
		if(s[i]=='?'){
			for(int j=0;j<13;j++){
				for(int k=0;k<=9;k++)
					dp[i][(j*10+k)%13]=(dp[i][(j*10+k)%13]+dp[i-1][j])%MOD;
			}
		}
		else{
			for(int j=0;j<13;j++){
				dp[i][(j*10+s[i]-'0')%13]=(dp[i][(j*10+s[i]-'0')%13]+dp[i-1][j])%MOD;
			}
		}
	}
	cout<<dp[s.size()-1][5]<<endl;
	return 0;
}

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

int main() {
  long long K;
  cin >> K;
  long long ans = -1;
  if(K%2==1){
    if(K==1||K==7){
      ans = 1;
    }
    else{
      vector<long long> amari(1);
      vector<long long> sumamari(1);
      amari.at(0) = 7;
      sumamari.at(0) = 7;
      long long keta = 2;
      long long j;
      while(1>0){
        j = amari.at(keta-2) * 10 % K;
        amari.push_back(j);
        j = sumamari.at(sumamari.size()-1) + amari.at(amari.size()-1);
        j = j % K;
        sumamari.push_back(j);
        if(j==0){
          ans = keta;
          break;
        }
        keta += 1;
        if(keta-K>3){
          break;
        }
      }
      
    }
    
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 18996
H, W, K = map(int, input().split())
Ass = [list(map(int, input().rstrip())) for _ in range(H)]

def check(Bss):
    L = len(Bss)
    accBs = [0] * L
    numCut = 0
    for i in range(W):
        for j in range(L):
            if Bss[j][i] > K:
                return H*W
            if accBs[j] + Bss[j][i] > K:
                accBs = [0] * L
                numCut += 1
                break
        for j in range(L):
            accBs[j] += Bss[j][i]
    return numCut

ans = H*W
for ptn in range(2**(H-1)):
    Bss = []
    Bs = Ass[0]
    numCut = 0
    for i in range(1, H):
        if (ptn>>(i-1)) & 1:  # 割る
            Bss.append(Bs)
            Bs = Ass[i]
            numCut += 1
        else:  # 割らない
            Bs = [B+A for B, A in zip(Bs, Ass[i])]
    Bss.append(Bs)

    numCut += check(Bss)
    ans = min(ans, numCut)

print(ans)


Measured memory_bytes: 3188
#!/usr/bin/env python

def main():
    S = input()

    for i in range(1 << 3):
        operator = ["-", "-", "-"] 
        for j in range(3):
            if ((i >> j) & 1):
                operator[j] = "+"
        formula = ""
        for s, op in zip(S, operator + [""]):
            formula += s + op
        if eval(formula) == 7:
            print(formula + "=7")
            break

if __name__ == '__main__':
    main()


Measured memory_bytes: 38608
import sys
n=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
if 0 in List:
    print(0)
    sys.exit()
ans=1
for i in List:
    if ans<=10**18:
        ans*=i
    else:
        print(-1)
        sys.exit()
if ans<=10**18:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 21792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
double pi = 3.141592653589793238;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};


ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout<<setprecision(10);
    ll n, x, y;
    cin>>n>>x>>y;
    x--, y--;
    map<ll,ll> m; 
    for(ll i=0;i<n-1;i++)
    {
        for(ll j = i+1;j<n;j++)
        {
            m[min(j-i, abs(j-y)+abs(x-i)+1)]++;
        }
    }
    for(int i=1;i<n;i++)
        cout<<m[i]<<endl;
    
    
} 

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<vector>

using namespace std;

int main(){
    double n,t,a;cin >> n >> t >> a;
    double h[1010]={};
    for(int i = 0;i < n;i++)cin >> h[i] ;
    double m = 1000000;
    int id = 0;
    for(int i = 0;i < n;i++){
        double tmp = t-(h[i]*0.006);
        //cout << tmp << endl;
        double d = tmp-a;
        if(d < 0)d = -d;
        if(m >d){
            m = d;
            id = i+1;
        }
    }
    cout << id << endl;
}

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

int dp[10500], ndp[10500];
main () {
  int n; cin >> n;
  ndp[0] = dp[0] = 1;
  for (int i = 0;i < n; i++) {
    int s; cin >> s;
    for (int j = 0; j < 10500; j++) {
      if (j + s >= 10500 || !dp[j]) continue;
      ndp[j + s] = 1;
    }
    for (int j = 0; j < 10500; j++) dp[j] = ndp[j];
  }
  int ans = 0;
  for (int i = 0; i < 10500; i++) if (dp[i] && i % 10) ans = i;
  cout << ans << endl;
}


Measured memory_bytes: 384
N = int(input())
dp = [N] *(N+10)
dp[0] = 0

for i in range(1,N+1):
    for p in range(N+1):
        p = 6**p
        if p > N:
            break
        dp[i] = min(dp[i],dp[i-p]+1)
    for p in range(N+1):
        p = 9**p
        if p > N:
            break
        dp[i] = min(dp[i],dp[i-p]+1)

print(dp[N])


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n & 1)
    {
        cout << "No";
        return 0;
    }
    FOR(i, 0, n / 2 - 1)
        if(s[i] != s[i + n / 2])
        {
            cout << "No";
            return 0;
        }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
n, m, q = gets.split.map(&:to_i)
abcds = q.times.map { gets.split.map(&:to_i) }
ans = 0

arrs = [*1..m].repeated_combination(n)

arrs.each do |arr|
  sum = 0

  sum = abcds.inject(0) do |r, (a, b, c, d)|
    r + (arr[b - 1] - arr[a - 1] == c ? d : 0)
  end

  ans = sum if sum >= ans
end

puts ans


Measured memory_bytes: 14324
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int nextInt() {
  int n = 0;
  int s = 1;
  int c;
  while ((c = getchar()) != EOF) {
    if (c == '-') {
      s = -1;
    }
    else if (('0' <= c) && (c <= '9'<c)) {
      n = n * 10 + (c - '0');
    }
    else {
      break;
    }
  }
  return s * n;
}

int main(){
	int n = nextInt();
	int m = nextInt();
    int x[100000];
    int l[100000];

    for (int i = 0; i < m; i++) {
      x[i] = nextInt();
    }

    qsort(x, m, sizeof(int), asc);

    for (int i = 1; i < m; i++) {
      // printf("%d,%d\n", i, x[i]);
      l[i-1] = x[i] - x[i - 1];
    }

    qsort(l, m-1, sizeof(int), asc);

    int sum = 0;
    for (int i = 0; i < (m - 1) - (n - 1); i++) {
      // printf("%d,%d\n", i, l[i]);
      sum += l[i];
    }

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

	return 0;
}


Measured memory_bytes: 1396
#include <cstdio>
#include <cstdlib>
const int maxn=1e5+5;
int n,a[maxn];
int main() {
	scanf("%d",&n);
	a[0]=0;
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	a[n+1]=0;
	int tot=0;
	for(int i=1;i<=n+1;++i) tot+=abs(a[i]-a[i-1]);
	for(int i=1;i<=n;++i) printf("%d\n",tot-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

vector<int64_t> Divisor(int64_t n) {
    vector<int64_t> ret;
    for(int64_t i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}


int main() {
	int64_t n, k; cin >> n >> k;
	int64_t a[n]; rep(i,n) cin >> a[i];
	int64_t sum = 0; rep(i,n) sum += a[i];
	vector<int64_t> v = Divisor(sum);
	int64_t ans = 1;
	for(int64_t g : v) {
		int64_t b[n];
		int64_t minus = 0;
		for(int i = 0; i < n; ++i) {
			b[i] = a[i] % g;
			minus += b[i];
		}
		if(minus <= k) {
			ans = g;
			continue;
		}
		sort(b, b + n);
		int64_t plus = 0;
		for(int i = n - 1; i >= 0; --i) {
			minus -= b[i];
			plus += g - b[i];
			if(max(plus, minus) <= k) {
				ans = g;
				break;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
	int L, A, B, C, D;
	cin >> L >> A >> B >> C >> D;
	int koku, suu;
	koku = A / C;
	if(A % C != 0)
		koku++;
	
	suu = B / D;
	if(B % D != 0)
		suu++;
	cout << (L - ((koku > suu) ? koku : suu)) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int mod=1e9+7;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a,b;
    cin>>a>>b;
    int n=a.size();
    int flag=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]!=b[i])
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        cout<<"No"<<'\n';
    }
    else
        cout<<"Yes"<<'\n';




}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n-1);
  for(int i=0;i<n-1;i++){
    cin >> a.at(i);
  }
  vector<int> b(n);
  for(int i=0;i<n-1;i++){
    b.at(a.at(i)-1)++;
  }
  b.at(n-1)=0;
  for(int i=0;i<n;i++){
    cout << b.at(i) << endl;
  }
}

Measured memory_bytes: 4844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long[]a=new long[n];
		long sum=0;
		for(int i=0;i<n;i++){
			a[i]=sc.nextLong();
			sum+=a[i];
		}
		long snuke=0;
		long arai=sum;
		long min=Integer.MAX_VALUE;
		for(int i=0;i<n-1;i++){
			snuke+=a[i];
			arai-=a[i];
			if(Math.abs(snuke-arai)<min)min=Math.abs(snuke-arai);
		}
		System.out.println(min);
		
	}
}

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

int main() {
  uint64_t Ans = 1e9;  // 回答：

  uint64_t N; cin >> N;  // 入力値

  Ans = N-1;  // (1,N) 座標が最大値
  uint64_t R = sqrt(N); // 平方根まで一つずつ調査する。
  for(uint64_t i =1;i<=R;i++){
    if (N%i != 0 ) continue;
    Ans = min(Ans,i + N / i - 2);
    // cout << "i:" << i << " Ans:" << Ans << endl;
  }
  cout << Ans << endl;
}

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




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

using namespace std;
#define ll long long
const int N=2e6+5;
string s;
int dp[N][2];
int solve(int idx,int c)
{
    if(idx<0) return c;
    int &ret=dp[idx][c];
    if(~ret) return ret;
    int cur=s[idx]-'0'+c;
    ret=solve(idx-1,0)+cur;
    ret=min(ret,solve(idx-1,1)+10-cur);
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>s;
    memset(dp,-1,sizeof dp);
    cout<<solve((int)s.size()-1,0)<<endl;
    return 0;
}


Measured memory_bytes: 63900
#include<cstdio>
#include<cstring>
#define  N  210000
using  namespace  std;
int  st[30][N],ss[30][N],lo2[N];
int  n,m,ans=1;
inline  int  mymin(int  x,int  y){return  x<y?x:y;}
inline  int  mymax(int  x,int  y){return  x>y?x:y;}
inline  int  rmq1(int  x,int  y)
{
	int  k=lo2[y-x+1];
	return  mymin(st[k][x],st[k][y-(1<<k)+1]);
}
inline  int  rmq2(int  x,int  y)
{
	int  k=lo2[y-x+1];
	return  mymax(ss[k][x],ss[k][y-(1<<k)+1]);
}
int  main()
{
//	freopen("std.in","r",stdin);
//	freopen("vio.out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int  i=1;i<=n;i++)
	{
		scanf("%d",&st[0][i]);ss[0][i]=st[0][i];
	}
	for(int  i=2;i<=n;i++)lo2[i]=(lo2[i>>1])+1;
	for(int  i=1;i<=lo2[n];i++)
	{
		for(int  j=n-(1<<i)+1;j>=1;j--)st[i][j]=mymin(st[i-1][j],st[i-1][j+(1<<(i-1))]);
	}
	for(int  i=1;i<=lo2[n];i++)
	{
		for(int  j=n-(1<<i)+1;j>=1;j--)ss[i][j]=mymax(ss[i-1][j],ss[i-1][j+(1<<(i-1))]);
	}
	for(int  i=n-m;i>=1;i--)
	{
		if(st[0][i]>rmq1(i+1,i+m-1)  ||  st[0][i+m]<rmq2(i+1,i+m-1))ans++;
	}
	int  now=1,cnt=0;
	for(int  i=2;i<=n;i++)
	{
		if(st[0][i]<st[0][i-1])now=i;
		if(i-now+1==m)cnt++;
	}
	cnt--;if(cnt==-1)cnt=0;
	printf("%d\n",ans-cnt);
	return  0;
}

Measured memory_bytes: 32896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		System.out.println((long) w * h / 2.0);
		if (x * 2 == w && y * 2 == h) {
			System.out.println(1);
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner  sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();

        if(y<x) {
            int t=0;
            t=y;    y=x;    x=t;
        }
        int z = 0;
        for(int i=0;;i++){
            z = y % x;
            if(z==0){
                System.out.println(x);
                break;
            }else{
                y = x;  x = z;
            }

        }
            
        
    }
}


Measured memory_bytes: 26412
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
int n;
cin>>n;
int res=0;
if(n%2==0)
{
	res=n/2;
}
else
{
	res=(n/2)+1;
}
cout<<res;
}


Measured memory_bytes: 256
import java.io.InputStream

private val input = FastScanner()

fun main(args: Array<String>) = input.run {
    val n = nextInt()
    val a = nextInt()
    val b = nextInt()
    val c = nextInt()
    val d = nextInt()
    val diff = Math.abs(a - b)

    (0L..n - 2).forEach { down ->
        val minDown = -down * d
        val maxDown = -down * c
        val up = n - 1 - down
        val minUp = minDown + up * c
        val maxUp = maxDown + up * d
        if (diff in minUp..maxUp) {
            println("YES")
            return
        }
    }

    println("NO")
}

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}

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

using namespace std;

int main() {

  int n, d;
  cin>>n>>d;
  int x[n], y[n];
  int ans = 0;
  for(int i = 0; i<n; i++){
    cin>>x[i]>>y[i];
    if(sqrt(pow(x[i],2) + pow(y[i], 2)) <= d) ans++;
  }
  
  cout<<ans;
  return 0;
} 
 
  


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

int calc(string a, string b) {
  set<char> s;
  int ret = 0;
  for (auto& c : a) s.insert(c);
  for (auto&c : b) {
    if (s.count(c) > 0) {
      ret++;
      s.erase(c);
    }
  }
  return ret;
}

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 1; i < n-1; i++) {
    chmax(ans, calc(s.substr(0, i), s.substr(i, n-i)));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
program main
	implicit none
    integer::d
    read(*,*) d
    if(d==25)then
    	write(*,*) 'Christmas'
    else if(d==24)then
    	write(*,*) 'Christmas Eve'
    else if(d==23)then
    	write(*,*) 'Christmas Eve Eve'
    else
    	write(*,*) 'Christmas Eve Eve Eve'
    end if
    stop
end program main

Measured memory_bytes: 2632
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
class Point2D{
	using Same = const Point2D&;
public:
	T x,y;
	bool operator==(Same rhs){
		return abs(x-rhs.x)<1e-8 && abs(y-rhs.y)<1e-8;
	}
	T operator^(Same rhs){
		return x*rhs.y-rhs.x*y;
	}
	Point2D operator-(Same rhs){
		Point2D res(*this);
		res.x-=rhs.x,res.y-=rhs.y;
		return res;
	}
	double GetNorm(){return hypot(x,y);}
};
using Point2DD = Point2D<double>;

vector<Point2DD> CalcConvexFullVertex(vector<Point2DD>& P){
	int N=P.size();
	Point2DD A=P[0];
	vector<Point2DD> L;
	do{
		L.push_back(A);
		Point2DD B=P[0];
		for(int i=1;i<N;i++){
			Point2DD C=P[i];
			if(B==A){
				B = C;
			}
			else{
				Point2DD AB(B-A),AC(C-A);
				double outer = AB^AC;
				if(outer>0 || (abs(outer)<=1e-8 && AC.GetNorm()>AB.GetNorm())){
					B = C;
				}
			}
		}
		A = B;
	}while(!(A==L[0]));
	return L;
}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int N=in();
		if(!N) break;
		vector<Point2DD> P(N);
		REP(i,N){
			scanf("%lf,%lf",&P[i].x,&P[i].y);
		}
		sort(ALL(P),[](Point2DD& l,Point2DD& r){return l.x==r.x ? l.y<r.y : l.x<r.x;});
		auto L = CalcConvexFullVertex(P);
		out(N-L.size());
	}
	return 0;
}


Measured memory_bytes: 3348
mod = 10**9 + 7
N = int(input())
array = [int(i) for i in input().split()]
array_2 = [0]

for a in array:
    array_2.append(array_2[-1]+a)
    
output = 0
for i in range(len(array)-1):
    output += array[i] * (array_2[-1] - array_2[i+1])
    
print(output%mod)

Measured memory_bytes: 31720
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N,cnt=0,tmp;
	ll i;
	cin >> N;
	for(i=0;i<N;i++){
		cin >> tmp;
		if(tmp==cnt+1){
			cnt++;
		}
	}
	if(cnt==0)cout << -1;else cout << N-cnt;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 998244353;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d; cin >> a >> b >> c >> d;
    vvll dp(c + 1, vll(d + 1, 0));
    for (ll i = a; i <= c; i++) {
        for (ll j = b; j <= d; j++) {
            if (i == a && j == b) dp[i][j] = 1;
            else if (i == a) {
                dp[i][j] = dp[i][j - 1] * i;
                dp[i][j] %= MOD;
            } else if (j == b) {
                dp[i][j] = dp[i - 1][j] * j;
                dp[i][j] %= MOD;
            } else {
                dp[i][j] = ((dp[i - 1][j] * j % MOD + dp[i][j - 1] * i % MOD
                           -(dp[i - 1][j - 1] * (i - 1) % MOD) * (j - 1) % MOD) + MOD) % MOD;
            }
        }
    }

    // for (ll i = a; i <= c; i++) DEBUG_VLL(dp[i])

    cout << dp[c][d] << '\n';
    return 0;
}


Measured memory_bytes: 73616
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (A, B) = Slice2<long>();
            var cnt = 0L;
            for (var i = A; i <= B; ++i)
            {
                var s = i.ToString();
                if (s == string.Join("", s.ToCharArray().Reverse()))
                    ++cnt;
            }
            WriteLine(cnt);
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 46872
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){//計算量はO(log(max(a,b))
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(){
  ll N, M;
  cin >> N >> M;
  if(N * 2 > M){
    cout << M / 2 << endl;
    return 0;
  }
  cout << N + (M - 2 * N) / 4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int X;
    cin >> X;
    if (X == 7 || X == 5 || X == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(){

    int n,m;

    cin >> n >> m;

    int x[m];

    for(int i=0; i<m; i++){
        cin >> x[i];
    }

    int y[m-1];

    sort(x, x+m);

    for(int i=0; i<m-1; i++){
        y[i] = abs(x[i] - x[i+1]);
    }

    sort(y, y+m-1);
    

    int c = 0;

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

        c+=y[i];
    }

    cout << c << endl;

}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
graph = [[] for _ in range(n)]
dp = [-1 for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    graph[x-1].append(y-1)


def dfs(s):
    #print(s, dp)
    if dp[s] != -1:
        return dp[s]
    
    rep = 0
    for g in graph[s]:
        rep = max(rep, dfs(g)+1)
    dp[s] = rep
    return rep

#print(graph)
ans = 0
for i in range(n):
    #print('i:', i)
    ans = max(ans, dfs(i))

print(ans)

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back

typedef long long ll;


#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;


const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

#define int long long

const int N = 4e5 + 10;

ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}


signed main() {
    int n, k;
    cin >> n >> k;
    int dp[n+4][k+4];
    int a[n+4];
    for(int i=1; i<=n; ++i) cin >> a[i];
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for(int i=1; i<=n; i++) dp[i][0] = 1;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=k; j++) {
            dp[i][j] = dp[i][j-1];
            dp[i][j] += dp[i-1][j];
            dp[i][j] %= MOD;
            if(j-a[i]-1 >= 0) {
                dp[i][j] -= dp[i-1][j-a[i]-1];
                dp[i][j] += MOD;
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[n][k] << '\n';
    return 0;
}


Measured memory_bytes: 81536
n = int(input())
a = list(map(int, input().split()))

s = sum(a)

x1 = s - 2 * (sum(a[1::2]))  # 偶数番目のindexを取得
x = [x1]
for i in range(2, n + 1):
    x.append(2 * a[i - 2] - x[i - 2])

print(*x)


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

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

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

    ll N;
    string S; 
    cin >> N >> S;

    ll ans = 0;

    ll r,g,b;
    r = g = b = 0;

    for (int i = 0;i < N;i++){
        if(S[i] == 'R') r++;
        if(S[i] == 'G') g++;
        if(S[i] == 'B') b++;
    }

    ans = r*g*b;

    for (int i = 0;i < N;i++){
        for (int j = 1;j < N;j++){
            if(i+j*2 >= N) continue;
            if(S[i] != S[i+j] && S[i+j] != S[i+j*2] && S[i] != S[i+j*2]) ans--;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3664
use std::collections::HashSet;
use std::cmp;

fn read<T: std::str::FromStr>()->T{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();

    s.trim().parse().ok().unwrap()
}

fn main(){

        //nの読み込み
        let n: i64 = {

            let s: String = read();
            
            s.parse().unwrap()
        };

        let mut maxcount:usize = 0;
        let mut color_set = HashSet::new();

        //n使わない
        let s: String = read();
        let mut smut = s.split_whitespace();

        for i in smut{
            let a: i64 = i.parse().unwrap();
            
            let col = match a {
                1...399 =>0,
                400...799 =>1,
                800...1199 =>2,
                1200...1599 =>3,
                1600...1999 =>4,
                2000...2399 =>5,
                2400...2799 =>6,
                2800...3199 =>7,
                _ => 8
            };

            if col == 8 {
                maxcount += 1;
            }
            else{            
                color_set.insert(col);
            }
        }

        let COLORMAX:usize = 8;
        let MIN_COLOR:usize = 1;

        let mut min_color = cmp::max( MIN_COLOR,  color_set.len());
        let mut max_color = cmp::max( MIN_COLOR,  color_set.len() + maxcount);

        println!("{} {}", min_color, max_color);


}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	long long n, m;
	cin >> n >> m;
	
	cout << ((n * m - ((n*2) + ((m - 2)*2))) > 0 ? n * m - ((n*2) + ((m - 2)*2)) : -(n * m - ((n*2) + ((m - 2)*2))))<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  string t; cin >> t;
  for(int i = 0; i < t.size(); i++){
    if(t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;

  return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {

    ll h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) { cin >> s[i]; }
    ll a[h][w];
    if (s[0][0] == '.') {
        a[0][0] = 0;
    } else {
        a[0][0] = 1;
    }
    repd(i, 1, w) {
        a[0][i] = a[0][i - 1];
        if (s[0][i] == '#') {
            if (s[0][i - 1] == '.') {
                a[0][i]++;
            }
        }
    }
    repd(i, 1, h) {
        a[i][0] = a[i - 1][0];
        if (s[i][0] == '#') {
            if (s[i - 1][0] == '.') {
                a[i][0]++;
            }
        }

        repd(j, 1, w) {
            ll up = a[i - 1][j], left = a[i][j - 1];
            if (s[i][j] == '#') {
                if (s[i - 1][j] == '.') {
                    up++;
                }
                if (s[i][j - 1] == '.') {
                    left++;
                }
            }
            a[i][j] = min(up, left);
        }
    }
    cout << a[h - 1][w - 1] << endl;
    return 0;
}

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

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//方針
//x * y の最大値を小さくする
//x : A[i]
//y : F[i]


int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  vector<ll> F(N);

  REP(i,N)
  {
    cin >> A[i];
  }
  REP(i,N)
  {
    cin >> F[i];
  }
  //Aを昇順
  sort(A.begin(),A.end());
  //Fを降順
  sort(F.rbegin(),F.rend());


  //K減らした後の列をA'とする

  ll l = 0, r = 1e12;
  while(l < r)
  {

    ll mid = (l + r) / 2;
    //K
    ll tmp = 0;
    //4 * 2 <= 3
    //4 - 3/2 == 3 -> A[i]を3減らす必要がある
    //A[i] * F[i] <= tをすべてにおいて満たす必要がある。
    //A[i] <= t/ F[i]を満たす必要がある
    //A[i]のほうが大きい場合は、A[i] - t/F[i]
    for(ll i = 0; i < N; ++i)
    {
      tmp += max(0LL,A[i] - mid/F[i]);
    }

    if(tmp <= K)
    {
      //さらに小さい値を探しにいく
      r = mid;
    }
    else
    {
      l = mid + 1;
    }
  }

  cout << r << endl;

  return 0;    
}



Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<ll,ll> pll;

int main(){
    int N;cin >> N;
    ll C;cin >> C;
    vector<ll> x(N),v(N);
    rep(i,N){
        cin >> x[i] >> v[i];
    }
    vector<ll> sum(N+1),sumr(N+1);

    for(int i=0;i<N;i++)sum[i+1]=sum[i]+v[i];
    for(int i=N;i>0;i--)sumr[i-1]=sumr[i]+v[i-1];
    FOR(i,1,N+1)sum[i]-=x[i-1];
    rep(i,N)sumr[i]-=C-x[i];
        
    //sum[i]...[0,i)の寿司をとった時のカロリー総計
    //sumr[i]...[i,N-1]の寿司をとった時のカロリー総計
    vector<ll> best(N+1),bestr(N+1);
    for(int i=0;i<N;i++){
        best[i+1]=max(sum[i+1],best[i]);
    }
    for(int i=N;i>0;i--){
        bestr[i-1]=max(sumr[i-1],bestr[i]);
    }
    //best[i]...[0,i)まで行けるときのカロリーのmax
    //bestr[i]...[i,N-1]まで行けるときのカロリーのmax
    ll res = 0;
    FOR(i,1,N+1){
        res = max(sum[i],res);//戻らず退店
        if(i!=N)res=max(res,sum[i]-x[i-1]+bestr[i]);//戻って反対の寿司も食べる
    }
    rep(i,N){
        res = max(sumr[i],res);//戻らず退店
        if(i!=0)res=max(res,sumr[i]-(C-x[i])+best[i]);//戻って反対の寿司も食べる
    }
    // rep(i,N+1){
    //     cout << best[i] << ":" << bestr[i] << endl;
    // }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
using System;

class Hello{

    public static void Main(){
    
        var array = Console.ReadLine().Split(' ');
    
        var a =  int.Parse(array[0]);
        var b =  int.Parse(array[1]);
        string ans = "";
        if(a < b)
        {
            for(int i = 0; i < b;i++){
                ans += "" + a;
            }
        }
        else
        {
            for(int i = 0; i < a;i++){
                ans += "" + b;
            }
        }
        
        Console.WriteLine(ans);
    }

}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  N=N%10;
  if (N==2 or N==4 or N==5 or N==7 or N==9) cout << "hon";
  else if (N==3) cout << "bon";
  else cout << "pon";
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    string t;
    rep (i, s.size()) {
        if (s[i] == 'x') {
            continue;
        } else {
            t += s[i];
        }
    }

    rep (i, (t.size() + 1) / 2) {
        if (t[i] != t[t.size() - 1 - i]) {
            cout << -1 << endl;
            exit(0);
        }
    }

    vector<int> xs(t.size() + 1, 0);
    int sidx = 0;
    rep (i, t.size()) {
        int ctr = 0;
        while (s[sidx] == 'x') {
            ctr++;
            sidx++;
        }
        xs[i] = ctr;
        sidx++;
    }
    sidx--;
    xs[t.size()] = s.size() - 1 - sidx;
    int ans = 0;
    rep (i, (xs.size() + 1) / 2) {
        ans += abs(xs[i] - xs[xs.size() - 1 - i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
def solve(N, W):
    m = sum(W)
    for i in range(1, N):
        #print(W[:i], W[i:])
        S1 = sum(W[:i])
        S2 = sum(W[i:])
        m = min(m, abs(S1-S2))
    return m
    
N = int(input())
W = [int(x) for x in input().split()]

print(solve(N, W))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
using namespace std;
#define ll long long
const int mod = 998244353, maxn = 1e5+10;
int N, M, K;
vector<int> G[maxn];
int dp[maxn];
void dfs(int x)
{
    for(int i : G[x])
    {
        if(!dp[i])
            dfs(i);
        dp[x] = max(dp[x], dp[i]+1);
    }
}
int main()
{
    scanf("%d %d", &N, &M);
    int x, y;
    for(int i = 0; i < M; i++) {
        scanf("%d %d", &x, &y);
        G[y].push_back(x);
    }
    int ans = 0;
    for(int i = 1; i <= N; i++)
        if(dp[i] == 0)
        {
            dfs(i);
            ans = max(ans, dp[i]);
        }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 13420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  vec a(3);
  rep(i,3)cin>>a[i];
  sort(a.begin(), a.end());
  cout<<(   ((a[0]==a[1]&&a[1]!=a[2])||(a[2]==a[1]&&a[1]!=a[0]))?"Yes":"No");
}


Measured memory_bytes: 256
import math
a,b,x = map(int,input().split(' '))
x = x/a
#print(x)
# type1
if x >= a*b/2:
    t = 2*x/a -b
    ans = math.atan2(b-t,a)
else:
    t=2*x/b
    ans = math.atan2(b,t)
print(math.degrees(ans) )

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll X, A;
    cin >> X >> A;
    if (X < A)
        cout << 0 << endl;
    else
        cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n, m, i, j, k;
	int A[100][100]={0}, b[100]={0};
	long int s;
	
	scanf("%d%d", &n, &m);
	
	/*Aの配列*/
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d", &A[i][j]);
		}
	}
	
	/*bの配列*/
	for(i=0;i<m;i++){
		scanf("%d", &b[i]);
	}

	/*答*/
	for(i=0;i<n;i++){
		s = 0;
		for(k=0;k<m;k++){
			s += A[i][k]*b[k];
			if(k==m-1){
			printf("%ld\n", s);
			}
		}
	}
	
	

return 0;
}


Measured memory_bytes: 2108