akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////
 
 
int main(){
    
    ll n;cin>>n;
    string s;cin>>s;
    ll pos=0;
    ll ans=0;
    while(pos<=n-1){
        ans++;
        while(pos<=n-2&&s[pos]==s[pos+1]){
            pos++;
        }
        pos++;
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int a,b,c;

 scanf("%d %d %d",&a,&b,&c);
 if((a>=b)&&(a>=c))
 {
    if(b>=c)
    {

    printf("%d %d %d\n",c,b,a);
    }
    else
    {

     printf("%d %d %d\n",b,c,a);
    }
 }
 else if((b>=a)&&(b>=c))
 {
    if(a>=c)
    {

   printf("%d %d %d\n",c,a,b);
    }
    else
    {

     printf("%d %d %d\n",a,c,b);
    }
 }
 else if((c>=a)&&(c>=b))
 {
  if(a>=b)
  {

     printf("%d %d %d\n",b,a,c);
  }
  else
  {

     printf("%d %d %d\n",a,b,c);
  }
}
return 0 ;


}


Measured memory_bytes: 2044
#include<iostream>
#include<cstring>
//#include<bits/stdc++.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<set>
#define  si(a)       scanf("%d",&a)
#define  sl(a)       scanf("%lld",&a)
#define  sii(a,b)    scanf("%d%d",&a,&b)
#define  sll(a,b)    scanf("%lld%lld",&a,&b)
#define  queues      priority_queue
#define mod 1000000007
#define mem(a)  memset(a,0,sizeof(a));
#define def(a) ((a)&(-a))
#define fi  first
#define se  second
#define mp  make_pair
#define  pb push_back
typedef long long ll;
//priority_queue<int,vector<int >,greater<int > >q;
const ll INF=0x3f3f3f3f;
const double E=exp(1);
const double PI=acos(-1);
using namespace std;
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c*=a;
        a*=a;
        b>>=1;
    }return c;
}
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int s[200003];
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
   string s;
   cin>>s;
   int a=s.size();
   if(a==1){cout<<0<<endl;return 0;}
   int sum=0;
   for(int i=0;i<a-1;i++)
   {
       if(s[i]==s[i+1])
        s[i+1]=s[i]=='0'?'1':'0',sum++;
   }cout<<sum;
}
/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

template<class monoid>
struct LazySegmentTree
{
  using F=function<monoid(monoid,monoid)>;
private:
    int n;
    vector<monoid> node, lazy;
    F f,g;
    monoid m1,m2;


public:
    LazySegmentTree(int sz,F fsum,monoid m1,F fadd,monoid mlazy):f(fsum),g(fadd),m1(m1),m2(mlazy)
    {
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1,m1);
        lazy.resize(2*n-1,m2);
    }
    void eval(int k, int l, int r)
    {
      if(lazy[k] != 0)
      {
        node[k] =g(node[k],lazy[k]);//ここ
        if(r - l > 1)
        {
          lazy[2*k+1] = g(lazy[2*k+1],lazy[k]);//ここ
          lazy[2*k+2] = g(lazy[2*k+2],lazy[k]);//ここ
        }
        lazy[k] = 0;
      }
    }
    void add(int a,int b,monoid x)
    {
      add(a,b,x,0,0,n);
    }
    void add(int a, int b, monoid x, int k, int l, int r)
    {
      eval(k, l, r);
      if(b <= l || r <= a) return;
      if(a <= l && r <= b)
      {
          lazy[k] =g(lazy[k],x) ;//ここ
          eval(k, l, r);
      }
      else
      {
          add(a, b, x, 2*k+1, l, (l+r)/2);
          add(a, b, x, 2*k+2, (l+r)/2, r);
          node[k] = f(node[2*k+1],node[2*k+2]);
      }
    }
    monoid query(int a,int b)
    {
      return query(a,b,0,0,n);
    }
    monoid query(int a, int b, int k, int l, int r)
    {
      if(b <= l || r <= a) return 0;
      eval(k, l, r);
      if(a <= l && r <= b) return node[k];
      monoid vl = query(a, b, 2*k+1, l, (l+r)/2);
      monoid vr = query(a, b, 2*k+2, (l+r)/2, r);
      return f(vl,vr);
    }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  vector<vector<pair<int,int>>>sec(n+1);
  rep(i,m)
  {
    ll l,r,a;
    cin>>l>>r>>a;
    sec[r].push_back({l,a});
  }
  LazySegmentTree<ll> st(n+1,[](ll a,ll b){return max(a,b);},0,[](ll a,ll b){return a+b;},0);
  repi(i,1,n+1)
  {
    st.add(i,i+1,st.query(0,i));
    for(auto p:sec[i])
    {
      st.add(p.first,i+1,p.second);
    }
  }
  cout<<st.query(0,n+1)<<endl;


  return 0;

}


