akhauriyash/Code-Regression huggingface dataset:
//ABC085B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

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

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

int main(){
  int K, N; cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  int south;
  south = A.at(N-1) - A.at(0);
  
  int north = 0;
  vector<int> B(N-1);
  for (int i = 0; i < N-1; i++) {
    B.at(i) = A.at(i+1) - A.at(i);
    if (north < B.at(i)) north = B.at(i);
  }
  north = K - north;
  
  int ans = min(south, north);
  cout << ans << endl;   
}

Measured memory_bytes: 1792
n = gets.to_i
ar = gets.split.map(&:to_i)
ar2 = []

(0..n-2).each do |i1|
  (1..ar[i1..-1].count-1).each do |i2|
    ar2 << (ar[i1] - ar[i1..-1][i2]).abs
  end
end

p ar2.max


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

int n;
string str;

bool parser(int ch)
{
	bool a, b;
	switch (str[n]) {
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
		return (ch >> (str[n++] - 'a')) & 1;
	case '(':
		n++;
		a = parser(ch);
		if (str[n] == '+') {
			n++;
			b = parser(ch);
			n++;
			return a || b;
		}
		else if (str[n] == '*') {
			n++;
			b = parser(ch);
			n++;
			return a&&b;
		}
		else {
			n++;
			n++;
			b = parser(ch);
			n++;
			if (a == true) {
				if (b == true)
					return true;
				else
					return false;
			}
			else
				return true;
		}
		break;
	case '-':
		n++;
		return !parser(ch);
		break;
	case 'T':
		n++;
		return true;
	case 'F':
		n++;
		return false;
	default:
		exit(EXIT_FAILURE);
	}
}

