akhauriyash/Code-Regression huggingface dataset:
/*考えられるパターン
1.両方とも正でx<y
y-x
2.両方とも正でx>y
符号チェンジ→絶対値を一致→符号チェンジ
3.x=0でyが正
y-x 1.と同じ
4.xが正でyが0
符号チェンジ→x回
5.両方とも負でx<y
y-x
6.両方とも負てx>y
符号チェンジ→絶対値を一致→符号チェンジ
7.x=0でyが負
絶対値を一致→符号チェンジ
8.xが負でyが0
y回
9.xyが正負違う
絶対値の差+符号チェンジ1回

同一の処理もあるが、ミスってたら直しがめんどうなので個別に処理する
処理時間も気にしない、省略せずに実装
*/
#include <stdio.h>
#include <stdlib.h>
int main(void){
    long long int x,y,ans;
    scanf("%lld %lld",&x,&y);
    ans=0;
    if(x>0 && y>0 && x<y){ //パターン1
        ans=y-x;
    }else if(x>0 && y>0 && x>y){ //パターン2
        ans++;
        ans+=(x-y);
        ans++;
    }else if(x==0 && y>0){ //パターン3
        ans=y-x;
    }else if(x>0 && y==0){ //パターン4
        ans++;
        ans+=x;
    }else if(x<0 && y<0 && x<y){ //パターン5
        ans=y-x;
    }else if(x<0 && y<0 && x>y){ //パターン6
        ans++;
        ans+=(x-y);
        ans++;
    }else if(x==0 && y<0){ //パターン7
        ans+=(0-y);
        ans++;
    }else if(x<0 && y==0){ //パターン8
        ans-=x;
    }else if((x>0 && y<0) || (x<0 && y>0) ){ //パターン9
        ans++;
        ans+=llabs((llabs(x)-llabs(y)));
    }
    
    printf("%llu\n",ans);
    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int n;
    int[] as;
    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++)
            as[i] = sc.nextInt();
    }

    private void solve() {
        long ans = 1L;
        for (int i = 0; i < n; i++){
            if (as[i] % 2 == 0) {
                ans *= 2;
            }
        }
        long tmp = (long)Math.pow(3, n);
        System.out.println(tmp - ans);
    }
}


Measured memory_bytes: 22356
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;

vector<vector<ll>> graph;
vector<ll> query;
vector<ll> ans;
vector<ll> visited;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

vector<ll> a , b;

//144 E
int main(void) {
	ll n,k;
	cin >> n >> k;
	a = vector<ll>(n), b = vector<ll>(n);
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) cin >> b[i];
	sort(a.rbegin(), a.rend());
	sort(b.begin(), b.end());

	ll low = -1, up = 0;
	rep(i, 0, n) up = max(a[i] * b[i], up);
	up++;
	while (up - low > 1) {
		ll k_Rest = k;
		bool can = true;
		ll middle = (up + low) / 2;
		rep(i, 0, n) {
			if (a[i] * b[i] > middle) {
				ll dec = a[i] - middle / b[i];
				if (dec > k_Rest) {
					can = false;
					break;
				}
				else {
					k_Rest -= min(a[i], dec);
				}
			}
		}
		if (can) {
			up = middle;
		}
		else {
			low = middle;
		}
	}
	cout << up << endl;
}