Measured memory_bytes: 19456
import math
import sys
from collections import deque
import copy
def mi() : return map(int,input().split())
a,b=mi()
l=[list(input()) for _ in range(a)]
count=0
for i in range(a):
  for _ in range(b):
    if l[i][_]==".":
      count+=1
l[0][0]=1
q=deque([[0,0]])
while q:
  x,y=q.popleft()
  if x==a-1 and y==b-1:
    print(count-l[x][y])
    sys.exit()
  for e,f in [[0,1],[0,-1],[1,0],[-1,0]]:
    if 0<=x+e<a and 0<=y+f<b and l[x+e][f+y]==".":
      l[x+e][f+y]=l[x][y]+1
      q.append([x+e,y+f])
print(-1)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll a;  ld b;
	cin >> a >> b;
	ll x = b * 100 + eps;
	cout << a * x / 100 << '\n';
}

Measured memory_bytes: 3744
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct label
{
    int top;    //1
    int front;  //2
    int right;  //3
    int left;   //4
    int back;   //5
    int bottom; //6
} Dice;

void diceroll(Dice *d, const char dir)
{
    int tmp;
    switch (dir)
    {
    case 'E':
    {
        tmp = d->top;
        d->top = d->left;
        d->left = d->bottom;
        d->bottom = d->right;
        d->right = tmp;
        break;
    }
    case 'N':
    {
        tmp = d->top;
        d->top = d->front;
        d->front = d->bottom;
        d->bottom = d->back;
        d->back = tmp;
        break;
    }
    case 'S':
    {
        tmp = d->top;
        d->top = d->back;
        d->back = d->bottom;
        d->bottom = d->front;
        d->front = tmp;
        break;
    }
    case 'W':
    {
        tmp = d->top;
        d->top = d->right;
        d->right = d->bottom;
        d->bottom = d->left;
        d->left = tmp;
        break;
    }
    }
}

void place_front(Dice *d, int q2)
{
    char direction[] = "NENEN";
    int i = 0;
    while (d->top != q2)
    {
        diceroll(d, direction[i]);
        i++;
    }
    diceroll(d, 'S');
}

void place_top(Dice *d, int q1)
{
    while (d->top != q1)
    {
        diceroll(d, 'W');
    }
}

int main(void)
{
    Dice d = {0, 0, 0, 0, 0, 0};
    int q, q1, q2;
    scanf("%d %d %d %d %d %d", &d.top, &d.front, &d.right, &d.left, &d.back, &d.bottom);
    scanf("%d", &q);

    for (int i = 0; i < q; i++)
    {
        scanf("%d %d", &q1, &q2);
        place_front(&d, q2);
        if (d.top != q1)
        {
            place_top(&d, q1);
        }
        printf("%d\n", d.right);
    }

    return 0;
}



Measured memory_bytes: 2044
import numpy as np


h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(input()[:]))
a = np.array(a)

n = 0
for i in range(h):
    if all(a[n, :]=='.'):
        a = np.delete(a, n, axis=0)
    else:
        n += 1
n = 0
for i in range(w):
    if all(a[:, n]=='.'):
        a = np.delete(a, n, axis=1)
    else:
        n += 1

for i in range(len(a)):
    for j in range(len(a[0])):
        print(a[i, j], end='')
    print()


Measured memory_bytes: 13876
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int n;
int main()
{	
   char  x;
	for(int i=1;i<=3;i++)
	{
		cin>>x;
		if(x=='1')cout<<9;
		if(x=='9')cout<<1;
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a >= k) cout << k << endl;
    else if(a+b >= k) cout << a << endl;
    else cout << a-(k-a-b) << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;

  map<string, int> memo;
  memo[s] = a;
  memo[t] = b;
  memo[u]--;
  cout << memo[s] << " " << memo[t] << endl;
  return 0;
}


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

