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

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/********************* MODULAR ARITHMETIC *******************************/

ll MOD = 1000000007;

void mod(ll &a){ if(a > MOD) a %= MOD; }
ll add(ll a, ll b) { a += b; mod(a); return a; }
ll mul(ll a, ll b) { mod(a); mod(b); a *= b; mod(a); return a; }
ll sub(ll a, ll b) { mod(a); mod(b); a -= b; a += MOD; mod(a); return a; }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

ll inv(ll a) { return powr(a, (MOD - 2)); }

/******************************** START *********************************/
const int N = 303;
int n;
ld dp[N][N][N];

ld func(int a, int b, int c)
{
  if(dp[a][b][c] > -1e16) {
    return dp[a][b][c];
  }

  if(a + b + c == 0) {
    return 0.0;
  } 
  ld res = 0;
  if(a > 0) {
    res += (a * 1.0 / (a + b + c) * 1.0) * func(a - 1, b, c);
  } 
  if(b > 0) {
    res += (b * 1.0 / (a + b + c) * 1.0) * func(a + 1, b - 1, c);
  }
  if(c > 0) {
    res += (c * 1.0 / (a + b + c) * 1.0) * func(a, b + 1, c - 1);
  }
  res += (n * 1.0) / (a + b + c) * 1.0;
  return dp[a][b][c] = res;
}

int main()
{
  ifalse;
  cin >> n;
  int a[4] = {0};
  for(int i = 0; i < n; i ++) {
    int x;
    cin >> x;
    a[x] ++;
  }

  for(int i = 0; i < N; i ++) {
    for(int j = 0; j < N; j ++) {
      for(int k = 0; k < N; k ++) {
        dp[i][j][k] = -1e18;
      }
    }
  }

  prec(16);
  cout << func(a[1], a[2], a[3]), nl;
  return 0;
}

Measured memory_bytes: 435072
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>


using std::cout;
using std::cin;
using namespace std;

void oneCase () {
   string l, r;
   cin >> r >> l;
   cout << l << r;


}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
num = 0
index = 0
a_lst = []
for _ in range(N):
  a_lst.append(int(input()))
past_index = [0] * N
while True:
  num += 1
  index = a_lst[index]-1
  if index == 1:
    break
  elif past_index[index] == 1:
    num = -1
    break
  else:
    past_index[index] = 1
print(num)

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b;cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0)out("Possible")
  else out("Impossible")

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define sd(x) scanf("%d",&(x))
#define pd(x) printf("%d",(x))
#define slld(x) scanf("%lld",&(x))
#define plld(x) printf("%lld",(x))
#define br printf("\n")
#define pi pair<int,int>
#define pii pair<long long int, long long int>
#define vi vector<int>
#define pb push_back
#define RESET(val) memset(val, 0, sizeof(val))
#define mp(a,b) make_pair(a, b)
#define fi first
#define se second
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define mod 1000000007
#define inf 1000000000
ll power(ll a,ll b,ll n){ll ans=1;while(b>0){if(b%2==1)ans=(ans*a)%n;a=(a*a)%n;b/=2;}return ans;}

int a[2][102];

signed main(){
 //   freopen("input.txt","r",stdin);
    int n;  cin>>n;
    for(int i = 0; i < 2; i++) 
        for(int j = 0; j < n; j++)  
            cin>>a[i][j];
    a[1][0] += a[0][0];
    for(int i = 0; i < 2; i++){
        for(int j = 1; j < n; j++){
            if(i == 0 && j == 0)    continue;
            if(i == 0)  a[i][j] += a[i][j-1];
            else    a[i][j] += max(a[i-1][j],a[i][j-1]);
        }
    }
    cout<<a[1][n-1];
    return 0;
} 

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
from bisect import bisect_left 
from collections import deque

def count_edge(a,b):
    global edge,AB
    if a>b:
        a,b=b,a
    AB[a*(10**5+1)+b]^=1