Measured memory_bytes: 3328
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int A, B; cin >> A >> B;
    if(A + B == 15) {
        cout << '+' << endl;
    }
    else if(A * B == 15) {
        cout << '*' << endl;
    }
    else {
        cout << 'x' << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main() {
  char p[1000005];
  memset(p, 1, sizeof(p));
  p[0] = 0;
  p[1] = 0;
  for (int i = 2; i <= 1000; i++) {
	if (p[i] == 1) {
	  for (int j = 2*i; j <= 1000000; j += i) {
		p[j] = 0;
	  }
	}
  }

  int a, d, n;
  while (1) {
	cin >> a >> d >> n;
	if (a == 0 && d == 0 && n == 0)return 0;
	while (1) {
	  if (p[a] == 1) n--;
	  if (n == 0) {
		cout << a << endl;
		break;
	  }
	  a += d;
	}
  }
}

Measured memory_bytes: 3984
from collections import Counter


n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()

ans = 0
l = n//2
if a[0][0] != b[0][0]:
    ans = l - a[0][1] + l - b[0][1]
else:
    if len(b) > 1:
        x = l - a[0][1] + l - b[1][1]
        y = l - a[1][1] + l - b[0][1]

    else:
        x = l - a[0][1] + l
        y = l - b[0][1] + l

    ans = min(x, y)

print(ans)


Measured memory_bytes: 95204
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


A, B, C = zz()
K = z()

# A<B<C　にしたい
for i in range(K):
    if (A >= B):
        B *= 2
    elif (B >= C):
        C *= 2
    # print(A, B, C)
if (A < B < C):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 42296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=210000;
int n,tot;
char s[N];
int head[N],nex[N<<1],to[N<<1];
int f1[N],f2[N],g[N],lb[N],size[N];
ll ans;
void add(int x,int y)
{
	tot++;
	nex[tot]=head[x];head[x]=tot;
	to[tot]=y;
}
void upd(int &x,int &y,int z)
{
	if(z>x)y=x,x=z;
	else if(z>y)y=z;
}
void dfs1(int x,int y)
{
	size[x]=s[x]-'0';
	for(int i=head[x],t;i;i=nex[i])if((t=to[i])!=y)
	{
		dfs1(t,x);
		size[x]+=size[t];
		upd(f1[x],f2[x],f1[t]+1);
		if(size[t])
			lb[x]=min(lb[x],f1[t]+1);
	}
}
void dfs2(int x,int y)
{
	for(int i=head[x],t,d;i;i=nex[i])if((t=to[i])!=y)
	{
		g[t]=max(g[x],f1[t]+1==f1[x] ? f2[x] : f1[x])+1;
		if(size[t]!=size[1])
			lb[t]=min(lb[t],g[t]);
		dfs2(t,x);
	}
}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
		if(s[i]=='0')lb[i]=n+1;
	dfs1(1,0);
	dfs2(1,0);
	for(int i=1;i<=n;i++)
	{
		upd(f1[i],f2[i],g[i]);
		ans+=max(0,min(f1[i]-1,f2[i]+1)-lb[i]+1);
	}
	printf("%lld\n",ans+1);
	return 0;
}


Measured memory_bytes: 18048
from operator import itemgetter
import sys

def read():
    return sys.stdin.readline().rstrip()

n, k = map(int, input().split())
ab = sorted([[int(i) for i in read().split()] for _ in range(n)], key=itemgetter(0))
c = 0
for a, b in ab:
    c += b
    if c >= k:
        print(a)
        break

Measured memory_bytes: 23720
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

int const SIZ = 10001;

bitset<SIZ> sieve;
vector<int> primes;

void prepare() {
    primes.push_back(2);
    sieve.set();
    sieve ^= 3;
    for (int i=4; i<SIZ; i+=2) {
        sieve.set(i, 0);
    }
    for (int i=3; i<SIZ; i+=2) {
        if ( ! sieve[i]) continue;
        primes.push_back(i);
        for (int j=2; i*j<SIZ; ++j) {
            sieve.set(i*j, 0);
        }
    }
}

bool isprime(int n) {
    for (int i=0; i<(int)primes.size(); ++i) {
        if (n % primes[i] == 0 && n != primes[i]) {
            return false;
        }
    }
    return true;
}

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

    int n;
    cin >> n;

    prepare();

    unordered_map<int,int> checked;
    int m, ans = 0;
    for (int i=0; i<n; ++i) {
        cin >> m;
        if (isprime(m) && ! checked[m]) {
            ++ ans;
            checked[m] = 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		final int a = sc.nextInt() + sc.nextInt() + sc.nextInt() + sc.nextInt();
		final int b = sc.nextInt() + sc.nextInt() + sc.nextInt() + sc.nextInt();

		System.out.println(a >= b ? a : b);

	}

}

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

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

ll a, b, h, m;

lldo dtr(lldo deg) {
	return deg * 3.141592653589793238462643383279 / 180;
}

int main() {
	cout << setprecision(15);
	cin >> a >> b >> h >> m;
	lldo theta1 = dtr((lldo)360 * h / 12 + (lldo)m * 360 / 12 / 60), theta2 = dtr((lldo)360 * m / 60);
	lldo theta3 = abs(theta1 - theta2);
	cout << sqrt((lldo)a * a + (lldo)b * b - (lldo)2 * a * b * cos(theta3)) << endl;
	return 0;
}

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

int main() {
  int N , K , a;
  a=0;
  cin>>N>>K;
  for(int i=0 ; i<N ; i++){
    int x;
    cin>>x;
    if(x<= abs(K-x)){
      a +=2*x ;
    }
    else{
     a +=2*abs(K-x) ;
   }
  }
  cout<< a <<endl;
}
  

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

using namespace std;

using ll = long long;

