akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

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

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

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

struct Edge {
    int to, id;

    Edge(int to, int id): to(to), id(id) {}
};

vector<Edge> g[55];
vector<int> es;

bool dfs(int cur, int t, int p = -1) {
    if(cur == t) return true;
    for(Edge e : g[cur]) {
        if(e.to == p) continue;
        if(dfs(e.to, t, cur)) {
            es.push_back(e.id);
            return true;
        }
    }
    return false;
}


int main() {
    int N;
    cin >> N;
    REP(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }

    int M;
    cin >> M;

    vector<ll> eset(M);
    REP(i, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        es = vector<int>();
        dfs(u, v);
        for(int e: es) {
            eset[i] |= 1ll<<e;
        }
    }

    ll ans = 0;
    REP(bit, 1<<M) {
        ll mask = 0;
        REP(j, M)
            if(bit >> j & 1) mask |= eset[j];

        int bit_cnt = __builtin_popcountll(mask);
        ll now = 1ll<<(N - 1 - bit_cnt);
        if(__builtin_popcountll(bit)%2 == 0)
            ans += now;
        else
            ans -= now;
    }
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int n, a1, a2, a3, a4, l1, l2, i, k;

int main() {
scanf("%d %d", &n, &k);
if (n < 2 * k - 1) {
	printf("-1\n");
	return 0;
}
a1 = k;
a2 = k + 2 * n - 1;
a3 = k + 2 * n;
a4 = k + 3 * n - 1;
l1 = n / 2 + n % 2;
for (i=0;i<l1;i++) printf("%d %d %d\n", a1 + i, a3 - l1 + i, a3 + i * 2);
l2 = n - l1;
for (i=0;i<l2;i++) printf("%d %d %d\n", a1 + l1 + i, a1 + l1 + i + l2, a3 + i * 2 + 1);
return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<iomanip>
#include<vector>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007

ull N;
double dp[301][301][301];
double get_dp(int a1,int a2,int a3)
{
  if(a1<0||a2<0||a3<0)
  {
    return 0;
  }
  return dp[a1][a2][a3];
}

int main()
{
  ull i,j,k,a;
  cin >> N;
  vector<int> s(3,0);
  for(i=0;i<N;++i)
  {
    cin >> a;
    ++s[a-1];
  }
  for(i=0;i<=s[2];++i)
  {
    for(j=0;i+j<=s[1]+s[2];++j)
    {
      for(k=0;i+j+k<=N;++k)
      {
        a=i+j+k;
        if(a)
        {
        dp[k][j][i]=(double)(N)/(a)
          			+(double)k/(a)*get_dp(k-1,j,i)
          			+(double)j/(a)*get_dp(k+1,j-1,i)
          			+(double)i/(a)*get_dp(k,j+1,i-1);
        }
        else
        {
          dp[k][j][i]=0;
        }
      }
    }
  }
  cout << setprecision(11) << dp[s[0]][s[1]][s[2]];
  return 0;
}

Measured memory_bytes: 213248
#include<cstdio>
#include<iostream>
using namespace std;
int a[5];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		a[i]=-1;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(a[x]>-1&&a[x]!=y)
		{
			puts("-1");
			return 0;
		}
		a[x]=y;
	}
	if(a[1]==0&&n!=1)
	{
		puts("-1");
		return 0;
	}
	if(a[1]==-1&&n!=1)
		a[1]=1;
	if(n==1&&a[1]==-1)
		a[1]=0;
	for(int i=1;i<=n;i++)
		printf("%d",a[i]>-1?a[i]:0);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define MOD 1000000007
#define DEBUG 0
#define REP(i,n) for(int i=0;i<n;i++)

#define F 1
#define S 2

int main(){

	lli n;
	map<lli,vector<lli>> m;

	cin>>n;
	REP(i,n-1){
		lli a,b;
		cin>>a>>b;
		m[a].push_back(b);
		m[b].push_back(a);
	}

	/* 1からNまで幅優先探索を行う*/
	/* この時どんな経路をたどったか覚えておく必要がある*/
	/* フェネックすぬけくん順番順番に行う */
	/* ターン数を覚えておき、新しいターンになったら次の人に手番を回す */
	lli flag[100010];
	REP(i,100010)flag[i]=0;

	queue<lli> f,s;
	queue<lli> fsize,ssize;

	f.push(1);
	s.push(n);

	fsize.push(0);
	ssize.push(0);
	flag[1]=F;
	flag[n]=S;
	
	while(f.size()!=0 || s.size()!=0){
		/*まずfのターン*/
		lli cnt=0;
		lli before;
		while(f.size()!=0){
			lli nowSize = fsize.front();
			if(cnt!=0){
				if(before!=nowSize)break;
			}
			before=nowSize;
			cnt++;
			lli ftop = f.front();
			f.pop();
			fsize.pop();
			for(auto e:m[ftop]){
				if(flag[e]!=0)continue;
				flag[e]=F;
				f.push(e);
				fsize.push(nowSize+1);
			}
		}

		/*次にSのターン*/
		cnt=0;
		while(s.size()!=0){
			lli nowSize = ssize.front();
			if(cnt!=0){
				if(before!=nowSize)break;
			}
			before=nowSize;
			cnt++;
			lli stop = s.front();
			s.pop();
			ssize.pop();
			for(auto e:m[stop]){
				if(flag[e]!=0)continue;
				flag[e]=S;
				s.push(e);
				ssize.push(nowSize+1);
			}
			cnt++;
		}
	}

	/*最終結果はFとSのそれぞれ多い方*/

	lli ansF=0,ansS=0;

	REP(i,100010){
		if(flag[i]==F)ansF++;
		else if(flag[i] == S)ansS++;
		else;
	}
	if(ansF > ansS)cout<<"Fennec"<<endl;
	else cout << "Snuke"<<endl;

	return 0;
}
 

Measured memory_bytes: 12544
// @DateTime:    2020-04-22 15:05:23
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast", "-funroll-all-loops", "-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(), (x).end()
#define trav(a, x) for (auto &a : x)
#define close \
    std::ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c)         \
    (sort(c.begin(), c.end()), \
     c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define CASET    \
    int ___T;    \
    cin >> ___T; \
    for (int __CS = 1; __CS <= ___T; __CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
LL bin(LL x, LL n, LL MOD) {
    LL ret = MOD != 1;
    for (x %= MOD; n; n >>= 1, x = x * x % MOD)
        if (n & 1) ret = ret * x % MOD;
    return ret;
}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6 + 10;
constexpr int mod = 1e9;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base = 2333, P_1 = 19260811, P_2 = 999998639;
void add(ll &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}
void dec(ll &a, int b) {
    a -= b;
    if (a < 0) a += mod;
}
int main() {
    ll n , k  , s;
    cin >> n >> k >> s;
    // vector<ll> a(n);
    for(int i = 1; i <= k;i++){
        cout << s << ' ';
    }
    add(s,1);
    for(int i= k+1; i <= n; i++){
        cout << s << ' ';
    }
}

Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = 0;
        int b = 0;
        for (int i = 0; i < n; i++) {
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            
            if (a < ai) {
                a = ai;
                b = bi;
            }
        }
        
        System.out.println(a+b);
    }
}