def main():
    global edge,AB
    N,M=map(int,input().split())
    data=[[] for i in range(N+1)]
    AB={}
    count=[0]*(N+1)
    for i in range(M):
        A,B=map(int,input().split())
        if A>B:
            A,B=B,A
        AB[A*(10**5+1)+B]=0
        data[A].append(B)
        data[B].append(A)
        count[A]^=1

    if M%2==1:
        print(-1)
        sys.exit()

    parent=[0]*(N+1)
    que=[1]
    parent[1]=1
    lsls=deque([])
    while que:
        h=[]
        for u in que:
            for v in data[u]:
                if parent[v]==0:
                    parent[v]=u
                    h.append(v)
                    if count[v]%2==1:
                        lsls.appendleft(v)
        que=h

    for i in lsls:
        if count[i]==0:
            continue
        else:
            count[i]=0
            while True:
                j=parent[i]
                if i==j:
                    break
                count_edge(i,j)
                if count[j]==1:
                    count[j]=0
                    break
                i=j
    num=10**5+1
    for u,j in zip(AB.keys(),AB.values()):
        if j!=1:
            print(u//num,u%num)
        else:
            print(u%num,u//num)
if __name__=="__main__":
    main()

Measured memory_bytes: 83872
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()

const int MOD = 1000000007;


//いろんなstlの使い方　https://qiita.com/tukejonny/items/f4013547df761a0b3523
//http://y-mazun.hatenablog.com/entry/20111202/1322840281



using namespace std;

int main(){
    int N,x;
    cin>>N>>x;
    if(x==1||x==2*N-1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
        if(x==2){
            int a[2*N-1];
            a[N-2]=x+1;
            a[N-1]=x;
            a[N]=x-1;
            a[N+1]=x+2;
            queue<int>que;
            for(int i=1;i<=2*N-1;i++){
                if(i==x+1||i==x||i==x-1||i==x+2){
                    continue;
                }else{
                    que.push(i);
                }

            }
            for(int i=0;i<2*N-1;i++){
                if(i==N-2||i==N-1||i==N||i==N+1){
                    continue;
                }else{
                    a[i]=que.front();
                    que.pop();
                }
            }
            for(int i=0;i<2*N-1;i++){
                cout<<a[i]<<endl;
            }


        }else{
            int a[2*N-1];
            a[N-2]=x-1;
            a[N-1]=x;
            a[N]=x+1;
            a[N+1]=x-2;
            queue<int>que;
            for(int i=1;i<=2*N-1;i++){
                if(i==x+1||i==x||i==x-1||i==x-2){
                    continue;
                }else{
                    que.push(i);
                }

            }
            for(int i=0;i<2*N-1;i++){
                if(i==N-2||i==N-1||i==N||i==N+1){
                    continue;
                }else{
                    a[i]=que.front();
                    que.pop();
                }
            }
            for(int i=0;i<2*N-1;i++){
                cout<<a[i]<<endl;
            }
        }
    }


}






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

int main()
{
	int t;
	t = 1;
	while (t--)
	{
		int n, k;
		cin >> n >> k;
		int a[n + 1];

		for (int i = 1; i <= n; i++)
			cin >> a[i];

		if (k > n)
		{
			cout << abs(a[n] - a[1]) << endl;
			return 0;
		}
		int dp[n + 1];

		dp[1] = 0;
		for (int i = 2; i <= k; i++)
			dp[i] = abs(a[i] - a[1]);

		for (int i = k + 1; i <= n; i++)
		{
			dp[i] = INT_MAX;
			for (int j = i - 1; j >= i - k; j--)
				dp[i] = min( dp[j] + abs(a[i] - a[j]), dp[i]);
		}

		cout << dp[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int pow2(int x) {
    int ret = 1;
    rep(i, x) ret *= 2;
    return ret;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P; cin >> N >> P;
    int A[51];
    rep(i, N) cin >> A[i];
    int cnt[2] = {};
    rep(i, N) cnt[A[i] % 2]++;
    if (P == 1 && cnt[1] == 0) {
        cout << 0 << endl;
        return 0;
    }
    cnt[1]--;
    cout << pow2(cnt[0]) * pow2(cnt[1]) << endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [0] + list(map(int, input().split())) + [0]

C = [0] * (N + 1)
S = 0
for i in range(N + 1):
    l = abs(A[i + 1] - A[i])
    C[i] = l
    S += l

ans = []
for i in range(1, N + 1):
    rst = S
    rst -= C[i] + C[i - 1]
    rst += abs(A[i + 1] - A[i - 1])
    ans.append(rst)

print(*ans, sep='\n')


Measured memory_bytes: 64108
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

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

		final char[] ch = sc.next().toCharArray();
		
		int[] count = new int[4];
		
		for(char c : ch){
			switch(c){
			case 'K':
				count[0]++;
				break;
			case 'U':
				count[1]++;
				break;
			case 'P':
				count[2]++;
				break;
			case 'C':
				count[3]++;
				break;
			}
		}
		
		int min = Integer.MAX_VALUE;
		
		for(int i : count){
			min =  Math.min(i, min);
		}
		
		System.out.println(min);
		
		
	}

}

Measured memory_bytes: 12000
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))

if A1*T1+A2*T2==B1*T1+B2*T2:
    print('infinity')
    exit()

if A1*T1+A2*T2 < B1*T1+B2*T2:
    A1, B1 = B1, A1
    A2, B2 = B2, A2

if A1>B1:
    print(0)
    exit()

Dtot = (A1*T1+A2*T2) - (B1*T1+B2*T2)
Dmin = (B1*T1) - (A1*T1)

ans = 2*((Dmin-1)//Dtot) + 1
if Dmin%Dtot==0: ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    ll n;
    std::cin >> n;
    std::cout << (n/500)*1000+((n%500)/5)*5 << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

// ----- MaxFlow -----

class MaxFlow
{
  struct Edge
  {
    int to;
    ll cap;
    int rev;
  };
  constexpr static ll INFTY = 10000000000000010LL;

  int N;
  vector<vector<Edge>> G;
  vector<bool> used;

public:
  MaxFlow() {}
  MaxFlow(int N) : N{N}
  {
    G.resize(N);
    used.resize(N);
  }

  void add_edge(int from, int to, ll cap = 1LL)
  {
    G[from].push_back({to, cap, static_cast<int>(G[to].size())});
    G[to].push_back({from, 0, static_cast<int>(G[from].size() - 1)});
  }

  ll max_flow(int s, int t)
  {
    ll flow = 0;
    while (true)
    {
      fill(used.begin(), used.end(), false);
      ll f = dfs(s, t, INFTY);
      if (f == 0)
      {
        return flow;
      }
      flow += f;
    }
  }

private:
  ll dfs(int v, int t, ll f)
  {
    if (v == t)
    {
      return f;
    }
    used[v] = true;
    for (auto &e : G[v])
    {
      if (!used[e.to] && e.cap > 0)
      {
        ll d = dfs(e.to, t, min(f, e.cap));
        if (d > 0)
        {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
};

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp

int main()
{
  int N, M;
  cin >> N >> M;
  MaxFlow flow{N};
  for (auto i = 0; i < M; i++)
  {
    int from, to;
    ll cap;
    cin >> from >> to >> cap;
    flow.add_edge(from, to, cap);
  }
  cout << flow.max_flow(0, N - 1) << endl;
}



Measured memory_bytes: 3232
/**
 *   author: r1933
**/
#include "bits/stdc++.h"

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  long long res = 0;
  vector<int> cum((int)s.length() + 5);
  for (int i = 1; i <= s.length(); ++i) {
    cum[i] = cum[i-1] + (s[i-1] == 'B');
    res += (s[i-1] == 'W' ? cum[i] : 0);
  }
  cout << res << "\n";
  return 0;
}


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

import collections

c = collections.Counter(a)
cs = sorted(c.items(), key=lambda x:x[0],reverse=True)
a=[0,0]
f=0
sq=0
for i in cs:
    if sq == 0 and i[1] >= 4:
        sq=i[0]**2
    if i[1] >= 2:
        a[f]=i[0]
        f+=1
    if f >= 2:
        break
print(max(sq,a[0]*a[1]))
 
 

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point {
 public:
  double x, y;

  Point(double x = 0, double y = 0): x(x), y(y) {}

  Point operator + (Point p) { return Point(x+p.x, y+p.y); }
  Point operator - (Point p) { return Point(x-p.x, y-p.y); }
  Point operator * (double a) { return Point(a*x, a*y); }
  Point operator / (double a) { return Point(x/a, y/a); }

  double norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

typedef Point Vector;
typedef vector <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

  Segment(Point p1 = Point(), Point p2 = Point()): p1(p1), p2(p2) {}
};
typedef Segment Line;

double norm(Vector a) {
  return a.x*a.x+a.y*a.y;
}

double abs(Vector a) {
  return sqrt(norm(a));
}
// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// ??´???l??¨???p????????¢
double getDistanceLP(Line l, Point p) {
  return abs(cross(l.p2-l.p1, p-l.p1))/abs(l.p2-l.p1);
}

// ?°???±:??´???s???p?????????????????????????????¨?????????????????????
Point project(Segment s, Point p) {
  Vector base = s.p2-s.p1;
  double r = dot(p-s.p1, base)/norm(base);
  return s.p1+base*r;
}

class Circle {
 public:
  Point c;
  double r;
  Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

// ???c??¨??´???l????????????????????????
bool intersect(Circle c, Line l) {
  return getDistanceLP(l, c.c) < c.r;
}

// ???c??¨??´???l?????????
pair<Point, Point> getCrossPoints(Circle c, Line l) {
  Vector pr = project(l, c.c);
  Vector e = (l.p2-l.p1)/abs(l.p2-l.p1);
  double base = sqrt(c.r*c.r-norm(pr-c.c));
  return make_pair(pr+e*base, pr-e*base);
}

int main() {
  Circle c;
  cin >> c.c.x >> c.c.y >> c.r;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    Line l;
    cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
    pair<Point, Point> ans = getCrossPoints(c, l);
    if (ans.second < ans.first) swap(ans.first, ans.second);
    cout << fixed << setprecision(20)
         << ans.first.x << " " << ans.first.y << " " << ans.second.x << " " << ans.second.y << endl;
  }
}

Measured memory_bytes: 1300
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    long A = long.Parse(ipt[0]);
    long B = long.Parse(ipt[1]);
    long K = long.Parse(ipt[2]);
    if (K <= A) {
      Console.WriteLine((A - K).ToString() + " " + B.ToString());
    } else {
      Console.WriteLine("0 " + Math.Max(B - (K - A), 0));
    }
  }
}

Measured memory_bytes: 11220
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void resolve() {
    int n;
    cin >> n;
    VLL l(n+1);
    l[0] = 2;
    l[1] = 1;
    REP(i,2,n+1) l[i] = l[i-2] + l[i-1];
    cout << l[n] << endl;
}

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

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
template<class T> using v = vector<T>;

#define REP(i, n) for(ll i = 0; i < n; ++i)
#define REP3(i, B, E) for(ll i = B; i <= E; ++i)

template<class T> T read() { T x{}; cin >> x; return x; }
template<class T> v<T> read(int N){ v<T> x(N); REP(i, N) cin >> x[i]; return x; }

template<class T>
void write(const T &x){ cout << x << endl; }
void write(double x){ printf("%.15f\n", x); }

template<class T> T& chmin(T &obj, T val){ return obj = min(obj, val); }
template<class T> T& chmax(T &obj, T val){ return obj = max(obj, val); }

// 二分探索 : [low, high) の範囲で述語 pred がtrue を返す最大の値を返す
template<class Pred>
ll bsearch(ll low, ll high, Pred pred){
    while(low + 1 < high){
        const ll mid = low + (high - low) / 2;
        if(pred(mid)){ low = mid; }
        else{ high = mid; }
    }
    return low;
}

int main() {
    
    auto S = read<string>();
    
    unordered_map<string, ll> m = {
        {"SUN", 7},
        {"MON", 6},
        {"TUE", 5},
        {"WED", 4},
        {"THU", 3},
        {"FRI", 2},
        {"SAT", 1}, 
    };
    
    write(m[S]);
}



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

int main() { 	
 int N,K,kk;
  cin >> N >> K;
  string A;
  cin >>A;
  kk =K-1;
  if(A.at(kk)=='A'){
  A.at(kk)='a';
  }else if(A.at(kk)=='B'){
   A.at(kk)='b';
  }else if(A.at(kk)=='C'){
   A.at(kk)='c';
  }
  cout << A<< endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  unsigned long long a,b, r;
  cin >> a >> b;

  if (b-a <= 4) {
    r = 0;
    while(a <= b){
      r ^= a;
      a++;
    }
    cout << r;
    return 0;
  }

  r=0;
  if (a%2){
    r ^= a;
    a++;
  }
  if (b%2 == 0) {
    r ^= b;
    b--;
  }

  if ( (b-a)%4 == 1)
    r^=1;


  cout << r << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define mod 1000000007
#define inf 1000000000000000000
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n,x;
	cin>>n>>x;
	ll arr[n];
	for(ll &i:arr)
		cin>>i;
	for(ll i=1;i<n;i++)
		arr[i]=arr[i]+arr[i-1];
	ll ans=n-1;
	for(ll i=0;i<n;i++)
	{
		if(arr[i]>x)
		{
			ans=i-1;
			break;
		}

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





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

#define N 100123
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define all(cont) cont.begin(), cont.end()
#define fastio ios::sync_with_stdio(false); cin.tie(0)

int main(){
	fastio;
    int n, m, a;
    ll dp[N];
    bool can[N];
    fill(can, can+N, true);
    cin >> n >> m;

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

    dp[0] = 1;
    for(int i = 1 ; i <= n ; i++){
    	dp[i] = 0;
    	if(can[i]){
    		dp[i] = dp[i-1];
    		if(i > 1) dp[i] = (dp[i-2] + dp[i]) % mod;
    	} 
    }
    cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long  N,A,B;
    cin >> N >> A >> B;
    
    long long Q,mod,r;
    Q=N/(A+B);
    mod=N%(A+B);
    
    if (mod>=A) {
        r=A;
    }
    else{
        r=mod;
    }
    
    long long ans=Q*A+r;
    
    cout << ans << endl;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <numeric>
#include <utility>
#include <cmath>
#include <algorithm>

using ll = long long;

template <class T>
using vec = std::vector<T>;

template <class T>
constexpr T nil = static_cast<T>(-1);

template <class T>
constexpr T inf = std::numeric_limits<T>::max() / 2;

constexpr ll INF = inf<ll>;

//ワーシャルフロイド法はO(log(|V|^3))
void solve()
{
    using namespace std;

    int n, m;
    cin >> n >> m;

    vec<vec<ll>> dist(n, vec<ll>(n, INF));
    
    for (int i = 0; i < n; ++i)
        dist[i][i] = 0;

    for (int i = 0, begin, end, d; i < m; ++i)
    {
        cin >> begin >> end >> d;
        dist[begin][end] = d;
    }

    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
        {
            if (dist[i][k] == INF) continue;
            for (int j = 0; j < n; ++j)
            {
                if (dist[k][j] == INF) continue;
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }

    bool negative = false;
    for (int i = 0; i < n && !negative; ++i)
        if (dist[i][i] < 0)
            negative = true;
    
    if (negative)
        cout << "NEGATIVE CYCLE" << endl;
    else
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
            {
                if (dist[i][j] == INF)
                    cout << "INF";
                else
                    cout << dist[i][j];

                cout << (j + 1 != n ? " " : "\n");
            }
}

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


Measured memory_bytes: 3248
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int n = sc.nextInt();
    int[] s=new int[n];
    for (int i = 0; i < n; i++) {
        s[i]=sc.nextInt();
    }
    int sum=0;
    for (int i = 0; i < n; i++) {
        sum+=s[i];
    }
    int m=100;
    if(sum%10!=0){
        out.println(sum);
    }else{
        for (int i = 0; i < n; i++) {
            if(s[i]%10!=0){
                m=min(m,s[i]);
            }
        }
        if(m%10!=0){
            out.println(sum-m);
        }else{
            out.println(0);
        }
    }
}}

Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

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

}


Measured memory_bytes: 3104
// STRIVER_79 
// Lets goto the next level 
// AIM 6* at CC and CM at CF *__* 

#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)(1e9 + 21)
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long 
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define in(x) scanf("%intd", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define fi first
#define se second
#define kitna se
#define endl "\n"
#define pi pair<int, int>
#define LL long long 
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int nax =  (int)(1*1e5+10);

// int SPF[N+5];

// void SOF()
// {
//     SPF[1] = 1;
//     for (int i=2; i<N; i++)
//         SPF[i] = i;
//     for (int i=4; i<N; i+=2)
//         SPF[i] = 2;
 
//     for (int i=3; i*i<N; i++)
//         {
//         if (SPF[i] == i)
//             {
//             for (int kon=i*i; kon<N; kon+=i)
//                 if (SPF[kon]==kon)
//                    SPF[kon] = i;
//             }
//         }
// }
int n,w;
int wt[nax],val[nax]; 
int dp[nax]; 

// int func(int ind,int vall)
// {
// 	// if(vall>w) return -1e18; 
// 	if(ind==n) return 0; 
// 	if(dp[ind][vall]!=-1) return dp[ind][vall]; 
// 	int ans = INT_MIN; 
// 	ans = wt[ind] + func(ind+1,vall+val[ind]); 
// 	ans = max(ans,func(ind+1,vall)); 

	
// }





signed main(){

int t=1; 
//cin >> t;
// string s; 
// getline(cin,s);

while(t--)
{
	cin >> n >> w;
	for0(i,n)
	cin >> wt[i] >> val[i]; 

	ini(dp,-1); 

	int sum = 0;
	for0(i,n) sum += val[i];

	ini(dp,1e9+5);

	dp[0] = 0; 

	for0(i,n)
	{
		bloop(j,sum,0)
		{
			if(dp[j]+wt[i]<=w)
			{
				dp[j+val[i]] = min(dp[j+val[i]],dp[j]+wt[i]); 
			}
		}
	}

	bloop(i,sum,0)
	{
		if(dp[i]<=w)
		{
			cout << i;
			rr;
		}
	}
}

rr;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
typedef long double ld;
#define pi 3.14159265358979

int  main()
{
	int n; cin >> n;
	vector <int> a(n);
	rep(i, n)
		cin >> a[i];
	sort(a.begin(), a.end());
	int cnt = 0;
	int ans = 0;
	int at = 0;
	for(int i = 0; i < n; i++)
	{
		if (a[i] - a[at] <= 2)
		{
			cnt = (i - at) + 1;
		}
		else
		{
			ans = max(cnt, ans);
			cnt = 1;
			while (abs(a[at]- a[i]) > 2)
				at++;
		}
		// cout << cnt << endl;
	}
	ans = max(cnt, ans);
	// cout << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 21:05:26 2020

@author: Kanaru Sato
"""

import math

n = int(input())
rootn = int(math.sqrt(n))

list = []

for i in range(1, rootn+1):
    if n%i ==0:
        list.append([i,n//i])

dist = list[-1][0]+list[-1][1]-2

print(dist)

Measured memory_bytes: 3472
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  if(s[s.size()-1]!='s')
  {
    s+='s';
  }
  else{
    s+="es";
  }
  cout<<s;



}  


Measured memory_bytes: 3656
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

string S;
long long K;
long long idx;

int main(){
	cin >> S >> K;

	while(K != 0 && idx < S.size()){
		long long change;
		if(S[idx] == 'a'){
			idx++;
			continue;
		}
		if((long long)'z' - S[idx] + 1 > K){
			idx++;
			continue;
		}else{
			change = 'z' - S[idx] + 1;
			K -= change;
			S[idx] = (S[idx] + change - 'a')%26 + 'a';
			idx++;
		}
	}

	if(K != 0){
		S[S.size() - 1] = (S[S.size() - 1] + K - 'a')%26 + 'a';
	}

	for(int i = 0; i < S.size(); i++){
		cout << S[i];
	}
	cout << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <complex>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef complex<double> vec2;

const double EA = 1e-9;

double dot(vec2 a , vec2 b){
	return a.real() * b.real() + a.imag() * b.imag();
}

double cross(vec2 a , vec2 b){
	return a.real() * b.imag() - a.imag() * b.real();
}

double pab(vec2 a , vec2 b){
	return abs(vec2(a - b));
}

double dis(vec2 a , vec2 b , vec2 c){
	return fabs(cross(a - c , b - c)) / pab(b , c);
}

vec2 p1,p2,p3;
vec2 q;
double h;
double d1,d2,d3;

bool eval(double a){
	return d3 * (h-a) / h >= 2 * a;
}

double BS(double a , double b , int t){
	double c = (a+b) / 2.0;
	if(t == 100) return c;
	return eval(c) ? BS(c,b,t+1) : BS(a,c,t+1);
}

int main(){
	int x1,x2,x3,y1,y2,y3;
	scanf("%d%d%d%d%d%d" , &x1 , &y1 , &x2 , &y2 , &x3 , &y3);
	p1 = vec2(1.*x1,1.*y1);
	p2 = vec2(1.*x2,1.*y2);
	p3 = vec2(1.*x3,1.*y3);
	d1 = pab(p2,p3);
	d2 = pab(p3,p1);
	d3 = pab(p1,p2);
	if(d1 >= d2 && d1 >= d3){
		swap(p1,p3);
		swap(d1,d3);
	} else if(d2 >= d3 && d2 >= d1){
		swap(p2,p3);
		swap(d2,d3);
	}
	double s = d1+d2+d3;
	q = d1 / s * p1 + d2 / s * p2 + d3 / s * p3;
	h = dis(q,p1,p2);
	if(h==0.0) return 0;
	printf("%.9f\n" , BS(0.0,h,0));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int mx = max(a,max(b,c));
  if((a+b+c) / mx == 2 && (a+b+c) % mx == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,d,x;
  cin>>n>>d>>x;
  vector<int> as(n);
  for(int i=0;i<n;i++){cin>>as.at(i);}
  for(int i=0;i<n;i++){
    for(int j=0;j>=0;j++){
      if(as.at(i)*j+1<=d){
        x++;
      }else{
        break;
      }
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main() {
    int n;cin>>n;
    int l=0,m=0;
    rep(i,n){
        int x;cin>>x;
        l+=x;
        m+=x*x;
    }
    cout<<(l*l-m)/2<<endl;
}

Measured memory_bytes: 256
N = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == [] and n != 1:
        arr.append([n, 1])

    return arr


factors = factorization(N)

ans = 0
for p, e in factors:
    ans += int((-1 + (8 * e + 1) ** 0.5) / 2)

print(ans)

Measured memory_bytes: 63288
int main(){
	int a,n,m,x,y,k,s=0;
	scanf("%d%d%d",&a,&n,&m);
	for(y=1;y<73;y++){ //x≦m(≦10^8)よりy≦72（最大はx=9999999）
		x=pow(y+a,n); //yからxを計算
		if(x>m)break; //x≦mの条件チェック
		for(k=0;x;x/=10)k+=x%10; //xの各桁合計k*/
		if(k==y)s++; //kとyの一致回数s
	}
	printf("%d\n",s);
}


Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
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=1LL<<60;

int x;

int main(){
    cin>>x;
    if(x<600) cout<<'8'<<"\n";
    else if(x<800) cout<<'7'<<"\n";
    else if(x<1000) cout<<'6'<<"\n";
    else if(x<1200) cout<<'5'<<"\n";
    else if(x<1400) cout<<'4'<<"\n";
    else if(x<1600) cout<<'3'<<"\n";
    else if(x<1800) cout<<'2'<<"\n";
    else cout<<'1'<<"\n";
    return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(scanf("%d %d",&H,&W)){
    if(H==0&&W==0)break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if((i%2+j%2)%2==0)printf("#");
	else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
import fractions

a, b, c, d = map(int, input().split())
one_to_b = b // c + b // d
one_to_a = (a - 1) // c + (a - 1) // d
l = c * d // fractions.gcd(c, d)
dup = b // l - (a - 1) // l
dividable = one_to_b - one_to_a - dup
print(b - a + 1 - dividable)


Measured memory_bytes: 5432
# coding: utf-8
# Your code here!
class UnionFindTree:
    def __init__(self, n):
        self._tree = [i for i in range(n)]
        self._rank = [1] * n
    def root(self, a):
        if self._tree[a] == a:return a
        self._tree[a] = self.root(self._tree[a])
        return self._tree[a]
    def is_same_set(self, a, b):
        return self.root(a) == self.root(b)
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._rank[ra] < self._rank[rb]:
            self._tree[ra] = rb
        else:
            self._tree[rb] = ra
            if self._rank[ra] == self._rank[rb]:
                self._rank[ra] += 1

def solve(n, m, x):
    uft = UnionFindTree(n)
    for a,b in x:
        uft.unite(a-1, b-1)
    return len(set(uft.root(i) for i in range(n)))-1

if __name__ == "__main__":
    n,m = map(int, input().split())
    *edges, = [list(map(int, input().split())) for _ in range(m)]
    print(solve(n,m,edges))

Measured memory_bytes: 32700
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}
/**
* @fn
* 指定した値との差の絶対値が最小のvectorの番号を返します。
*/
long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpabsmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b) && a.at(i) >= b) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


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



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val array =
        intArrayOf(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)
    val n = readLine()!!.toInt()
    println(array[n - 1])
}

Measured memory_bytes: 29764
use proconio::input;

fn main() {
    input! { n: usize, q: usize }

    let mut t = FenwickTree::new(n);
    for i in 0..n {
        input! { a: u64 }
        t.add(i, a);
    }

    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: u64 }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    v: Vec<T>,
}

use std::ops::{AddAssign, Sub};
use num::{Zero, zero};
impl<T: Copy + AddAssign + Sub<Output = T> + Zero> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            v: vec![zero(); n],
        }
    }

    fn add(&mut self, i: usize, v: T) {
        let mut i = i + 1;
        while i <= self.v.len() {
            self.v[i - 1] += v;
            i += i & i.wrapping_neg();
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= i & i.wrapping_neg();
        }
        v
    }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> nums(N);
  int ans = 0;
  for (int i = 0; i < N; i++){
    cin >> nums.at(i);
  }
  for (int i = 0; i < N - 2; i++){
    if (nums.at(i) >= nums.at(i + 1) && nums.at(i + 1) >= nums.at(i + 2)) ans++;
    else if (nums.at(i) < nums.at(i + 1) && nums.at(i + 1) < nums.at(i + 2)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = int(input())

def dfs(N, a, b, c):
  if int(N) > S:
    return 0
  res = 0 if a == 0 or b == 0 or c == 0 else 1
  for i in "357":
    if i == "3":
      res += dfs(N+i, a+1, b, c)
    if i == "5":
      res += dfs(N+i, a, b+1, c)
    if i == "7":
      res += dfs(N+i, a, b, c+1)
  return res

print(dfs("0", 0, 0, 0))

Measured memory_bytes: 3064
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]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

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


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    A = int(input())
    print(N * N - A)


if __name__ == '__main__':
    main()


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

int main() {
  long long X,K,D;
  cin >> X >> K >> D;
  long long A = abs(X)/D;
  
  if (A >= K)
    cout << abs(X) - abs(K*D) << endl;
  else if ((K - A)%2 == 0)
    cout << abs(X) - abs(A*D) << endl;
  else
    cout << D - abs(X) + abs(A*D) << endl;
  
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();

    int ans = 0;
    while (X > 0 || Y >0) {
      if (X >= 1 && Y >= 1) {
        
        int num = Math.min(X, Y);
        if (2*C < A + B) {
          ans += 2*C*num;
        } else {
          ans += (A+B)*num;
        }
        X -= num;
        Y -= num;
      } else if (X >= 1) {
        if (2*C < A) {
          ans += 2*C*X;
        } else {
          ans += A*X;
        }
        X -= X;
      } else if (Y >= 1) {
        if (2*C < B) {
          ans += 2*C*Y;
        } else {
          ans += B*Y;
        }
        Y -= Y;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
import java.math.*;import java.util.*;class Main{public static void main(String[]z){int p[]=new int[10001],i=0;for(BigInteger x=BigInteger.ONE;i++<10000;p[i]=p[i-1]+x.intValue())x=x.nextProbablePrime();for(Scanner s=new Scanner(System.in);(i=s.nextInt())>0;)System.out.println(p[i]);}}

Measured memory_bytes: 179436
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int64_t n, a;
    cin >> n >> a;

    int64_t ans = n;

    for (int p = 1; p < 50; p++) {
        multiset<int64_t> ss;
        for (int i = 0; i < p + 1; i++) {
            ss.insert(2);
        }

        for (;;) {
            int64_t tt = 1;
            for (auto &s: ss)
                tt *= s;

            if (tt >= n) {
                break;
            }

            auto mi = *ss.begin();
            ss.erase(ss.begin());
            ss.insert(mi + 1);
        }

        int64_t cur = 0;
        for (auto &s: ss)
            cur += s;
        cur += p * a;

        ans = min(ans, cur);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	N := ScanInt(scanner)
	D := ScanInt(scanner)
	X := ScanInt(scanner)
	
	for i := 0; i < N; i++ {
	    A := ScanInt(scanner)
	    for j := 1; j <= D; j += A {
	        X++
	    }
	}
	
	fmt.Println(X)
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
/* Murad Eynizade */

#include <bits/stdc++.h>
#define intt long long
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define SIZE 300001
#define INF INT_MAX
#define F first
#define S second
#define in(a) scanf("%d",&a);
#define outn(a) printf("%d\n",&a);
#define outs(a) printf("%d ",&a);


using namespace std;

int n , W;

intt dp[SIZE] , we[SIZE] , val[SIZE] , res;

int main()
{
    FAST_READ;
    cin>>n>>W;
    for (int i = 1;i<=n;i++) cin>>we[i]>>val[i];
    for (int i = 1;i<=n;i++) {
        for (int j = W;j>=0;j--) {
            if (j - we[i] < 0)break;
            dp[j] = max(dp[j] , dp[j - we[i]] + val[i]);
            res = max(res,dp[j]);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4352
fun main(args: Array<String>){

    var (a,b,c,d) = readLine()!!.split(" ").map{it.toLong()}
    var ans = Long.MIN_VALUE
    ans = Math.max(ans,a*c)
    ans = Math.max(ans,a*d)
    ans = Math.max(ans,b*c)
    ans = Math.max(ans,b*d)

    println(ans)



}


Measured memory_bytes: 36460
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  lol a[n + 5];
  rep(i, n){
    cin >> a[i];
  }
  sort(a, a + n, greater<lol>());
  lol ans = 0;
  reps(i, n - 1){
    ans += a[i / 2];
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 5220