int main()
{
	while (cin >> str, str != "#") {
		bool res = true;
		for (int i = 0; i < 0x800; i++) {
			n = 0;
			bool p1 = parser(i);
			n++;
			if (p1 != parser(i)) {
				res = false;
				break;
			}
		}
		cout << (res ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <sstream>
#include <iterator>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <cmath>

#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")

using namespace std;

int factorical(int x) {
	return x ? x * factorical(x - 1) : 1;
}

//ABC060B - Choose Integers
int Main() {
	long long a, b, c;
	bool ans = 0;

	cin >> a >> b >> c;

	int x = 0;
	int loopNum = b / 2 + 1;

	if (a == 1) {
		if (c < b) ans = true;
	}
	else
		for (int i = 0; i < b; i++) {
			x = i * a;
			if (x % b == c) ans = true;
		}


	YESNO(ans);

	return 0;
}


int main()
{
	Main();
	return 0;
}

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

const long long mod=1e9+7;
long long n, dp[200003], ans[200003], facto[200003], size[200003];
vector<long long>adjl[200003];

long long modpow(long long x, long long y){
	long long ret=1;
	while (y>0){
		if (y&1){
			ret*=x;
			ret%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return ret;
}

long long modinv(long long x){
	return modpow(x,mod-2);
}

long long dfs1(long long now, long long bef){ //dp, size
	long long ret=1;
	size[now]=1;
	for (long long next : adjl[now]){
		if (next==bef) continue;
		long long tmp=dfs1(next,now);
		ret*=(tmp*modinv(facto[size[next]]))%mod;
		ret%=mod;
		size[now]+=size[next];
	}
	ret*=facto[size[now]-1];
	ret%=mod;
	return dp[now]=ret;
}

void dfs2(long long now, long long bef){
	for (long long next : adjl[now]){
		if (next==bef) continue;
		dp[now]*=modinv(dp[next]);
		dp[now]%=mod;
		dp[now]*=facto[size[next]];
		dp[now]%=mod;
		dp[now]*=modinv(facto[size[now]-1]);
		dp[now]%=mod;
		size[now]-=size[next];
		dp[now]*=facto[size[now]-1];
		dp[now]%=mod;
		dp[next]*=modinv(facto[size[next]-1]);
		dp[next]%=mod;
		size[next]+=size[now];
		dp[next]*=facto[size[next]-1];
		dp[next]%=mod;
		dp[next]*=dp[now];
		dp[next]%=mod;
		dp[next]*=modinv(facto[size[now]]);
		dp[next]%=mod;
		ans[next]=dp[next];
		dfs2(next,now);
		dp[next]*=facto[size[now]];
		dp[next]%=mod;
		dp[next]*=modinv(dp[now]);
		dp[next]%=mod;
		dp[next]*=modinv(facto[size[next]-1]);
		dp[next]%=mod;
		size[next]-=size[now];
		dp[next]*=facto[size[next]-1];
		dp[next]%=mod;
		dp[now]*=modinv(facto[size[now]-1]);
		dp[now]%=mod;
		size[now]+=size[next];
		dp[now]*=facto[size[now]-1];
		dp[now]%=mod;
		dp[now]*=modinv(facto[size[next]]);
		dp[now]%=mod;
		dp[now]*=dp[next];
		dp[now]%=mod;
	}
}

void init(){
	facto[0]=1;
	for (int i=1;i<200003;i++){
		facto[i]=i*facto[i-1];
		facto[i]%=mod;
	}
}


int main(){
	init();
	cin >> n;
	for (int i=0;i<n-1;i++){
		long long u, v;
		cin >> u >> v;
		adjl[u].push_back(v);
		adjl[v].push_back(u);
	}
	dfs1(1,0);
	ans[1]=dp[1];
//	for (int i=1;i<=n;i++) cout << dp[i] << " ";
//	cout << "\n";
	dfs2(1,0);
	for (int i=1;i<=n;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 20976
#import <stdio.h>
#import <string.h>
typedef long long INT;
int main(){
    INT n;
    scanf("%lld",&n);
    int v=0;
    for(INT p=1LL;p*p<=n;p++) {
        if (n%p==0) {
            char s[20];
            sprintf(s, "%lld", n/p);
            v=strlen(s);
        }
    }
    printf("%d", v);
    return 0;
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

vector<int>primes;
vector<int>res;
const int MA=10000000;
bool t[MA];

void init(){
  for(int i=2;i*i<MA;i++){
    if(t[i]==0){
      primes.pb(i);
      for(int j=i*2;j*j<MA;j+=i){
        t[j]=1;
      }
    }
  }
}

void calc_soinsu(ll n){

  for(int i=0;i<primes.size();i++){
    while((n%primes[i])==0){
      res.pb(primes[i]);
      n/=primes[i];
    }
  }
  if(n!=1)res.pb(n);
}

int main(){
  ll n;
  cin>>n;
  init();
  //rep(i,primes.size())cout<<primes[i]<<"_";
  calc_soinsu(n);
  cout<<n<<":";
  rep(i,res.size()){
    cout<<" "<<res[i];
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3168
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    N = LS()

    if '7' in N:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w, n, posx, posy;
    string s, t;
    cin >> h >> w >> n >> posx >> posy >> s >> t;

    int up = 0, down = h + 1, lef = 0, rig = w + 1;
    for (int i = n - 1; i >= 0; i--)
    {
        if (t[i] == 'U' && down != h + 1) down++;
        if (t[i] == 'D' && up != 0) up--;
        if (s[i] == 'U') up++;
        if (s[i] == 'D') down--;

        if (t[i] == 'L' && rig != w + 1) rig++;
        if (t[i] == 'R' && lef != 0) lef--;
        if (s[i] == 'L') lef++;
        if (s[i] == 'R') rig--;
        if (up >= down - 1 || lef >= rig - 1) cout << "NO\n", exit(0);
    }
    if (posx <= up || posx >= down || posy <= lef || posy >= rig) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}



Measured memory_bytes: 920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int>pli;
typedef pair<ll,pair<int,int>>plii;
const pli M(1ll<<60,0);
const int N=2e5+5;
struct node{
	int lb,rb,md;
	pli m[4];plii al;
}t[N<<2];
int n,D,a[N],i;ll ans;
bool b[N];
inline void set1(int i,int l){
	t[i].m[0]=pli(a[l]-1ll*l*D,l);
	t[i].m[1]=pli(a[l]+1ll*l*D,l);
	t[i].m[2]=t[i].m[3]=M;t[i].al=make_pair(1ll<<60,make_pair(0,0));
}
inline void set2(int i,int l){
	t[i].m[2]=pli(a[l]-1ll*l*D,l);
	t[i].m[3]=pli(a[l]+1ll*l*D,l);
	t[i].m[0]=t[i].m[1]=M;t[i].al=make_pair(1ll<<60,make_pair(0,0));
}
inline plii F(pli a,pli b){return make_pair(a.first+b.first,make_pair(a.second,b.second));}
inline void maintain(int i){
	for(int j=0;j<4;++j)t[i].m[j]=min(t[i<<1].m[j],t[i<<1|1].m[j]);
	t[i].al=min(min(t[i<<1].al,t[i<<1|1].al),min(F(t[i<<1].m[0],t[i<<1|1].m[3]),
		F(t[i<<1].m[2],t[i<<1|1].m[1])));
}
void build(int i,int l,int r){
	t[i].lb=l;t[i].rb=r;t[i].md=l+r>>1;
	if(l==r)return l==1?set1(i,l):set2(i,l);
	build(i<<1,l,t[i].md);build(i<<1|1,t[i].md+1,r);
	maintain(i);
}
void mdy(int i,int l){
	if(t[i].lb==t[i].rb)return set1(i,l);
	mdy(i<<1|(t[i].md<l),l);maintain(i);
}
int main(){
	scanf("%d%d",&n,&D);for(i=1;i<=n;++i)scanf("%d",a+i);build(1,1,n);
	b[1]=1;
	for(i=1;i<n;++i){
		int x=t[1].al.second.first,y=t[1].al.second.second;
		ans+=t[1].al.first;if(b[x])b[y]=1,mdy(1,y);else b[x]=1,mdy(1,x);
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define N 18
typedef long long ll;
typedef pair <int, int> pii;
int n, a[N];
const ll inf = 1e18;

map <pii, ll> mp[N][N];

ll solve(int l, int r, int x, int y) {
    map <pii, ll> :: iterator it = mp[l][r].find(pii(x, y));
    if (it != mp[l][r].end()) return it -> second;
    if (l == r - 1) return mp[l][r][pii(x,y)] = 0;
    ll t = inf;
    for (int m = l + 1; m < r; m ++) t = min(t, solve(l, m, x, x + y) + solve(m, r, x + y, y) + 1ll * a[m] * (x + y));
    return mp[l][r][pii(x,y)] = t;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
    printf("%lld\n", solve(0, n - 1, 1, 1) + a[0] + a[n-1]);

    return 0;
}


Measured memory_bytes: 32896
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b && b!=c) || (a==c&& c!=b )|| (b==c && a!=b))
    cout<<"Yes";
  else cout<<"No";
  return 0;
}


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

using namespace std;

int main() {
    int a, b; cin >> a >> b;

    bool flag = false;

    for (int i = 0; i < 10101; i++) {
        int ca =  i * 0.08;
        int cb =  i * 0.1;
        if ((ca == a) && (cb == b)) {
            cout << i << endl;
            flag = true;
            break;
        }
    }

    if (!flag) cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))

a = [0]*n
b = [0]*m
c = [0]*n

for i in range(n):
    a[i] = list(map(int, input().split()))
    #print(a[i][0])

for i in range(m):
    b[i] = int(input())

for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print(c[i])

Measured memory_bytes: 8104
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


bool pairCompare(const Pi& firstElof, const Pi& secondElof)
{
	return firstElof.second > secondElof.second;
}

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

	int n;
	cin >> n;
	int ans = 0;
	vi v(n);
	vi c(n);
	rep(i, n)cin >> v[i];
	rep(i, n)cin >> c[i];
	rep(i, n) {
		if (v[i] - c[i] > 0) {
			ans += v[i] - c[i];
		}
	}

	cout << ans << endl;

	return 0;
}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
 // freopen("data.in", "r", stdin);
  int n;
  cin >> n;
  vector<int> f (n);
  vector<int> g (n);
  for (int i = 0; i < n; i++) cin >> f[i];
  for (int i = 0; i < n; i++) cin >> g[i];
  vector<int> perm  = f;

  sort(perm.begin(), perm.end());
  int a = 0, b = 0, c = 1;
  do {
    if (equal(perm.begin(), perm.end(), f.begin())) a = c;
    if (equal(perm.begin(), perm.end(), g.begin())) b = c;
    if (a && b) break;
    c++;
  }while (next_permutation(perm.begin(), perm.end()));
  cout << abs(a-b) << endl;

  return 0;
}





















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

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

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}

signed main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 0 || b % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#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;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

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

    int n; cin>>n;
    vector<int> c(n);
    for(int i=0; i<n; i++) cin>>c[i];
    
    sort(c.begin(), c.end());

    ll ans = 0;
    for(int i=0; i<n; i++){
        int l = i, r = n - i - 1;
        ans += (((modpow(2, r) + modpow(2, max(0, r - 1)) * r % MOD) % MOD) * modpow(2, l) % MOD) * c[i] % MOD;
        ans %= MOD;
    }

    ans *= modpow(2, n);
    ans %= MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	static class FastReader{
		BufferedReader br;
		StringTokenizer tok;
		
		FastReader(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		
		String next() {
			if(tok==null || (!tok.hasMoreTokens())) {
				try {
					tok = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return tok.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(this.next());
		}
		String nextLine() {
			String s="";
			try {
				s = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return s;
		}
	}
	
	static int argmax(int[] arr) {
		if(arr[0]>=arr[1] && arr[0]>=arr[2])
			return 0;
		else if(arr[1]>=arr[0] && arr[1]>=arr[2])
			return 1;
		else 
			return 2;
	}
	
	public static void main(String[] args) {
		FastReader fr=new FastReader();
		int n=fr.nextInt();
		int[][] arr=new int[n][3];
		for(int i=0; i<n; i++) {
			arr[i][0]=fr.nextInt();
			arr[i][1]=fr.nextInt();
			arr[i][2]=fr.nextInt();
		}
		
		int[][] dp=new int[n][3];
		dp[0]=arr[0];
		for(int i=1; i<n; i++) {
			dp[i][0]=Math.max(dp[i-1][1], dp[i-1][2])+arr[i][0];
			dp[i][1]=Math.max(dp[i-1][0], dp[i-1][2])+arr[i][1];
			dp[i][2]=Math.max(dp[i-1][0], dp[i-1][1])+arr[i][2];
		}
		System.out.println(Math.max(Math.max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]));	
	}
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int v[125252];

int cnt[2][125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",v+i),v[i]--;
  REP(i,n)cnt[i%2][v[i]]++;
  int ans = n;
  int top1val = 100025, top2val = 100025;
  REP(i,100000)if(cnt[0][i]>0){
    if(cnt[0][i] > cnt[0][top2val]){
      top2val = i;
    }
    if(cnt[0][top2val] > cnt[0][top1val]){
      swap(top1val, top2val);
    }
  }
  REP(i,100000)if(cnt[1][i]>0){
    if(i!=top1val){
      CHMIN(ans, n-cnt[1][i]-cnt[0][top1val]);
    }else{
      CHMIN(ans, n-cnt[1][i]-cnt[0][top2val]);
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

#define mod 1000000009
#define INF 1000000000
#define ll long long
#define dbl double
#define ull unsigned ll
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvvll vector<vector<vector<ll>>>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define all(x) begin(x), end(x)
#define contains(a, x) (a.find(x) != end(a))
#define F(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)
#define RF(i,a,b)for(int i = (int)(a); i >= (int)(b); --i)
#define fast() {ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define log(x) cout << (x) << endl;

int count(int a, int b, int c) {
	int t=0, u=0;
	t=min(b,c); c-=t, b-=t; t*=2;
	if (c) u = min(a, c), c -= u;
	return t+b+u+min(c,1);
}


int main() {
	fast();
  	int a,b,c;
  	cin>>a>>b>>c;
	log(count(a,b,c))
	return 0;
}






Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = B[A[0]-1]
for i in range(1, n):
    if A[i] - A[i-1] == 1:
        ans += B[A[i]-1] + C[A[i]-2]
    else:
        ans += B[A[i]-1]

print(ans)


Measured memory_bytes: 3064
import sys

n,m = map(int,input().split())
t = [0] * 2
t[0] = 1
t[1] = 2
a = []
for _ in range(m):
	a.append(int(input()))
mod = 10**9 + 7

for i in range(1,m):
	if a[i] - a[i-1] == 1:
		print(0)
		sys.exit()
a.append(n+1)

l = []
dan = 0
for i in range(m+1):
	l.append(a[i]-1-dan)
	dan = a[i] + 1
	if dan == n+2:
		break

if max(l) > 2:
	for i in range(2,max(l)):
		t.append(t[i-1] + t[i-2])

ans = 1
for i in l:
	if i != 0 and t[i-1] != 0:
		ans *= t[i-1]
		ans %= mod

print(ans)


Measured memory_bytes: 471560
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}

debug dbg;

class BPolygon {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    vector<int> l(n);
	    int sum = 0;
	    for(int i=0; i<n; i++){
	        in >> l[i];
	        sum += l[i];
	    }

	    bool flg = true;
	    for(int i=0; i<n; i++){
	        if(sum-l[i] <= l[i]) flg = false;
	    }

	    ans(flg, out);
	}
};


int main() {
	BPolygon solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#include<strstream>
#include<sstream>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<set>
long long mod = 10e18;
long long is(int n)
{
	if (n == 0)
		return 2;
	if (n == 1)
		return 1;
	return (is(n - 1) + is(n - 2));
}
int main()
{
	int n; cin >> n;
	cout << 24 + (24 - n);
	
}

Measured memory_bytes: 3168
N = int(input())
num = [1]*(N+1)
num[0] = 0
for a in range(3,len(num),3):
    num[a] = 0
for b in range(5,len(num),5):
    num[b] = 0
t = 0
for a in range(len(num)):
    if num[a] == 1:
        t += a
print(t)

Measured memory_bytes: 16656
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
 
 
using namespace std;
int main() {
    string S; cin >> S;
    int wb_ans = 0;
    int bw_ans = 0;
    for(int i = 0; i < S.length(); i++) {
        if(i%2 == 0) {
            if(S[i] == '0')      wb_ans++;
            else if(S[i] == '1') bw_ans++;
        } else {
            if(S[i] == '0')      bw_ans++;
            else if(S[i] == '1') wb_ans++;
        }
    }
    cout << min(wb_ans, bw_ans) << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	int n;
	cin >> n;
	vector<ll> x[n],y[n];
	rep(i, n) {
		x[i] = vector<ll>(0);
		y[i] = vector<ll>(0);
	}
	rep(i, n) {
		ll a;
		cin >> a;
		if (i - a >= 0) {
			x[i - a].push_back(i);
		}
		if (i + a < n) {
			y[i + a].push_back(i);
		}
	}
	ll ans = 0;
	ll p, q, r, s;
	rep(i, n) {
		ans += x[i].size() * y[i].size();
	}
	cout << ans << endl;
}


Measured memory_bytes: 20968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int X , Y ;
  cin >> X  >> Y ;
  rep(i,X+1){
    rep(j,X+1){
      if( (Y-i*1000-j*5000)%10000 == 0 && i + j + (Y-i*1000-j*5000)/10000 == X && (Y-i*1000-j*5000)/10000 >= 0  ){
		cout << (Y-i*1000-j*5000)/10000 << ' ' << j << ' ' << i << endl;
        return 0 ;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' '<< -1  << endl;
}

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

int n, a[10];

int main() {
    cin >> n;
    int MAX = pow(3, n), cnt = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i] % 2 == 0) cnt++;
    }
    cout << MAX - pow(2, cnt) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int i,n,ilm[100000],d[100000]={0},v=0,a=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&ilm[i]);
if(i==0)
d[0]++;
else if(ilm[i-1]!=ilm[i]&&i>0)
d[v]++;
else{
v++;
d[v]++;
}
}
if(v<3){
for(i=0;i<=v;i++){
a+=d[i];
}
}
else{
for(i=0;i<=v-2;i++){
a=max(a,d[i]+d[i+1]+d[i+2]);
}
}
printf("%d\n",a);
return 0;
}



Measured memory_bytes: 3980
s = int(input())
lines = [s]
for line in lines:
  if(line%2 == 0):
    even = int(line / 2)
    if(even not in lines):
      lines.append(even)
    else:
      break
  else:
    odd = 3*line + 1
    if(odd not in lines):
      lines.append(odd)
    else:
      break
print(lines.index(lines[-1])+2)

Measured memory_bytes: 3060
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	int n;
	cin >> n;
	int sum = 0 , a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int m;
	cin >> m;
	while(m--)
	{
		int x,y;
		cin >> x >> y;
		--x;
		int d = sum - a[x];
		cout << d +y << nl;
	}
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a[4], b[4];
  while (cin >> a[0]) {
    for (int i = 1; i < 4; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < 4; i++) {
      cin >> b[i];
    }
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (b[i] == a[j]) {
          hit += i == j;
          blow += i != j;
        }
      }
    }
    cout << hit << " " << blow << endl;
  }

  return 0;
}


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

typedef long long ll;

using namespace std;


const ll N=100001;

bool prime[N];

ll ruipri[N];

void eratosthenes(bool prime[N]){
    for(ll i=0;i<N;i++) prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(ll i=0;i<N;i++){
        if(prime[i]){
            for(int j = i + i; j < N; j+=i){
                prime[j] = 0;
            }
        }
    }
}

int main(){

    eratosthenes(prime);

     ll count=0;
   

    for(ll i=1;i<N;i++){
    
        
       
        if(i%2==1){
            ll k=(i+1)/2;
        if(prime[i]==1&&prime[k]==1){
            ++count;
        }
        }
        ruipri[i]=count;
        
    }
/*
    for(int i=0;i<60;i++){
        cout<<ruipri[i]<<" ";
    }
    cout<<endl;
  */  

    ll Q;
    cin>>Q;

    ll ans[Q];


    for(ll i=0;i<Q;i++){
        ll l,r;
        cin>>l>>r;

        ans[i]=ruipri[r]-ruipri[l-1];


    
    }

    for(ll i=0;i<Q;i++){
        cout<<ans[i]<<endl;
    }




}




Measured memory_bytes: 5240
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

namespace ConsoleAppAtCoderABC169
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(ReadLine());

            // 素因数分解
            var primeFactor = new List<(long, int)>();
            var rootN = (long)Math.Sqrt(N);
            var n = N;

            for (long i = 2; i <= rootN; i++)
            {
                if(n % i == 0)
                {
                    var x = 0;
                    do
                    {
                        x++;
                        n /= i;
                    } while (n % i == 0);

                    primeFactor.Add((i, x));
                }
            }

            if(rootN < n)
            {
                primeFactor.Add((n, 1));
            }

            // 集計
            var ans = 0;

            foreach (var pf in primeFactor)
            {
                var x = pf.Item2;
                var count = 1;

                while(true)
                {
                    if(0 <= x - count)
                    {
                        x -= count;
                        ans++;
                        count++;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 27784
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll f(ll n)
{
        if (even(n)) return n/2;
        else return 3*n+1;
}

int main()
{
        ll s;
        cin >> s;
        ll ne = s;
        map<ll, ll> mp;
        mp[s]++;
        ll ans = -inf;
        rep(i, 2, 10000000) {
                ne = f(ne);
                mp[ne]++;
                if (mp[ne] == 2) {
                        ans = i;
                        break;
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 3596
//#define		FILE_INPUT_DEFINE
#ifdef		FILE_INPUT_DEFINE
#include	<fstream>
#endif		// FILE_INPUT_DEFINE

#include	<iostream>
#include	<deque>
#include	<string>
#include	<algorithm>
#include	<cstdio>
#include	<memory>

using namespace std;

enum class Walk
{
	ePreOrder = 0,
	eInOrder,
	ePostOrder
};


struct Node
{
	shared_ptr<Node>		parent;
	shared_ptr<Node>		left;
	shared_ptr<Node>		right;
	int						key;

	Node(int k)
	{
		key = k;
	}
};

shared_ptr<Node>			root;

void insert(int key)
{
	unique_ptr<Node>		z(new Node(key));
	weak_ptr<Node>			x = root;
	weak_ptr<Node>			y;

	while (x.use_count() != 0)
	{
		y = x;
		if (z->key < x.lock()->key)
		{
			x = x.lock()->left;
		}
		else
		{
			x = x.lock()->right;
		}
	}

	if (y.use_count() != 0)
	{
		z->parent = y.lock();
	}

	if (y.use_count() == 0)
	{
		root = move(z);
	}
	else
	{
		if (z->key < y.lock()->key)
		{
			y.lock()->left = move(z);
		}
		else
		{
			y.lock()->right = move(z);
		}
	}
}

void Order(weak_ptr<Node> nd, const Walk &wk)
{
	if (wk == Walk::ePreOrder)
		cout << " " << nd.lock()->key;
	if (nd.lock()->left.use_count() != 0)
		Order(nd.lock()->left, wk);
	if (wk == Walk::eInOrder)
		cout << " " << nd.lock()->key;
	if (nd.lock()->right.use_count() != 0)
		Order(nd.lock()->right, wk);
	if (wk == Walk::ePostOrder)
		cout << " " << nd.lock()->key;
}

bool	find(int key)
{
	weak_ptr<Node> nd = root;
	
	while (nd.use_count() != 0)
	{
		if (key == nd.lock()->key)
		{
			return true;
		}
		else if (key > nd.lock()->key)
		{
			nd = nd.lock()->right;
		}
		else
		{
			nd = nd.lock()->left;
		}
	}

	return false;
}

int main()
{
#ifdef		FILE_INPUT_DEFINE
	// input from txt
	std::ifstream in(R"(C:\Temp\input.txt)");
	std::cin.rdbuf(in.rdbuf());
#endif		// FILE_INPUT_DEFINE
	string		str;
	int			n, key;

	cin >> n;
	cin.clear();
	cin.ignore();

	for (int i = 0; i < n; ++i)
	{
		cin >> str;
		if (str == "insert")
		{
			cin >> key;
			insert(key);
		}
		else if (str == "print")
		{
			Order(root, Walk::eInOrder);
			cout << "\n";
			Order(root, Walk::ePreOrder);
			cout << "\n";
		}
		else if (str == "find")
		{
			cin >> key;
			if (find(key))
			{
				cout << "yes\n";
			}
			else
			{
				cout << "no\n";
			}
		}
		cin.clear();
		cin.ignore();
	}

	return 0;
}

Measured memory_bytes: 40548
#include <iostream>
using namespace std;
 
class Dice{
public:
    int n1,n2,n3,n4,n5,n6;
     
    void East(){
        int t = n1;
        n1 = n4;
        n4 = n6;
        n6 = n3;
        n3 = t;
    }
    void West(){
        int t = n1;
        n1 = n3;
        n3 = n6;
        n6 = n4;
        n4 = t;
    }
    void South(){
        int t=n1;
        n1 = n5;
        n5 = n6;
        n6 = n2;
        n2 = t;
    }
    void North(){
        int t=n1;
        n1 = n2;
        n2 = n6;
        n6 = n5;
        n5 = t;
    }
};
 
int main() {
    Dice dice;
    int n1, n2, n3, n4, n5, n6;
    int q;
    cin >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
    dice.n1 = n1;
    dice.n2 = n2;
    dice.n3 = n3;
    dice.n4 = n4;
    dice.n5 = n5;
    dice.n6 = n6;
     
    cin >> q;
    for(int i=0; i<q; i++){
        int a, b;
        cin >> a >> b;
        if(b == dice.n1){
            dice.South();
        }else if(b == dice.n3){
            dice.West();
            dice.South();
        }else if(b == dice.n4){
            dice.East();
            dice.South();
        }else if(b == dice.n5){
            dice.South();
            dice.South();
        }else if(b == dice.n6){
            dice.North();
        }
        if(a == dice.n3){
            dice.West();
        }else if(a == dice.n4){
            dice.East();
        }else if(a == dice.n6){
            dice.East();
            dice.East();
        }
        cout << dice.n3 << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <math.h>
using namespace std;
int N;
int M;
int L[100020];
int R[100020];
int lmax, rmin;
int ans;

int main(){
	cin >> N >> M;
	lmax = 0;
	rmin = N;
	for(int i=0; i<M; i++){
		cin >> L[i] >> R[i];
		if(lmax < L[i]) lmax = L[i];
		if(rmin > R[i]) rmin = R[i];
	}
	ans = rmin - lmax + 1;
	if(ans<0) ans = 0;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            //ここから
            int N = ReadLineToInt();
            string[] W = new string[N];

            bool flag = true;
            for(int i = 0; i < N; i++)
            {
                W[i] = ReadLineToString();
                if (i !=0 
                    && (W[i - 1].Substring(W[i - 1].Length-1, 1) != W[i].Substring(0, 1))
                    || W.Where(w=>w==W[i]).Count()>1)
                {
                    flag = false;
                }

            }
            string ans = flag ? "Yes" : "No";

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static public void Factoring(long num,ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for(long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }


        long mod = 1000000007;
        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n,int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }

        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
    
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector <string> a (H);
  
  for (int i=0; i<H; i++){
    cin >> a.at(i);
  }
  for (int i=0; i<(W+2); i++){
  cout << "#";
  }
  cout << endl;
  
  for (int i=0; i<H; i++){
    cout << "#" << a.at(i) << "#" << endl;
  }

   for (int i=0; i<(W+2); i++){
  cout << "#";
  }
  cout << endl;
 
  
}


Measured memory_bytes: 256
H,W = map(int,input().split())
para_val = [input() for i in range(H)]
for i in range(H+2):
    if i == 0 or i== H+1 :
        a = ["#"] * (W+2)
        ans = "".join(a)
        print(ans)
    else:
        b = ["#"]
        b.append(para_val[i-1])
        b.append("#")
        ans = "".join(b)
        print(ans)

Measured memory_bytes: 3060
use std::io::Read;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut a: BinaryHeap<isize> = BinaryHeap::new();
    for _ in 0..n {
        let ai: usize = iterator.next().unwrap().parse().unwrap();
        a.push(-(ai as isize));
    }

    let mut vec: Vec<(usize, usize)> = Vec::new();
    for _ in 0..m {
        let bi: usize = iterator.next().unwrap().parse().unwrap();
        let ci: usize = iterator.next().unwrap().parse().unwrap();
        vec.push((ci, bi));
    }

    vec.sort();

    while !vec.is_empty() {
        let mut v = vec.pop().unwrap();
        while v.1 > 0 {
            let ai = (-a.pop().unwrap()) as usize;
            if ai >= v.0 {
                a.push(-(ai as isize));
                break;
            }
            a.push(-(v.0 as isize));
            v.1 -= 1;
        }
    }

    let ans: usize = a.iter().map(|it| (-it) as usize).sum();
    return ans.to_string();
}


Measured memory_bytes: 12540
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func solve(n, m int) int {
	var ds []int
	for i := 1; i*i <= m; i++ {
		if m%i == 0 {
			ds = append(ds, i)
			ds = append(ds, m/i)
		}
	}
	result := 0
	for _, d := range ds {
		if m >= n*d {
			if d > result {
				result = d
			}
		}
	}
	return result
}

func main() {
	n := loadint()
	m := loadint()
	result := solve(n, m)
	fmt.Println(result)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <atcoder/dsu.hpp>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N, long long Q, std::vector<long long> t,
           std::vector<long long> u, std::vector<long long> v) {
             dsu d(N);
             rep(i, Q)
             if(t[i]) cout << d.same(u[i], v[i]) << endl;else d.merge(u[i], v[i]) ;
           }

signed main() {
  long long N;
  scanf("%lld", &N);
  long long Q;
  scanf("%lld", &Q);
  std::vector<long long> t(Q);
  std::vector<long long> u(Q);
  std::vector<long long> v(Q);
  for (int i = 0; i < Q; i++) {
    scanf("%lld", &t[i]);
    scanf("%lld", &u[i]);
    scanf("%lld", &v[i]);
  }
  solve(N, Q, std::move(t), std::move(u), std::move(v));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 8148
#include<cstdio>
#define LL long long 
using namespace std;
const int MAXN = 2e5 + 10;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int N, a[MAXN];
main() {
	N = read();
	for(int i = 1; i <= N; i++) a[i] = read();
	LL l = 1, sxor = 0, sum = 0, ans = 0;
	for(int i = 1; i <= N; i++) {
		sum += a[i]; sxor ^= a[i];
		while(sxor != sum && (l < i)) 
			sum -= a[l], sxor ^= a[l++];
		ans += i - l + 1;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 896
// ITP1_6_A:   Reversing Numbers
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
  int n,k,arr[101];
  scanf("%d",&n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d",&k);
    arr[i] = k;
  }
  for (int c = n-1; c >= 0; c--)
  {
    if(c > 0)printf("%d ",arr[c]);
    else
    {
      printf("%d",arr[c]);
    }
    
    
  }
  printf("\n");
	return 0;
}



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

int main() {
  string s;
  cin>>s;
  int n = s.length();
  string t = s;
  reverse(s.begin(),s.end());
  if (s != t) {
    cout<<"No"<<endl;
    return 0;
  }
  string u1 = s.substr(0, (n-1)/2);
  string u2 = u1;
  reverse(u2.begin(), u2.end());
  if (u1 != u2) {
    cout<<"No"<<endl;
    return 0;
  }
  string v1 = s.substr((n+3)/2-1, n-(n+3)/2+1);
  string v2 = v1;
  reverse(v2.begin(), v2.end());
  if (v1 != v2) {
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b=map(int,input().split())
    X=list(map(int,input().split()))
    ans=0
    for i in range(n-1):
        ans+=min(a*(X[i+1]-X[i]),b)
    print(ans)


if __name__=='__main__':
    main()

Measured memory_bytes: 62704