int main(){
    ll a, b;
    cin >> a >> b;
    if(a <= b){
        for(ll i = 0; i < b; ++i){
            cout << to_string(a);
        }
    }else {
        for(ll i = 0; i < a; ++i){
            cout << to_string(b);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
//#define MOD 1000000007
#define MAXN 200005
#define INT_SIZE 32
#define debug cout<<"we are debugging"<<endl;
#define me(x) memset(x,0,sizeof(x))
const ll MOD = 1e9+7;
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
const ll MAX = 1000005;

ll fac[MAX], finv[MAX], inv[MAX];
void cmbinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i=2;i<MAX;i++) {
		fac[i] = fac[i-1]*i%MOD;
		inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i] = finv[i-1]*inv[i]%MOD;
	}
}
ll cmb(ll n, ll k) {
	if(n<k) return 0;
	if(n<0 || k<0) return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main()
{
     fast;
     cmbinit();
    ll n;
    cin>>n;
    ll ans=fast_expo(10,n);
    ans%=MOD;
    ll val=0,ans1;
    for(ll i=1;i<=n;i++)
    {
         ans1=((cmb(n,i))%MOD*(fast_expo(8,n-i))%MOD)%MOD;
         val=(val+ans1)%MOD;
         val%=MOD;
    }
    for(ll i=1;i<=n;i++)
    {
         ans1=((cmb(n,i))%MOD*(fast_expo(8,n-i))%MOD)%MOD;
         val=(val+ans1)%MOD;
         val%=MOD;
    }
    ll ans3=fast_expo(8,n)%MOD;
    val=(val+ans3)%MOD;
    cout<<(ans-val+MOD)%MOD;
}


Measured memory_bytes: 27068
from collections import deque
N,M=map(int,input().split())
graph=[[] for i in range(N)]
for m in range(M):
    A,B=map(int,input().split())
    graph[A-1].append(B-1)
    graph[B-1].append(A-1)
queue=deque([0])
distance=[0]*N
while queue:
    room=queue.popleft()
    for next_room in graph[room]:
        if distance[next_room]==0:
            distance[next_room]=room+1
            queue.append(next_room)
if 0 in distance:
    print("No")
else:
    print("Yes")
    print(*distance[1:],sep="\n")

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int a;
	cin >> a;
	int b = a + a*a + a*a*a;
	cout << b << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;

    REP(i, 1500) {
        ll c = (i + 1) * 8, d = (i + 1) * 10;
        if (c / 100 == a && d / 100 == b) {
            cout << (i + 1) << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;


#include <random>

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

    int D;
    cin>>D;
    int c[26];
    int q[D];
    rep(i,26){
        cin>>c[i];
    }
    int s[D][26];
    rep(i,D){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    map<int,int> m;
    int y=0;
    rep(i,D){

        int an=-INF;
        int x=0;
        rep(k,26){
            int a=ans;
            map<int,int> ma=m;
            a+=s[i][k];
            rep(j,26){
                if(j==k){
                    ma[k]=0;
                }else{
                    ma[j]++;
                    a-=ma[j]*c[j];
                }
            }
            if(an<a){
                x=k;
                an=a;
            }
        }
        y=x;
        ans+=s[i][y];
        rep(j,26){
            if(j==y){
                m[y]=0;
            }else{
                m[j]++;
                ans-=m[j]*c[j];
            }
        }
        y++;
        q[i]=y;
    }

    int tr=0;
    std::random_device rnd; 
    while(tr<=15000){
        int g=rnd()%26;
        int h=rnd()%26;
        tr++;
        int ansm=0;
        int r[D];
        rep(i,D){
            if(i==g){
                r[i]=h;
            }else{
                r[i]=q[i];
            }
        }
        map<int,int> mx;
        rep(i,D){
            ansm+=s[i][r[i]];
            rep(j,26){
                if(j==r[i]){
                    mx[r[i]]=0;
                }else{
                    mx[j]++;
                    ansm-=mx[j]*c[j];
                }
            }
        }
        if(ansm>ans){
            rep(i,D){
                q[i]=r[i];
            }
        }
    }
    rep(i,D){
        cout << q[i] << endl;
    }

    



}


Measured memory_bytes: 3696
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $a, $b) = split / /, <STDIN>);
say "Alice" if abs($a - $b) % 2 == 0;
say "Borys" if abs($a - $b) % 2 == 1;

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
//#define lli long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod  1000000007
using namespace std;
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{
       if(a.first!=b.first) return(a.first > b.first);
       else return (a.second<b.second);
} 
ll power(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)%m;
        n=n/2;
    }
    return result%m;
}
bool isPrime(ll k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    ll i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll bin(ll n)
{
    int di= 0;
    while(n)
    {   di=di+n%10;
        n=n/10;
        
    }
    return di;
}
 

int main(){
   IOS;
ll t;
t=1;
//cin>>t;

while(t--){
ll n;cin>>n;
ll x=n%1000;
  if(x==0) cout<<x;
  else cout<<1000-x;
}
return 0;}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define left nadnlassad
#define right asdaslknd
#define y1 kjdajasjdsas
#define nxt accepted
#define prev why_would_you_call_when_you_are_high
 
#define pb push_back
#define mp make_pair
#define mt make_tuple
 
#define f first
#define s second
 
#define ll long long
#define ld long double
#define ull unsigned ll
 
#define _hash pair<ll, ull>
#define pii pair<int, int>
#define uint unsigned int
#define puu pair<uint, uint>
 
#define sqr(x) ((x) * 1LL * (x))
 
#define vec vector<int>
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define endl "\n"
#define _bits(x) __builtin_popcountll(x)
 
using namespace std;
 
void rf() {
    #define fname "sparse"
    #ifdef SONY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif //SONY
}
 
const int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1};
const int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2};
const int Nx[4] = {0, 0, -1, 1};
const int Ny[4] = {1, -1, 0, 0};
 