int main()
{
    int p, q, r;
    vector<int> path(3);

    int min = 0x1000;

    cin >> path[0] >> path[1] >> path[2];

    sort(path.begin(), path.end());

    cout << path[0] + path[1] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int check(int a,int b,int c){
	int a2=a*a,b2=b*b,c2=c*c;
	int ab=a2+b2,ac=a2+c2,bc=b2+c2;
	if(ab==c2||ac==b2||bc==a2){
		return 1;
	}else{return 0;}
}

main(){
	int count,a,b,c;
	scanf("%d",&count);
	while(count){
		scanf("%d%d%d",&a,&b,&c);
		if(check(a,b,c)){printf("YES\n");}
		else{printf("NO\n");}
		count--;
	}
}

Measured memory_bytes: 0
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
num=[-1]*n
rec=dict()
for i in range(m):
  if sc[i][0] in rec and str(sc[i][1])!=num[sc[i][0]-1]:
    print(-1)
    exit()
  else:
    rec[sc[i][0]]=0
    num[sc[i][0]-1]=str(sc[i][1])
if num[0]=='0':
  if n>1:
    print(-1)
    exit()
elif num[0]==-1:
  if n>1:
    num[0]='1'
for i in range(n):
  if num[i]==-1:
    num[i]='0'
print(''.join(num))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define INF 0x3f3f3f3f
#define pb push_back
#define se second
#define fi first
using namespace std;
const int N=1e5+5;
const ll mod=1e9+7;
int a[N],vis[N];
ll f[N],ans[N];

void pre(){
    f[0]=1;
    for(ll i=1;i<N;i++){
        f[i]=(i*(f[i-1]%mod))%mod;
    }
}

ll power(ll x,ll y){
    ll ret=1;
    x%=mod;
    while(y){
        if(y&1){
            ret=(ret*x)%mod;
        }
        y=y>>1;
        x=(x*x)%mod;
    }
    return ret;
}

ll IE(ll x){
    return power(x,mod-2);
}

ll C(ll m,ll r){
    return (f[m]*((IE(f[r]) * IE(f[m-r])) % mod)) % mod;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
    pre();
    int n; cin>>n;
    for(int i=1;i<=n+1;i++){
        ans[i]=C(n+1,i)%mod;
    }
    int rep1=-1,rep2=-1,repnum;
    for(int i=1;i<=n+1;i++){
        cin>>a[i];
        if(!vis[a[i]]) vis[a[i]]=1;
        else repnum=a[i];
    }
    for(int i=1;i<=n+1;i++){
        if(a[i]==repnum){
            if(rep1==-1) rep1=i;
            else rep2=i;
        }
    }
    int sz2=(n+1-rep2);
    /*for(int i=0;i<=sz2;i++){
        ll x=C(sz2,i);
        ans[i+1]=ans[i+1]-x;
    }*/
    int sz1=(rep1-1);
    for(int i=1;i<=(sz1+sz2+1);i++){
        ll sum=C(sz1+sz2,i-1)%mod;
        ans[i]=(ans[i]-sum+mod)%mod;
    }
    for(int i=1;i<=n+1;i++) cout<<ans[i]%mod<<endl;
	return 0;
}

Measured memory_bytes: 3712
from collections import deque
dq = deque()
for _ in [None]*int(input()):
    s = input()
    if s == "deleteFirst":
        dq.popleft()
    elif s == "deleteLast":
        dq.pop()
    else:
        a, b = s.split()
        if a == "insert":
            dq.appendleft(b)
        else:
            if b in dq:
                dq.remove(b)
print(" ".join(dq))

Measured memory_bytes: 87512
#include <stdio.h>

int main()
{
    int i;

    //??\???
    int n;
    scanf("%d", &n);
    int R[n];
    for( i = 0; i < n; ++i )
        scanf("%d", &R[i]);

    //min???????°???????????????????max????????¶
    int min = R[0], max = R[1] - R[0];
    for( i = 1; i < n; ++i ){
        max = max < R[i] - min ? R[i] - min : max;
        min = min > R[i] ? R[i] : min; //min??????????????´??°???????????¨ R[i]-min == min-min ?????????
    }

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

    return 0;
}

Measured memory_bytes: 2628
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Int (Int64)
import Data.Coerce
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Unsafe as BS
import Control.Exception (assert)
import Data.Char

main = do
  n <- readLn
  s <- BS.getLine
  assert (BS.length s == 2 * n) $ return ()
  let loop :: N -> Int -> Int -> N
      loop !acc !k !i | BS.length s == i = if k == 0 then acc else 0
                      | chr (fromIntegral $ BS.unsafeIndex s i) == 'W' = if even k
                                                                         then loop (acc * fromIntegral k) (k-1) (i+1)
                                                                         else loop acc (k+1) (i+1)
                      | otherwise = if even k
                                    then loop acc (k+1) (i+1)
                                    else loop (acc * fromIntegral k) (k-1) (i+1)
  print $ loop (product (coerce ([1..fromIntegral n] :: [Int64]) :: [N])) 0 0

--
-- Modular Arithmetic
--

modulo :: Int64
modulo = 10^9+7
addMod, subMod, mulMod :: Int64 -> Int64 -> Int64
addMod !x !y | x + y >= modulo = x + y - modulo
             | otherwise = x + y
subMod !x !y | x >= y = x - y
             | otherwise = x - y + modulo
mulMod !x !y = (x * y) `rem` modulo

newtype N = N { unwrapN :: Int64 } deriving (Eq)
instance Show N where
  show (N x) = show x
instance Num N where
  (+) = coerce addMod
  (-) = coerce subMod
  (*) = coerce mulMod
  fromInteger n = N (fromInteger (n `mod` fromIntegral modulo))
  abs = undefined; signum = undefined

{-# RULES
"^9/Int" forall x. x ^ (9 :: Int) = let u = x; v = u * u * u in v * v * v
"^9/Integer" forall x. x ^ (9 :: Integer) = let u = x; v = u * u * u in v * v * v
 #-}


Measured memory_bytes: 1404
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

//const int N = 1e5+1;
const double pi = acos(-1);

int N,W;

int dp[110][100006];
int wt[110], val[110];
int sum = 0;

int find(int v, int idx){
    if(idx==N){
        return v==0?0:INT_MAX;
    }
    if(dp[idx][v] != -1) return dp[idx][v];
    int ans = find(v,idx+1);
    if(val[idx]<=v)
      ans = min(ans,wt[idx] + find(v-val[idx],idx+1));

    return dp[idx][v] = ans;
}

void solve(){    

    cin>>N>>W;
    mem(dp,-1);

    for(int i = 0;i<N;i++){
        cin>>wt[i]>>val[i];
        sum += val[i];
    }

    for(int i = sum;i>=0;i--){
        if(find(i,0)<=W){
            cout<<i<<"\n";
            return;
        }
    }
    cout<<"0";
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

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

Measured memory_bytes: 89580
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	c := [3]int{0, 0, 0}
	ans := 1
	for _, v := range a {
		cnt := 0
		for i := 0; i < 3; i++ {
			if v == c[i] {
				cnt++
			}
		}
		ans *= cnt
		ans %= mod
		for i := 0; i < 3; i++ {
			if c[i] == v {
				c[i]++
				break
			}
		}
	}

	out(ans)
}


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

int bubbleSort(vector<int> &v) {
  int tot = 0;
  for (int i = 0, n = v.size(); i < n; i++) {
    int k = i;
    for (int j = i; j < n; j++) {
      if (v[j] < v[k]) {
        k = j;
      }
    }
    if (k != i) {
      ++tot;
      swap(v[k], v[i]);
    }
  }
  return tot;
}

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int &i : v) cin >> i;
  int t = bubbleSort(v);
  cout << v[0];
  for (int i = 1; i < n; i++) cout << " " << v[i];
  cout << endl << t << endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

template<class T> inline bool cmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool cmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MOD=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll MAXN=1e5+5;
const ll MAXLG=__lg(MAXN)+2;


ll n;
/********** Main()  function **********/
int main()
{
  IOS();
  cin>>n;
  cout<<(n/2)*(n-n/2)<<endl;
	return 0;
}


Measured memory_bytes: 892
def main():
    N = int(input())
    pre_A = [int(i) for i in input().split()]
    A = []
    for i in range(N):
        if i != 0 and pre_A[i-1] == pre_A[i]:
            continue
        A.append(pre_A[i])
    N = len(A)
    A = [(int(i), idx) for idx, i in enumerate(A)]
    cur = 0
    for i in range(N):
        sea_level = 0
        if (i == 0 or A[i-1][0] <= sea_level) and A[i][0] > sea_level:
            cur += 1

    B = sorted(A)
    ans = 0
    pre_h = 0
    for h, idx in B:
        if h == 0:
            continue
        if pre_h != h:
            ans = max(cur, ans)
        # 高さがhになったときの、島の数の増減を考える
        if (idx != 0 and A[idx - 1][0] > h) and (idx != N-1 and A[idx + 1][0] > h):
            cur += 1
        elif (idx == 0 or A[idx - 1][0] < h) and (idx == N-1 or A[idx + 1][0] < h):
            cur -= 1
        pre_h = h
    print(max(cur, ans))


if __name__ == '__main__':
    main()



Measured memory_bytes: 21360
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  rep(i, N) cin >> p[i];
  sort(all(p), greater<int>());

  int ans = 0;
  rep(i, N) {
    if (i == 0) {
      ans += p[i] / 2;
    } else {
      ans += p[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> ans, num(n, 0);
    for (int i = n; i > 0; i--)
    {
        if (num[i - 1] % 2 == a[i - 1])
            continue;
        ans.push_back(i);
        for (int j = 1; j * j <= i; j++)
        {
            if (i % j == 0)
            {
                num[j - 1]++;
                if (j * j != i)
                    num[i / j - 1]++;
            }
        }
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 5108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(n);i++)
#define fori(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;


// 3 1 2 2 1
// 1 1 2 2 3
// (1 1) 2 2 3 need = nsm - sm

string s;
bool fun(int i, int j){
	for(int m = i; m <= j; m++){
//		debug()
		if(s[m] != s[j-m]) return false;
	}
	return true;
}



int main(){
	cin>>s;
	llint n = s.length();
	//debug(fun(0, n-1));
	if(fun(0, n-1) && fun(0, (n-1)/2-1) && fun((n+3)/2 - 1, n - 1)) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		for (int i = A; i <= B; i++) {
			if (i < A + K || B - K < i) {
				System.out.println(i);
			}
		}
	}
}


Measured memory_bytes: 27864
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>

int main() {
        fio;
        int a,b;
        cin>>a>>b;
        string s1,s2;
        for(int i=0;i<b;i++)
        s1+=to_string(a);
        
        for(int i=0;i<a;i++)
        s2+=to_string(b);
        
        if(!lexicographical_compare(s1.begin(),s1.end(), s2.begin(), s2.end()))
        cout<<s2<<endl;
        else
        cout<<s1<<endl;
        

 }



Measured memory_bytes: 256
object Main {

  import scala.collection.mutable

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val S = sc.next

    var chars = mutable.HashMap.empty[Char, Int]
    for (c <- S) {
      if (chars.contains(c)){
        chars(c) += 1
      } else {
        chars += c -> 1
      }
    }
    var res = true
    for (cs <- chars) {
      if (cs._2 != 2) {
        res = false
      }
    }
    if (chars.size != 2) {
      res = false
    }

    if(res){
      println("Yes")
    } else {
      println("No")
    }
  }
}

Measured memory_bytes: 25892
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        List<Integer> b = new ArrayList<>();
        List<Integer> c = new ArrayList<>();
        for (int i = 0; i < n; ++i) a.add(sc.nextInt());
        for (int i = 0; i < n; ++i) b.add(sc.nextInt());
        for (int i = 0; i < n; ++i) c.add(sc.nextInt());
        Collections.sort(a);
        Collections.sort(c);

        long res = 0;
        for (int i = 0; i < n; ++i) {
            int key = b.get(i);
            int ng = -1;
            int ok = n;
            while (ok - ng > 1) {
                int mid = (ng + ok) / 2;
                if (key <= a.get(mid)) ok = mid;
                else ng = mid;
            }
            long numA = ok;

            ng = -1;
            ok = n;
            while (ok - ng > 1) {
                int mid = (ng + ok) / 2;
                if (key < c.get(mid)) ok = mid;
                else ng = mid;
            }
            long numC = n - ok;

            res += numA * numC;
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 98644
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
long ggd(long a, long b) {//最小公倍数，最大公約数
	if(a<b)swap(a,b);
	if (b == 0) {
		return a;			
	}
	return ggd(b, a % b);
}
bool IsPrime(ll num)//素数
{
    if (num < 2ll) return false;
    else if (num == 2ll) return true;
    else if (num % 2ll == 0ll) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll i = 3ll; i <= sqrtNum; i += 2ll)
    {
        if (num % i == 0ll)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

vector< ll > divisor(ll n) {  //公約数の列挙
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
int main(){
    ll a,b;
    std::cin >> a>>b;
    std::vector<ll> dia,dib;
    
    dib=divisor(b);
    std::set<ll> s;
    a=ggd(a,b);
    dia=divisor(a);
    rep(i,dia.size()){
        if(IsPrime(dia[i]))s.insert(dia[i]);
    }
    
    s.insert(1);
   // rep(i,s.size())std::cout << *s.begin()+i << std::endl;
    std::cout << s.size() << std::endl;
}

Measured memory_bytes: 384
lis = list(map(int,input().split()))
if lis[0] == lis [1] and lis[0] != lis[2]:
    print("Yes")
elif lis[1] == lis[2] and lis[1] != lis[0]:
    print("Yes")
elif lis[0] == lis[2] and lis[2] != lis[1]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38448
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (998244353)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> Q;
 
ll dp[3010][3010];
 
int main(void){
    ll n,s;
    cin>>n>>s;
    vector<ll>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=s;j++){
            if(j-a[i]>=0)dp[i+1][j] = (dp[i+1][j]+dp[i][j-a[i]])%N;
            dp[i+1][j]=(dp[i+1][j]+(2*dp[i][j])%N)%N;
        }
    }
    cout<<dp[n][s]<<endl;
    return 0;
}

Measured memory_bytes: 74160
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {

    public static InputReader in;
    public static PrintWriter out;
    public static void main(String[] args) {
        in = new InputReader(System.in);
        out = new PrintWriter(System.out);
        int L = in.nextInt();
        int N = in.nextInt();
        int[] a = new int[N + 5];
        for (int i = 1; i <= N; i++) {
            a[i] = in.nextInt();
        }
        long ans = 0;
        ans = Math.max(ans, solve(N, a, L));
        int[] aa = new int[N + 5];
        for (int i = 1; i <= N; i++) {
            aa[i] = L - a[N + 1 - i];
        }
        ans = Math.max(ans, solve(N, aa, L));
        out.print(ans);
        out.close();
    }
    public static long solve(int n, int[] a, int l) {
        int[] b = new int[n + 5];
        int m = n + 1;
        for (int i = 1; i <= n; i++) {
            if (i == 1) b[i] = a[i];
            else b[i] = a[i] - a[i - 1];
        }
        b[m] = l - a[n];
        long[] sum = new long[n + 5];
        long[] sum135 = new long[n + 5];
        for (int i = 1; i <= m; i++) {
            sum[i] = sum[i - 1] + b[i];
            sum135[i] = (long)(2 * i - 1) * b[i] + sum135[i - 1];
        }
        long ans = 0;
        for (int Rnum = 0; Rnum < n; Rnum++) {
            long cur = sum[m - 1 - Rnum] * (Rnum + 1);
            int zero_i = m - (Rnum + 1) / 2;
            int len = Rnum / 2;
            if ((Rnum & 1) == 0) {
                cur += (sum135[m] - sum135[zero_i]) - (2 * zero_i - 1) * (sum[m] - sum[zero_i]);
                cur += Rnum * (sum[zero_i - 1] - sum[zero_i - len - 1]) - ((sum135[zero_i - 1] - sum135[zero_i - len - 1]) - (2 * (zero_i - len) - 2) * (sum[zero_i - 1] - sum[zero_i - len - 1]));
            }
            else {
                cur += (sum135[m] - sum135[zero_i]) - (2 * zero_i) * (sum[m] - sum[zero_i]);
                cur += Rnum * (sum[zero_i - 1] - sum[zero_i - len - 1]) - ((sum135[zero_i - 1] - sum135[zero_i - len - 1]) - (2 * (zero_i - len) - 2) * (sum[zero_i - 1] - sum[zero_i - len - 1]));
            }
            ans = Math.max(ans, cur);
        }
        return ans;
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public Long nextLong() {
            return Long.parseLong(next());
        }
        public Double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 47332
# _n=gets
# as=gets.strip.split.map(&:to_i).sort.reverse
# alice_n=0
# bob_n=0
# cnt=0
# as.each do |n| 
#     if cnt%2==0
#         alice_n+=n
#     else
#         bob_n+=n
#     end

#     cnt+=1
# end

# puts alice_n-bob_n

_n=gets
as=gets.strip.split.map(&:to_i).sort.reverse

alice=0
bob=0

until as.empty? do
    alice+=as.shift
    break if as.empty?
    bob+=as.shift
end

puts alice-bob

Measured memory_bytes: 14356
def main():
    S = input().strip()
    taps = [('R', 'U', 'D'), ('L', 'U', 'D')]
    cannot_taps = ['L', 'R']
    all_can_taps = True
    for i in range(len(S)):
        if S[i] == cannot_taps[i % 2]:
            all_can_taps = False
    print('Yes' if all_can_taps else 'No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;
using ll = long long;

int main() {
	int n, w;
	cin >> n >> w;
	vector<pair<long long, long long>> items(n);			// First Means Value Second Means Weight
	for (auto& item : items)
		cin >> item.first >> item.second;

	// vector<vector<long long>> dp(n + 1, vector<long long>(w + 1));
	vector<ll> prev(w + 1), curr(w + 1);
	for (int i = 0; i <= n; i++) {				// Here i represents ith item To Consider
		for (int j = 0; j <= w; j++) {			// Here j means Value You Can Get In j Weight Bag
			if (i == 0 || j == 0) {
				curr[j] = 0;
			}
			else if (items[i - 1].first <= j)
				curr[j] = max(prev[j], prev[j - items[i - 1].first] + items[i - 1].second);
			else
				curr[j] = prev[j];
			// cout << dp[i][j] << " ";
		}
		prev = curr;
		// cout << endl;
	}
	cout << curr[w] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        
    }
    int maxv=p[0],minv=p[0];
    for(int i=0;i<n;i++){
        if(p[i]<=maxv&&p[i]<=minv){
            ans++;
        }
        maxv=max(maxv,p[i]);
        minv=min(minv,p[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  cout << x * y / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];

    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    rep(i, n) {
        ll B = b[i];
        ll aidx = lower_bound(all(a), B) - a.begin();
        ll cidx = upper_bound(all(c), B) - c.begin();
        if (aidx <= n || cidx <= n) {
            ans += aidx * (n - cidx);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {

    lli A, B;
    cin >> A >> B;


    lli k = (A + B) / 2;
    
    if (abs(A - k) == abs(B - k)) {
        cout << k << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#python3
from math import floor, sqrt

def f(x):
    p = set()
    for i in range(1, floor(sqrt(x))+1):
        if x%i == 0:
            p.add(i)
            p.add(x//i)
    return len(p)
def main():
    n = int(input())
    cnt = 0
    for i in range(1, n+1):
        if i%2 != 0:
            if f(i) == 8:
                cnt += 1
    print(cnt)
main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
		int h,w,m;
  		cin>>h>>w>>m;
  		int* x=new int[h];
  		int* y=new int[w];
  		for(int i=0;i<h;i++)
          x[i]=0;
        for(int i=0;i<w;i++)
          y[i]=0;
  		map<pair<int,int>,int> p;
  		for(int i=0;i<m;i++){
        	int a,b;
          	cin>>a>>b;
          	x[a-1]++;
          	y[b-1]++;
          	p[pair<int,int>(a-1,b-1)]++;
        }
  		int ans=0;
  		int mx=-1,xv=0;
  		for(int i=0;i<h;i++){
        	if(xv<x[i])
            {	mx=i;
             	xv=x[i];
            }
        }  		
  		for(int i=0;i<w;i++){        	
           ans=max(ans,x[mx]+y[i]-p[pair<int,int>(mx,i)]);           
        }
        int my=-1,yv=0;
  		for(int i=0;i<w;i++){
        	if(yv<y[i])
            {	my=i;
             	yv=y[i];             	
            }          	              
        }
        for(int i=0;i<h;i++){ 
          ans=max(ans,x[i]+y[my]-p[pair<int,int>(i,my)]);
        }
        cout<<ans<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  char A[N][N], B[M][M];
  


  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B[i][j];
    }
  }
  
  for (int i = 0; i < N-M+1; i++) {
    for (int j = 0; j < N-M+1; j++) {
      bool cond = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (B[k][l] != A[i+k][j+l]) {
            cond = false;
          }
        }
      }
      if (cond) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int X, A; cin >> X >> A;
    Ans(X < A, 0, 10);

    return 0;
}


Measured memory_bytes: 256
uses math;
var s:array[0..200001] of longint;
  k,n,a,b,c,d,e:longint;
begin
  readln(k,n);
  for a:=1 to n do read(s[a]);
  e:=maxlongint;
  s[0]:=s[n]-k;s[n+1]:=s[1]+k;
  for a:=1 to n do e:=min(min(k-s[a]+s[a-1],k-s[a+1]+s[a]),e);
  writeln(e);
end.

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
//****************************************************                
#define f(var,start,end) for(ll var = start; var <end ; ++var)
#define rf(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define vvll vector<vector<ll>>
#define mtp make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define nl cout<<"\n"
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions
void solve();

int binary(int a[],int l,int r,int find)
{
    if(l>r)
    {
        return -1; 
    }else
    {
        int mid=(l+r)/2;
        if(a[mid]==find)
        {
            return mid+1;
        }else if(a[mid]>find)
        {
            binary(a,l,mid-1,find);
        }else
        {
            binary(a,mid+1,r,find);
        }   
    }   
}

int main()
{
    FAST_IO;
    ll testcases = 1;
    // cin >> testcases; //comment for 1 test case
    while(testcases--)
    {
        solve();
    }
}

void solve()
{
	ll a,b;
	cin>>a>>b;
	ll p=a*b;
	cout<<p;
	nl;   
}

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

int main(){
  int n;ll a,b,ans,now,next;cin>>n>>a>>b>>now; 
  REP(i,n-1){
    cin>>next;
    ans+=((next-now)*a<b?(next-now)*a:b);
    now=next;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
program one_stroke_path
  integer :: n, m, i, k
  integer :: a(50), b(50), c
  logical :: v(8)
  a = 0
  b = 0
  c = 0
  v = .true.
  read(*,*) n, m
  if (m.lt.n-1) then
    write(*,'(i0)') 0
    stop
  end if
  do i = 1, m
    read(*,*) a(i), b(i)
  end do
  v(1) = .false.
  call dfs(n,m,a(1:m),b(1:m),v(1:n),c,1)
  write(*,'(i0)') c
  stop
contains
  recursive subroutine dfs(n,m,x,y,v,c,i)
    implicit none
    integer, intent(in)    :: n, m, x(m), y(m), i
    logical, intent(inout) :: v(n)
    integer, intent(inout) :: c
    integer                :: j
    logical                :: t
    t = .false.
    do j = 1, n
      t = t.or.v(j)
    end do
    if (.not.t) then
      c = c + 1
      return
    end if
    do j = 1, m
      if (x(j).eq.i.and.v(y(j))) then
        v(y(j)) = .false.
        call dfs(n,m,x,y,v,c,y(j))
        v(y(j)) = .true.
      end if
      if (y(j).eq.i.and.v(x(j))) then
        v(x(j)) = .false.
        call dfs(n,m,x,y,v,c,x(j))
        v(x(j)) = .true.
      end if
    end do
    return
  end subroutine dfs
end program one_stroke_path

Measured memory_bytes: 256
n = int(input())
flg = 0
for i in range(n):
	t,x,y = map(int, input().split())
	if x+y > t:
		print ("No")
		exit()
	if x+y < t:
		if (x+y)%2 != t%2:
			print ("No")
			exit()
print ("Yes")

Measured memory_bytes: 3060
import scala.io.StdIn

object Main extends App {

  var hw = StdIn.readLine().split(' ').map(_.toInt)
  while(hw(0) != 0 && hw(1) != 0){
    (0 until hw(0)).foreach{ _ =>
      (0 until hw(1)).foreach( _ => print("#"))
      println("")
    }
    println("")
    hw = StdIn.readLine().split(' ').map(_.toInt)
  }

}



Measured memory_bytes: 51396