Measured memory_bytes: 58588
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n1, s, n2 = LS()
ans = 'A' + s[0] + 'C'
print(ans)


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100000
#define LARGE 2000000000

typedef struct {
  char suit;
  int value;
}Card;

Card L[MAX/2+2],R[MAX/2+2];

void merge(Card*,int,int,int,int);
void mergeSort(Card*,int,int,int);
int partition(Card*,int,int,int);
void quickSort(Card*,int,int,int);

void merge(Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].value=R[n2].value=LARGE;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }else{
      A[k]=R[j++];
    }
  }
}

void mergeSort(Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(Card A[],int n,int p,int r){
  int i,j;
  Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main()
{
  int n,i,v;
  Card A[MAX],B[MAX];
  char command[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",command,&v);
    A[i].suit=B[i].suit=command[0];
    A[i].value=B[i].value=v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}

Measured memory_bytes: 4932
a, b = map(int, input().split())
c = []
for i in range(a):
  *s, = map(int, input().split())
  c += s[1:]
count=[]
e = c[:]
d=list(set(c))

for i in d:
  if e.count(i) == a:
    count.append(i)
    
print(len(count))


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    bool ok = true;
    for (int i = 0; i + 1 < N; i++) {
        if (A[i] > A[i + 1]) ok = false;
    }
    if (ok) {
        cout << "YES" << endl;
        return;
    }

    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            vector<int> B = A;
            swap(B[i], B[j]);
            bool ok = true;
            for (int k = 0; k + 1 < N; k++) {
                if (B[k] > B[k + 1]) {
                    ok = false;
                }
            }
            if (ok) {
                cout << "YES" << endl;
                return;
            }
        }
    }
    cout << "NO" << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 1e5+9;

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    ll i,n,t,k,j,x=0,y=0,m;
    ll a[32]  ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin>>n;
    cout<<a[n-1]<<endl;

    
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int N,Q;
ll A[100010];
ll ac[100010];
ll bc[100010];
int main(){
	cin>>N>>Q;
	rep(i,N) cin>>A[i];
	rep(i,N) ac[i+1] = ac[i] + A[i];
	rep(i,N){
		bc[i] = (i>=2?bc[i-2]:0) + A[i];
	}
	rep(_,Q){
		ll X;
		cin>>X;
		auto better = [&](ll a,ll b){
			if(abs(X-a) != abs(X-b)) return abs(X-a) < abs(X-b);
			return a<b;
		};
		auto touch = [&](int t){
			if(t+t+1>N) return true;
			if(better(A[N-t-1],A[N-t-t-1])) return true;
			return false;
		};
		int ub = N, lb = 0;
		while(ub-lb>1){
			int m = (ub+lb)/2;
			if(touch(m)) ub = m;
			else lb = m;
		}
//		show(ub);
		ll res = (ac[N]-ac[N-ub]) + (N-1-ub-ub>=0 ? bc[N-1-ub-ub] : 0);
		cout<<res<<endl;
	}
}

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

int main() {
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int main() {
  ll H, W;
  cin >> H >> W;
  if (H == 1ll || W == 1ll) {
    cout << 1 << endl;
  } else {
    cout << (H * W + 1ll) / 2ll << endl;
  }
};


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x1, x2, d;
    scanf("%d%d", &x1, &x2);
    if (x1 > x2){
        d = x1 - x2;
        printf("%d\n", d);
    }
    else if(x2 > x1){
        d = x2 - x1;
        printf("%d\n", d);
    }
    else{
        d = 0;
        printf("%d\n", d);
    }
    return 0;
}


Measured memory_bytes: 2100
"""
隣接している展望台よりも高いかどうかを調べる
良くない展望台と判明した展望台は記録していく
"""
N,M = map(int,input().split())
H = list(map(int,input().split()))
roads = [[]for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    roads[a].append(b)
    roads[b].append(a)


count = 0
for i in range(1,N+1):
    h = H[i-1]
    judge = 1
    for j in roads[i]:
        if h <= H[j-1]:
            judge = 0
            break
    if judge == 1:
        count += 1

print(count)



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

#define line "\n"
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define ll long long int
#define lb long double
#define ull unsigned long long int
#define pb push_back
#define vi vector < int >
# define vs vector < string >
# define vb vector < bool >

# define pii pair < int , int >
# define pll pair < ll , ll >   
# define pld pair < ld , ld >
# define pDD pair < D , D >


# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
using namespace std;
void solve()
{
int a;
cin>>a;
cout<< a+pow(a,2)+pow(a,3);
}
int main()
{fast
//ll t;
//cin>>t;
//while(t--)
{
solve();
}

}



Measured memory_bytes: 4224
#include <iostream>
using namespace std;
int i ;
char A= ',' ;
string  S;
int main(){
cin>>S;
for(i=0;i<19;i++){
	
	if (S[i]==A ){
	cout<<" "; 
	continue;
	}
	cout<<S[i];
}
	return 0;
	}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<std::vector<lint>>a(10,std::vector<lint>(10));
    for(lint i=1;i<=n;i++){
        lint x=i%10;
        lint y=i;for(;y>=10;y/=10);
        a.at(x).at(y)++;
    }
    lint ans=0;
    for(lint i=1;i<10;i++)for(lint j=1;j<10;j++){
        ans+=a.at(i).at(j)*a.at(j).at(i);
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
std::map<int32_t, int32_t> A;
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; i++)
	{
		int32_t a;
		in >> a;
		A[a]++;
	}
	int32_t res = 0;
	for (auto& i : A) {
		if (i.first <= i.second) {
			res += i.second - i.first;
		}
		else {
			res += i.second;
		}
	}

	out << res << endl;
	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;

int32_t target_x, target_y;
char S[8100];
std::vector<int32_t> move_x;
std::vector<int32_t> move_y;

std::unordered_map<int32_t,bool> dp[8000];
bool funcx(int32_t i, int32_t now)
{
	if (i == move_x.size()) { return now == target_x; }
	if (dp[i].count(now)) { return dp[i][now]; }
	return dp[i][now]=funcx(i + 1, now + move_x[i]) || funcx(i + 1, now - move_x[i]);
}
bool funcy(int32_t i, int32_t now)
{
	if (i == move_y.size()) { return now == target_y; }
	if (dp[i].count(now)) { return dp[i][now]; }
	return dp[i][now] = funcy(i + 1, now + move_y[i]) || funcy(i + 1, now - move_y[i]);
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> S>> target_x>> target_y;
	{
		auto iter_s = S;
		while (*iter_s == 'F') {
			--target_x;
			++iter_s;
		}
		bool xmode = true;
		while (*iter_s == 'T') {
			++iter_s; xmode = !xmode;
			int32_t count = 0;
			while (*iter_s == 'F') {
				++count;
				++iter_s;
			}
			if (xmode) { move_x.push_back(count); }
			else { move_y.push_back(count); }
		}
	}

	bool x = funcx(0, 0);
	for (auto& i : dp) { i.clear(); }
	if (x&&funcy(0, 0)) {
		out << "Yes\n";
	}
	else {
		out << "No\n";
	}

	return 0;
}
#endif


Measured memory_bytes: 4736
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
struct A{
    string s;
    int p;
    int order;
};

bool compare_by_b(pair<long, long> a, pair<long, long> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
    int N;
    cin>>N;
    int d[N];
    FOR(i,N){
        cin>>d[i];
    }
    sort(d,d+N);

    int ans=d[(N/2)]-d[N/2 -1];

    

    cout <<ans<< endl;
    return 0;
}

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

int main(){
	int N; cin >> N;
	while(N--){
		int a[9],b[9];
		rep(i,9)cin >> a[i];
		rep(i,9)cin >> b[i];
		sort(a,a+9),sort(b,b+9);
		
		double c[2] = {0};
		do{
			int r[2]={0};
			rep(i,9)r[a[i]>b[i]]+=a[i]+b[i];
			c[r[0]>r[1]]++;
		}while(next_permutation(a,a+9));
		rep(i,2)c[i]/=362880;
		printf("%.5lf %.5lf\n",c[0],c[1]);
	}
}

Measured memory_bytes: 908
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=0;
  for(int i=0;i<n;i++)ans=__gcd(a[i],ans);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



public class Main {

	private static final int BIG_NUM  = 2000000000;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		long sum = 0;
		int minimum = BIG_NUM,maximum = -BIG_NUM;

		try {

			int N = Integer.parseInt(br.readLine());

			String first[] = br.readLine().split("[\\s]+");
			int array[] = new int[first.length];

			for(int i = 0; i < first.length; i++){

				array[i] = Integer.parseInt(first[i]);
				minimum = Math.min(minimum, array[i]);
				maximum = Math.max(maximum, array[i]);
				sum += array[i];
			}

			System.out.printf("%d %d %d\n",minimum,maximum,sum);

		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}





Measured memory_bytes: 31976
import java.util.*;

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

      Scanner sc = new Scanner(System.in);
      
      char c = sc.next().charAt(0);
      
      if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
          System.out.println("vowel");
      } else {
          System.out.println("consonant");  
      }

      sc.close();
    }
}