const ll LINF = (ll) 5e18;
const int INF = 1e9 + 7;
 
const int N = 6e5 + 1;
const int MAXN = 1e6 + 50;
const double EPS = 1e-9, PI = 3.14159265359;
int n;
int a[N];
 
int main() {
    srand(time(0));
    //ios_base::sync_with_stdio(0), cin.tie(0);
    rf();
    cin >> n;
    vector<pii> v;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        v.pb(mp(a[i], i));
    }
    sort(all(v));
    int ans = 0, last = -INF;
    for (int i = 0; i < n; i++) {
        if (v[i].s % 2 != i % 2) { 
            ans++;
        }
    }
    cout << ans / 2;
    return 0;
}

Measured memory_bytes: 1656
def main():
    import sys
    input = sys.stdin.readline
    
    N,K = map(int,input().split())
    X = list(map(int,input().split()))
    ans = float("inf")
    for i in range(N-K+1):
        x = X[i]
        y = X[i+K-1]
        if ans > y-x + min(abs(x),abs(y)):
            ans = y-x + min(abs(x),abs(y))
    print(ans)
    
    
    
main()

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

int main() {
  string S;cin>>S;
  bool can=true;
  int l=S.size();
  for(int i=0;i<l;i++){
    if(i%2==0 && S.at(i)=='L'){
      can=false;
      break;
    }
    else if(i%2==1 && S.at(i)=='R'){
      can=false;
      break;
    }
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  
}



Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
#define pi 3.1415926535
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	double r;
	cin>>r;
	cout<<fixed<<setprecision(10);
	cout<<2*pi*r;
	return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
bool cmp(string a,string b){
	return a<=b;;
}
int main(){
	string cc[200010];
	int n,i,j,k,l,cnt=1;
	cin>>n;
	for(i=1;i<=n;i++)cin>>cc[i];
	sort(cc+1,cc+1+n);
	for(i=2;i<=n;i++){
		if(cc[i]!=cc[i-1])cnt++;
	}
	cout<<cnt;
	getchar();getchar();
} 

Measured memory_bytes: 9884
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    int tmp = n;
    int x = 0;

    while(n > 0){
        x += n % 10;
        n = n /10;
    }

    if(tmp % x == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
	while(u != NIL && k != u->key) {
		if(k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com[0] == 'f') {
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		} else if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 22032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int a, b;
	int n;
	cin >> n;
	int x = 0;
	bool flag = false;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a == b) {
			x++;
		} else {
			x = 0;
		}
		if (x == 3) {
			flag = true;
		}
	}

	printf("%s", flag ? "Yes": "No");

	return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
using namespace std;

const int MAX_H = 1001;
const int MAX_W = 1001;

int H, W, N;
string F[MAX_H];
void Input() {
    cin >> H >> W >> N;
    for (int i = 0; i < H; i++) cin >> F[i];
}

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

struct S {
    int y, x, c;
    S(int y = 0, int x = 0, int c = 0) : y(y), x(x), c(c) {}
};
int bfs(int sy, int sx, int gy, int gx) {
    queue<S> Q;
    static bool U[MAX_H][MAX_W];
    memset(U, 0, sizeof(U));
    Q.push(S(sy, sx, 0));
    U[sy][sx] = true;
    while (!Q.empty()) {
        S c = Q.front(); Q.pop();
        if (c.y == gy && c.x == gx) return c.c;
        for (int i = 0; i < 4; i++) {
            int ny = c.y + dy[i],
                nx = c.x + dx[i];
            if (ny < 0 || ny >= H) continue;
            if (nx < 0 || nx >= W) continue;
            if (F[ny][nx] == 'X') continue;
            if (U[ny][nx]) continue;
            Q.push(S(ny, nx, c.c + 1));
            U[ny][nx] = true;
        }
    }
    assert(0);
}

pair<int, int> Find(char c) {
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if (c == F[y][x]) return make_pair(y, x);
        }
    }
    assert(0);
}

void Solve() {
    string s = "S";
    for (int i = 0; i < N; i++) {
        s.push_back(i + 1 + '0');
    }
    int Ans = 0;
    for (int i = 0; i < N; i++) {
        pair<int, int> from = Find(s[i]),
                         to = Find(s[i + 1]);
        Ans += bfs(from.first, from.second, to.first, to.second);
    }
    cout << Ans << endl;
}

int main() {
    Input(); Solve();
    return 0;
}

Measured memory_bytes: 3260
#!/user/bin/env pypy3
import sys
from typing import NamedTuple, List


def fast_input():
    return sys.stdin.readline()[:-1]


class Position(NamedTuple):
    t: int
    x: int
    y: int

    def _calc_diff_move(self, position) -> int:
        diff_x = self.x - position.x
        diff_y = self.y - position.y
        return abs(diff_x) + abs(diff_y)

    def can_move_from(self, prev) -> bool:
        diff_t = self.t - prev.t
        diff_move = self._calc_diff_move(prev)
        if not diff_t % 2 == diff_move % 2:
            return False
        return diff_t >= diff_move


def result_format(b: bool) -> str:
    return "Yes" if b else "No"


def solve(positions: List[Position]) -> bool:
    positions = [Position(t=0, x=0, y=0)] + positions
    for p_ind in range(len(positions) - 1):
        p_curr = positions[p_ind]
        p_next = positions[p_ind + 1]
        if not p_next.can_move_from(p_curr):
            return False
    return True


def main():
    n = int(fast_input())
    positions = []
    for _ in range(n):
        t, x, y = list(map(int, fast_input().split()))
        positions.append(Position(t=t, x=x, y=y))
    result = solve(positions)
    print(result_format(result))


main()


Measured memory_bytes: 94084
#include <stdio.h>
 
int main (void)
{
  int n,k;
  scanf("%d %d",&n,&k);
  int ans = k;
  
  for(int i = 1;i < n;i++){
    ans= ans*(k-1);
  }
  
  printf("%d",ans);
  
  return 0;
}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    ll n,ans=0;
    cin >> n;
    vector<ll> v;
    for(ll i=0;i<n;i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    for(ll i=1;i<v.size();i++)
    {

        if(v[i-1] > v[i])
        {

            ll x=v[i-1]-v[i];
            ans+=x;
            v[i]+=x;
        }
    }
    cout << ans;
}


Measured memory_bytes: 5344
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
    int a;
    cin >> a;
    
    double b;
    
    b = a*a*a/27.0;
    
    cout << fixed;
    cout << setprecision(7) << b;

    return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 110;

int n;
int h[N];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> h[i];

    int now = -1, res = 0;
    for(int i = 1; i <= n; i++)
        if(now <= h[i])
        {
            now = h[i];
            res++;
        }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

X = INT()
ans = ceil((-1 + (1 + 8*X)**0.5)/2)
print(int(ans))



Measured memory_bytes: 13608
#include <iostream>
using namespace std;
int main()
{
  int n,y,d;
  cin>>n>>y;
  int a=-1;
  int b=-1;
  int c=-1;
  int i=0;
  while(c==-1&&i<=n){
    if((((y-1000*n-9000*i)%4000)==0)&&(y-1000*n-9000*i>=0)){
      a=i;
      b=(y-1000*n-9000*a)/4000;
      d=n-a-b;
      if(d>=0){
          c=d;
      }
      else{
          a=-1;
          b=-1;
      }
    }
    i++;
  }
  cout<<a<<" "<<b<<" "<<c<<'\n';
  return 0;
}

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

int main() {
	ll K,N;
	cin >> N >>K;
	vector<ll> h(N);
	for(int i=0;i<N;i++){
		cin >> h.at(i);
	}
	sort(h.begin(),h.end());
	ll min=100000000000;
	for(int i=0;i<=N-K;i++){
		if(h.at(i+K-1)-h.at(i)<min){
			min=h.at(i+K-1)-h.at(i);
		}
	}
	cout<<min<<endl;
	
	return 0;
}