Measured memory_bytes: 22740
#include<stdio.h>
int main(void){
  int N,i,j;
  scanf("%d",&N);
  //int cmax=N/4;
  //int dmax=N/7;
  for(i=0;i<=(N/4);i++){
    for(j=0;j<=(N/7);j++){
      if(N==(i*4+j*7)){
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e15;

int main(){
    vector<ll> a(3);
    rep(i,3){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    if(a[0]+a[1]==a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
int prime[100001];
int ans[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n,cnt=0;
	cin>>n;
	prime[0]=prime[1]=-1;
    for(int i=2;i<=100000;i++){
        if(prime[i]!=-1){
            prime[i]=1;
            for(int j=i+i;j<=100000;j+=i)prime[j]=-1;
        }
    }
	for(int i=3;i<=100000;i+=2){
		if(prime[i]==1){
			if(prime[(i+1)/2]==1) ans[i]++;
		}
	}
	for(int i=3;i<=100000;i++) ans[i]+=ans[i-1];
	while(n--){
		int l,r;
		cin>>l>>r;
		cout<<ans[r]-ans[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#define cinf(n,x,y,z) for(int i=0;i<(n);i++) cin >> x[i]>>y[i]>>z[i];
typedef long long int ll;
using namespace std;

int main(){
	ll n,a,b; cin >>n>>a>>b;
	if(a>b){
		cout <<0 << endl;
		return 0;
	}
	if(a!=b&&n==1){
		cout <<0 << endl;
		return 0;
	}
	else{
		ll ans=b*(n-2)-a*(n-2)+1;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = []
for i in range(N):
    A.append(list(input()))
B = []
for i in range(M):
    B.append(list(input()))
match = 0
for h in range(N-M+1):
    for w in range(N-M+1):
        if A[h][w]==B[0][0]:
            count = 0
            for bh in range(M):
                for bw in range(M):
                    if B[bh][bw]==A[h+bh][w+bw]:
                        count+=1
                    else:
                        count=-1
                        break
                if count==-1:
                    break
            if count==M*M:
                match=1
    if match==1:
        break

if match==0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          ll i,j;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  ll N,Y;
	      	  cin >> N >> Y;


	      	  for(i=0;i<=N;i++){
	      		  for(j=0;j<=N;j++){
	      			  ll x=Y-(10000*i+5000*j);
	      			  if(i+j>N) continue;
	      			  if(x<0) continue;
	      			  if(x%1000!=0) continue;
	      			  ll k=x/1000;
	      			  if(i+j+k==N && 10000*i+5000*j+1000*k==Y){
	      				  cout << i << ' ' << j << ' ' << k;
	      				  return 0;
	      			  }

	      		  }
	      	  }

	      	  cout << "-1 -1 -1" << endl;

	          return 0;
}


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

int main()
{
	long n=0, a=0, b=0;
	cin >> n >> a >> b;

	long answer = (n / (a + b)) * a;
	long mod = n % (a + b);
	if (mod > a) {
		answer += a;
	}
	else {
		answer += mod;
	}

	cout << answer;

	return 0;
}


Measured memory_bytes: 256
package main

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

func solve() {
	s := getRunes()
	k := getInt()

	ans := s[0]
	for i, r := range s {
		ans = r

		if r > '1' {
			break
		}
		if i == k-1 {
			break
		}
	}

	fmt.Fprintln(wr, string(ans))
}

// -----------------------------------------

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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

func getRunes() []rune {
	return []rune(getString())
}


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

int main()
{
  long n;
  cin >> n;
  long k = 1;
  
  for(int i = 1; i <= n; i++) {
    k *= i;
    k%= (long) 1E9+7;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
import itertools,math
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]


x = [i for i in range(n)]
candi = itertools.permutations(x)

dist = 0
count = 0
for i in candi: #経路の候補を作成
  for j in range(0,n-1):
    now = a[i[j]] # いまのx座標now[0],y座標[1]
    next = a[i[j+1]] # 次の座標
    dist += math.sqrt((next[0] - now[0])**2 + (next[1] - now[1])**2)
  count += 1

print(dist/count)

Measured memory_bytes: 3064
#!/usr/bin/python3

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


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

def main():
    N = int(input())
    S = input()
    cs = [0] * (N + 1)
    for i in range(N):
        cs[i + 1] = cs[i] + (S[i] == "W")

    ans = INF
    for i in range(N):
        l_w = cs[i]
        l_e = i - l_w
        r_w = cs[N] - cs[i + 1]
        r_e = (N - i - 1) - r_w

        ans = min(ans, l_w + r_e)

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16016
using System;
using System.Linq;

namespace ABC148
{
    class A
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());

            if (A + B == 3) Console.WriteLine(3);
            if (A + B == 4) Console.WriteLine(2);
            if (A + B == 5) Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <math.h>

int main(int argc,char* argv[]){
  
  for(;;){
    int q;
    double x;

    scanf("%d",&q);
    if(q == -1){break;}
    
    x = q/2;
    while(!(fabs(x*x*x - q) < 0.00001*q)){
      x = x - (x*x*x-q)/(3*x*x);
    }

    printf("%lf\n",x);
  }

  return 0;
  
}

Measured memory_bytes: 0
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


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

   
    int a[n],b[n],c[n];
    inrep(n,a);
    inrep(n,b);
    inrep(n-1,c);

    ll ans = 0;
    rep(i,0,n){
	ans += b[i];
    }
    rep(i,0,n-1){
	if(a[i] == a[i+1] - 1){
	    ans += c[a[i] - 1];
	}
    }

    P(ans);
    return  0;
}


Measured memory_bytes: 256
N,M,X,Y = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(j) for j in input().split()]
a = list(range(X+1,Y+1))
b = list(range(max(x)+1,min(y)+1))
if list (set(a)&set(b))!=[]:
    print('No War')
else :
    print('War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1; i<sqrt(n); i++){
        ll tmp=(n-i)/i;
        if(n/tmp==n%tmp){
            ans+=tmp;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int LOGN = 20;
const int MAXN = 100010;

ll dis[MAXN];
int parent[MAXN][LOGN];
vector<pii> edges[MAXN];

void dfs(int node)
{
    rep(i, 0, MAXN) dis[i] = -1;

    queue<int> que;
    que.push(node);
    dis[node] = 0;

    while (que.size() > 0)
    {
        int node = que.front();
        ll d = dis[node];
        que.pop();

        for (auto next_c : edges[node])
        {
            int next = next_c.first;
            ll c = next_c.second;

            if (dis[next] != -1) continue;

            que.push(next);
            dis[next] = d + c;
        }
    }
};


int main()
{
    int n;
    cin >> n;
    rep(i, 0, n - 1)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }


    int q, k;
    cin >> q >> k;
    k--;

    dfs(k);

    rep(i, 0, q)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;

        cout << dis[x] + dis[y] << endl;
    }
    return 0;
}

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

int main()
{
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c = c - b;
		if(c <= 0)
		{
			cout<<"Yes"<<endl;
			break;
		}
		a = a - d;
		if(a <= 0)
		{
			cout<<"No"<<endl;
			break;
		}
	}
	return 0;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int a = 0, b = 0, c, sum = A*X + B*Y;
    for(int i = 0; i <= max(X, Y) * 2; i++){
        a = 0;
        b = 0;
        if(i % 2 != 0) continue;
        c = C * i;
        if(i/2 < X) a = (X - i / 2) * A;
        if(i/2 < Y) b = (Y - i / 2) * B;
        sum = min(sum, a + b + c);
    }
    cout << sum << endl;
}

Measured memory_bytes: 3532
#include <assert.h>
#include <stdio.h>

int cnt[2010][2010][2];
int acnt[2010][2010];

int main() {
  int N, K;
  scanf("%d%d", &N, &K);

  for (int i = 0; i < N; i++) {
    int x, y;
    char c;
    scanf("%d%d %c", &x, &y, &c);
    cnt[y % (2*K)][x % (2*K)][c == 'B']++;
  }

  for (int y = 0; y < 2*K; y++) {
    int c = 0;
    for (int x = 0; x < 2*K; x++) {
      int wb = x >= K;
      c += cnt[y][x][wb];
    }

    int fc = c;
    for (int x = 0; x < 2*K; x++) {
      //printf("y=%d x=%d %d %d\n", y, x, yc[0], yc[1]);
      acnt[y][x] = c;

      c -= cnt[y][x][0];
      c += cnt[y][(x+K)%(2*K)][0];
      c -= cnt[y][(x+K)%(2*K)][1];
      c += cnt[y][x][1];
    }
    assert(fc == c);
  }

  int best_cnt = 0;
  for (int x = 0; x < 2*K; x++) {
    int c = 0;
    for (int y = 0; y < 2*K; y++) {
      int wb = y >= K;
      c += acnt[y][(x+wb*K)%(2*K)];
    }

    int fc = c;
    for (int y = 0; y < 2*K; y++) {
      //printf("%d %d %d\n", x, y, c);
      if (best_cnt < c) {
        best_cnt = c;
      }

      c -= acnt[y][x];
      c += acnt[y][(x+K)%(2*K)];
      c -= acnt[(y+K)%(2*K)][(x+K)%(2*K)];
      c += acnt[(y+K)%(2*K)][x];
    }
    assert(fc == c);
  }
  printf("%d\n", best_cnt);
}


Measured memory_bytes: 47360
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int c=a+b;
	int d=a-b;
	int e=a*b;
	if(c<d)
	swap(c,d);
	if(c<e)
	swap(c,e);
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
int32_t main() {
	IAMSPEED
	ll n,r; cin>>n>>r;
	if(n<10){
		cout<<100*(10-n) + r;
	} else {
		cout<<r;
	}
	
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 0
flag = 0
if a + b < 2*c:
    ans = a*x + b*y
elif a + b >= 2*c:
    if x > y:
        if a > 2*c:
            ans = 2*c*x
            flag = 1
        elif a <= 2*c:
            ans = 2*c*y + a*(x-y)
            flag = 2
    elif x < y:
        if b > 2*c:
            ans = 2*c*y
            flag  = 3
        elif b <= 2*c:
            ans = 2*c*x + b*(y-x)
            flag = 4
    elif x == y :
        ans = 2*c*x
        flag = 5

# print(flag)
print(ans)

Measured memory_bytes: 9224
# N = 3
# ARR = [
#     [10, 40, 70],
#     [20, 50, 80],
#     [30, 60, 90]
# ]


# N = 7
# ARR = [
#     [6, 7, 8],
#     [8, 8, 3],
#     [2, 5, 2],
#     [7, 8, 6],
#     [4, 6, 8],
#     [2, 3, 4],
#     [7, 5, 1]
# ]
#

N = int(input())
ARR = []

for i in range(N):
    ARR.append(list(map(int,input().split())))



def calculate(n, arr):
    result = []
    for index, ar in enumerate(arr):
        if index == 0:
            result.append(ar)
        else:
            s1 = max(result[-1][1] + ar[0], result[-1][2] + ar[0])
            s2 = max(result[-1][0] + ar[1], result[-1][2] + ar[1])
            s3 = max(result[-1][0] + ar[2], result[-1][1] + ar[2])
            result.append([s1, s2, s3])

    print(max(result[-1]))


calculate(N, ARR)


Measured memory_bytes: 47360
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,m;cin>>n>>m;
  ll A[300][300];
  rep(i,n){
    rep(j,m){
      cin>>A[i][j]; A[i][j]--;
    }
  }
  ll ok = 300, ng = -1;
  while(ok - ng >= 2){
    bool over = false;
    ll idx[300] = {};
    bool outs[300] = {};
    ll mid = (ng + ok) / 2;
    while(true){
      ll count[300] = {};
      rep(i,n){
        count [ A[i][idx[i]] ] ++;
      }
      bool update = false;
      rep(i,m){
        if(count[i] > mid){
          outs[i] = true;
          update = true;
        }
      }
      if(!update){
        break;
      }
      rep(i,n){
        while(outs[A[i][idx[i]]]){
          idx[i]++;
          if(idx[i] == m){
            over = true;
            break;
          }
        }
      }
      if(over) break;

    }
    if(over){
      ng = mid;
    }else{
      ok = mid;
    }
  }
  cout<<ok<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int lb(int l,int r,int n,int *d){
  int m=(l+r)/2;
  if(l==r)return m;
  return n<=d[m]?lb(l,m,n,d):lb(m+1,r,n,d);
}
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,i,j,a,d[100010];
  long long s=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&j);
    hin(j);
  }
  for(i=0;i<n;i++)d[i]=N[hout()];
  // for(i=0;i<n;i++)printf("%d\n",d[i]);
  for(i=0;i<n;i++){
    for(j=0;j<i;j++){
      a=lb(0,n,d[i]+d[j],d)-1;//printf("%d %d %d\n",i,j,a);
      if(a<=i||a==n)continue;
      s+=a-i;
    }
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
 
int int_cmp(const int *a, const int *b)
{
  if (*a < *b)
    return (-1);
  else if (*a > *b)
    return (1);
  return (0);
}
 
 
int main()
{
  int n,q,i,x,j;
  int array_n[100000];
  int array_q[50000];
  int count=0;
 
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&array_n[i]);
  }
  qsort(array_n,n,sizeof(array_n[0]),(int(*)(const void*, const void*))int_cmp);
 
  scanf("%d",&q);
  for (i=0;i<q;i++){
    scanf("%d",&x);
    int l=0;
    int r=n-1;
    int m;
    while (l<=r){
      m=(l+r)/2;
      if (array_n[m]==x){
        count++;
        break;
      }else if(array_n[m]<x){
        l=m+1;
      }else if(array_n[m]>x){
        r=m-1;
      }
    }
  }
 
  printf("%d\n",count);
 
  return 0;
}


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

using namespace std;
typedef         long long int   ll;
#define         MAX         200010
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output1.txt","w",stdout)
#define         inf         1000000050

int main(){

    //freopen("input.txt","w",stdout);
    ll n,d,x,y,cnt=0;
    cin>>n>>d;
    ll val;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        val = ceil(sqrt((x*x)+(y*y)));
        if(val<=d) cnt++;
        //cout<<val<<endl;
    }

    cout<<cnt<<endl;

    return 0;
}

/**

*/


Measured memory_bytes: 3692
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }

int main() {

	long res = 0;
	long sres = 0;
	long N; cin >> N;
	vector<long> H(N);
	for (int i = 0; i < N; i++) cin >> H[i];

	for (int i = 1; i < N; i++) if (H[i - 1] >= H[i]) { sres++; res = max(res, sres); }
	else sres = 0;

	cout << res << endl;

}

Measured memory_bytes: 1024