Measured memory_bytes: 1024
//
//  main.cpp
//  ABC172F
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    ll a[303]={};
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll s=a[1]+a[2];
    ll c=0;
    for(int i=3;i<=n;i++){
        c^=a[i];
    }
   // if(s<c||(s-c)%2==1){ // cが大きい時、不可能
   //     cout<<-1<<endl;
   //     return 0;
   // }
    ll d=s-c;
    if(d<0||d%2==1){
        cout<<-1<<endl;
        return 0;
    }
    d/=2;
    if(d>a[1]||d&c){
        cout<<-1<<endl;
        return 0;
    }
    bitset<40> d40,ap40,c40;
    d40=bitset<40>(d);
    c40=bitset<40>(c);
    vector<ll>free;
    rep(i,40){
        if(c40[i]==0) {
            ap40.set(i,d40[i]);
        }else{
            free.push_back(i);
        }
    }
    sort(free.rbegin(),free.rend());
    ll r_ans=ap40.to_ullong();
    ll cand=0;
    for(auto& x:free){
        if(ap40.set(x,1).to_ullong()>a[1]){
            ap40.set(x,0);
        }
        cand=(ll)ap40.to_ullong();
        r_ans=max(r_ans,cand);
    }
    if(r_ans==0){ // 山１を全て移動させることはできない
        cout<<-1<<endl;
    }else{
        cout<<a[1]-r_ans<<endl;
    }
    return 0;
}


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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<i64> A(N), B(N);
  vector<pair<i64, i64>> se, es;

  REP(i, N) {
    i64 s, e;
    cin >> s >> e;
    se.emplace_back(s, e);
    es.emplace_back(e, s);
  }
  sort(es.begin(), es.end());
  sort(se.rbegin(), se.rend());

  i64 ans;
  if (N % 2 == 1) {
    ans = es[N / 2].first - (se[N / 2].first - 1);
  } else {
    i64 e1 = es[N / 2 - 1].first, e2 = es[N / 2].first;
    i64 s1 = se[N / 2].first, s2 = se[N / 2 - 1].first;
    ans = (e1 + e2) - (s1 + s2 - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 12920
<?php
  
 fscanf(STDIN,"%d",$X);

for($i=2;$i<=$X;$i++){

    if($X%$i==0 && $X != $i){
      $i=2;
      $X++;
      continue;
    }
  if($X == $i){
    echo $X."\n";
  }
}


  



                  
                  
                  



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

int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int j=0;
  while (A>0&&C>0){
    C-=B;
    if(C<=0){
      j=1;
      break;
    }
    A-=D;
  }
  if(j==1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

int main(){
    int n, m; cin >> n >> m;
    vector<string> data(n);
    for (int i = 0; i < n; i++) cin >> data[i];

    mf_graph<int> ans(n * m + 2);
    int s = n * m, t = s + 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (data[i][j] == '#') continue;
            if ((i + j) % 2 == 1) {
                ans.add_edge(m * i + j, t, 1);
            }
            else {
                ans.add_edge(s, m * i + j, 1);
                for (int k = 0; k < 4; k++) {
                    int ni = i + di[k], nj = j + dj[k];
                    if (0 <= ni && ni < n && 0 <= nj && nj < m && data[ni][nj] == '.') {
                        ans.add_edge(m * i + j, m * ni + nj, 1);
                    }
                }
            }
        }
    }

    cout << ans.flow(s, t) << "\n";

    for (auto p : ans.edges()) {
        if (p.from == s || p.to == t || p.flow == 0) continue;
        int x = p.from / m;
        int y = p.from % m;
        int nx = p.to / m;
        int ny = p.to % m;
        if (x + 1 == nx) {
            data[x][y] = 'v';
            data[nx][ny] = '^';
        }
        else if (y + 1 == ny) {
            data[x][y] = '>';
            data[nx][ny] = '<';
        }
        else if (x - 1 == nx) {
            data[x][y] = '^';
            data[nx][ny] = 'v';
        }
        else {
            data[x][y] = '<';
            data[nx][ny] = '>';
        }
    }

    for (int i = 0; i < n; i++) {
        cout << data[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 5392
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
    for( int iii=1; ; ++iii ) {
        int w, n;
        cin >> w;
        if ( w == 0 )
            break;
        cin >> n;

        struct { int v, w; } item[1000] = {{0, 0}};
        for( int i=0; i<n; ++i ) {
            scanf( "%d,%d", &item[i+1].v, &item[i+1].w );
        }

        int dp[1002][1002] = {};

        int max_w = 0, max_v = 0;
        for( int ni=1; ni<n+1; ++ni ) {
            for( int wi=1; wi<w+1; ++wi ) {
                int const bef_ni = ni - 1;
                int const bef_wi = wi - item[ni].w;

                dp[ni][wi] = [&]() -> int {
                    if ( bef_wi >= 0 ) {
                        return max( dp[bef_ni][wi], dp[bef_ni][bef_wi] + item[ni].v );
                    } else {
                        return dp[bef_ni][wi];
                    }
                }();

                if ( dp[ni][wi] > max_v || ( dp[ni][wi] == max_v && wi < max_w ) ) {
                    max_v = dp[ni][wi];
                    max_w = wi;
                }
            }
        }

        cout << "Case " << iii << ":" << endl
             << max_v << endl
             << max_w << endl;
    }
}

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

bool table[10000000];

int main() {
    while (true) {
        int m, n;
        cin >> m >> n;
        if (m == 0 && n == 0) {
            break;
        }
        for (int i = 0; i < 10000000; i++) {
            table[i] = true;
        }
        
        int cnt = 0;
        int ans = -1;
        for (int i = m; i < 10000000; i++) {
            if (table[i]) {
                cnt++;
                for (int j = 2*i; j < 10000000; j += i) {
                    table[j] = false;
                }
            }
            if (cnt == n + 1) {
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 12832
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

struct point{
	point(){}
	double x;
	double y;
};

bool check(point *pos){
	double dot = ((pos[0].x-pos[1].x)*(pos[2].x-pos[3].x))+((pos[0].y-pos[1].y)*(pos[2].y-pos[3].y));
	if(dot > -0.0000000001 && dot < 0.0000000001){
		return true;
	}
	return false;
}

int main(){
	point pos[4];
	while(cin >> pos[0].x >> pos[0].y >> pos[1].x >> pos[1].y >> pos[2].x >> pos[2].y >> pos[3].x >> pos[3].y){
		if(cin.eof()) break;
		if(check(pos)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
n,t = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
Min = a[0]
dif  = 0
for i in range(1,n):
    if dif < a[i] - Min:
        dif = a[i] - Min
        ans = 1
    elif dif == a[i] - Min:
        ans += 1
    Min = min(Min,a[i])

print(ans)

Measured memory_bytes: 62704
#include<iostream>
 #include<string>
 using namespace std;
 
 int main()
 {
 	string str;
 	while(cin>>str)
 	{
 	    bool flag=false;
 		int len=str.length();
 		for(int i=1;i<len;i++)
 		{
 			if(str[i]!='9')
 			{
 				flag=true;
 				break;
			 }
			 if(flag) break;
		 }
 		int sum=0;
 		sum=sum+(len-1)*9;
 		if(flag) sum=sum+(str[0]-'0')-1;
 		else sum=sum+(str[0]-'0');
 		cout<<sum<<endl;
	 }
 	return 0;
 }

Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 2222
int p[ N ] , sz[ N ];
void init_p( int n ){
  for( int i = 0 ; i < n ; i ++ ){
    p[ i ] = i;
    sz[ i ] = 1;
  }
}
int f( int x ){
  return x == p[ x ] ? x : p[ x ] = f( p[ x ] );
}
void uni( int x , int y ){
  x = f( x ); y = f( y );
  if( x == y ) return;
  p[ x ] = y;
  sz[ y ] += sz[ x ];
}
void build(){

}
int n , m;
char c[ N ][ N ];
void init(){
  n = getint();
  m = getint();
  for( int i = 0 ; i < n ; i ++ )
    scanf( "%s" , c[ i ] );
}
int s[ N ] , ans , in[ N ] , stmp;
void cal(){
  vector< pair<int,int> > v;
  for( int i = 1 ; i < m ; i ++ )
    v.push_back( { s[ i ] , i } );
  sort( v.begin() , v.end() , greater< pair<int,int> >() );
  init_p( m );
  ++ stmp;
  for( auto i : v ){
    int who = i.second;
    in[ who ] = stmp;
    if( in[ who - 1 ] == stmp ) uni( who - 1 , who );
    if( in[ who + 1 ] == stmp ) uni( who + 1 , who );
    ans = max( ans , i.first * ( sz[ f( who ) ] + 1 ) );
  }
}
void solve(){
  ans = max( n , m );
  for( int i = 1 ; i < m ; i ++ )
    s[ i ] = 1;
  for( int i = 1 ; i < n ; i ++ ){
    for( int j = 1 ; j < m ; j ++ ){
      if( ( c[ i     ][ j ] == c[ i     ][ j - 1 ] ) ==
          ( c[ i - 1 ][ j ] == c[ i - 1 ][ j - 1 ]) )
        s[ j ] ++;
      else
        s[ j ] = 1;
    }
    cal();
  }
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;

int main() {
  int s[3];
  int ans[3];
  rep(i,0,3)cin>>s[i];
  ans[0]=s[0]+s[1];
  ans[1]=s[0]+s[2];
  ans[2]=s[1]+s[2];
  cout<<min({ans[0],ans[1],ans[2]})<<endl;
}

Measured memory_bytes: 256
#include <iostream>
        #define endl '\n'
    	#define ll long long
         
        using namespace std;
         
        int main(void)
        {
          cin.tie(NULL); ios_base::sync_with_stdio(false);
          int N; cin >> N;
          ll acc = 0;
          ll temp;
          while(N--)
          {
            cin >> temp;
            acc += temp - 1;
          }
          cout << acc << endl;
          return 0;
        }

Measured memory_bytes: 888
#include<stdio.h>
int main(void)
{
	int a[5],min,t=0,n,i,j;
	for(i=0; i<5; i++)
	scanf("%d", &a[i]);
	for(i=0; i<5; i++)
	{
		min=10;
		for(j=0; j<5; j++)
		{
			if(a[j]!=0&&(10-(a[j]%10+t%10)%10)%10<min)
			{
				min=(10-(a[j]%10+t%10)%10)%10;
				n=j;
			}
		}
		t+=a[n];
		if(i<4)
		t+=min;
		a[n]=0;
	}
	printf("%d\n", t);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define mod 1000000007
using namespace std;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

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


Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#define N_MAX 100005
#define NIL -1

void print(int t);
int get_depth(int t);
int get_height(int t);
int get_sibling(int t);
int get_degree(int t);

struct node
{
  int parent;
  int left;
  int right;
};

struct node tree[N_MAX];


int get_depth(int t)
{
  int depth=0;
  while(tree[t].parent != NIL){
    t = tree[t].parent;
    depth ++;
  }
  
  return depth;
}

int get_height(int t)
{
  int height1=0;
  int height2=0;

  if(tree[t].right != NIL){
    height1 = get_height(tree[t].right) + 1;
  }
  if(tree[t].left != NIL){
    height2 = get_height(tree[t].left) + 1;
  }

  if(height1>height2) return height1;
  else return height2;
}

int get_sibling(int t)
{
  if(tree[t].parent == NIL) return NIL;

  if(tree[tree[t].parent].left != t && tree[tree[t].parent].left != NIL){
  return tree[tree[t].parent].left;
  }

  if(tree[tree[t].parent].right != t && tree[tree[t].parent].right != NIL){
  return tree[tree[t].parent].right;
  }
  return NIL;
}

int get_degree(int t)
{
  if(tree[t].left != NIL && tree[t].right != NIL) return 2;
  if(tree[t].left == NIL && tree[t].right == NIL) return 0;
  else return 1;
}

void print(int t)
{
  printf("node %d: ",t);

  printf("parent = %d, ",tree[t].parent);

  printf("sibling = %d, ",get_sibling(t));

  printf("degree = %d, ",get_degree(t));

  printf("depth = %d, ", get_depth(t));
  
  printf("height = %d, ", get_height(t));

  if(tree[t].parent == NIL){
    printf("root\n");
  }
  else if(tree[t].left == NIL && tree[t].right == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}



int main()
{
  int n, i;
  int id,left=0, right;

  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    tree[i].parent=NIL;
    tree[i].left=NIL;
    tree[i].right=NIL;
  }

  
  for(i=0; i<n; i++){
    scanf("%d", &id);
    scanf("%d%d", &left, &right);
    tree[id].left = left;
    tree[id].right = right;

    if(left != NIL) tree[left].parent = id;
    if(right != NIL) tree[right].parent = id;
  }
  
  for(i=0; i<n; i++){
    print(i);
  }
  
  return 0;
}

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

using namespace std;

typedef pair<int, int> P;

int main() {
  int N;
  cin >> N;
  set<int> s;
  for (int i = 0; i < N; ++i) {
    int d;
    cin >> d;
    s.insert(d);
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  int n;
  string s;
  cin >> s;
  if (s == "ABC") {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }
}

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

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

    std::vector<int> p(n);
    for (auto&& pi : p) std::cin >> pi;

    int m = 0;
    for (int i = 1; i < n - 1; ++i)
        if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) ++m;
    
    std::cout << m << std::endl;
}

Measured memory_bytes: 256