akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 1000000007
#define ve vector
#define pi pair<int,int>
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}



void solve()
{ 
ll n,x,t;
    cin>>n>>x>>t;
    ll ans=(n+x-1)/x;
    ans*=t;
    cout<<ans<<endl;

}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;
   
    
     int t=1;
  //  cin>>t;
     while(t--)
    	solve();
    return 0;
}



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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mod = 1e9 + 7;
int n, q;
vector <pair <int, int> > lim[305];
int dp[305][305][305];

int f(int i, int a, int b, int c) {
	if (~dp[a][b][c]) return dp[a][b][c];
	rep(j, lim[i].size()) {
		int l = lim[i][j].first, x = lim[i][j].second;
		int cnt = (a >= l) + (b >= l) + (c >= l);
		if (cnt != x) return dp[a][b][c] = 0;
	}
	if (i == n) return dp[a][b][c] = 1;
	return dp[a][b][c] = (0LL + f(i + 1, i + 1, b, c) + f(i + 1, a, i + 1, c) + f(i + 1, a, b, i + 1)) % mod;
}

int main() {
	scanf("%d %d", &n, &q);
	rep(i, q) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		lim[r].pb(mp(l, x));
	}
	memset(dp, -1, sizeof(dp));
	printf("%d\n", f(0, 0, 0, 0));
	return 0;
}

Measured memory_bytes: 114668
import sys
sys.setrecursionlimit(500000)

def dfs(v,c):
    color[v] = c

    for i in a[v]:
        if color[i] != -1:
            if color[i] == c:return False
            continue
        if dfs(i,1-c) == False:return False

n,m = map(int,input().split())
a = [[]for i in range(n)]
color = [-1 for _ in range(n)]

for i in range(m):
    x,y= map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)
if dfs(0,0) == False:
    print(n*(n-1)//2-m)
else:print(color.count(0) * color.count(1) -m)

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

using namespace std;

int main(void) {
    long n, d, a;
    cin >> n >> d >> a;
    
    vector<long> imos(2e5 + 1);
    vector<pair<long,long>> xh(n);
    for(auto &e: xh) cin >> e.first >> e.second;

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

    auto is = xh.begin(), it = xh.begin();

    long r = 0;
    long s = 0;
    for(int i=0; i<n; i++) {
        s += imos[i];
        xh[i].second -= s;

        long t = max(0l, (xh[i].second + a - 1) / a * a);
        s += t;

        imos[upper_bound(xh.begin(), xh.end(), make_pair(xh[i].first + 2*d, (long)1e9)) - xh.begin()] += -t;

        r += t / a;
    }
    cout << r << endl;
}


Measured memory_bytes: 4992
class Tree:
    def __init__(self,parent,left,right):
        self.parent = parent
        self.left = left
        self.right = right

def getdepth(u):
    for i in range(N):
        depth = 0
        j = i
        while trees[j].parent != -1:
            j = trees[j].parent
            depth += 1
        depths[i] = depth


N = int(input())
# ?????????
trees = [Tree(-1,-1,-1) for i in range(N)]
for i in range(N):
    l = list(map(int, input().split()))
    no = l[0]
    jisu = l[1]
    # 2???????????????????????§???????´??????????
    childs = l[2:]
    for j in range(jisu):
        child = childs[j]
        if j == 0:
            trees[no].left = child

        if j != len(childs)-1:
            trees[child].right = childs[j+1]

        trees[child].parent = no

r = 0
for i in range(N):
    if trees[i].parent == -1:
        r = i

depths = [-1] * N
getdepth(r)

for i in range(N):
    type = ""
    if trees[i].parent == -1: type = "root"
    elif trees[i].left == -1: type = "leaf"
    else: type = "internal node"
    childs = "["
    child = trees[i].left
    while child != -1:
        childs += str(child)
        child = trees[child].right
        if child != -1: childs += ", "
    childs += "]"

    print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, trees[i].parent, depths[i], type, childs))

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

int binSearch(int *A, const int key, const int N) {
  int left = 0;
  int right = N;
  while (left < right) {
    int mid = (left + right) / 2;
    if (A[mid] == key) return mid;
    if (key < A[mid]) right = mid;
    else if (A[mid] < key) left = mid + 1;
  }
  return -1;
}

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

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

  int Q;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int key;
    cin >> key;
    cout << (binSearch(A, key, N) >= 0) << endl;
  }

  return 0;
}



Measured memory_bytes: 3484
N = int(input())
C = input()

S = 0
E = 1
Ans = 0

while S < N - E:
  while C[S] == 'R' and S < N-1:
    S += 1
    
  while C[E*-1] == 'W' and E < N:
    E += 1
    
  if S >= N - E:
    break
  else:
    S += 1
    E += 1
  
  Ans += 1

print(Ans)



Measured memory_bytes: 9264
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
/*----------------------------------------------------------------------------------*/

int main() {
    int h, w; cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i,h) rep(j,w) cin >> a[i][j];

    vector<vector<int>> ans(h*w, vector<int>(4));
    int cnt = 0;
    rep(i,h) rep(j, w) {
        if (a[i][j]%2==1) {
            vector<int> tmp(4);
            if (i+1<h) {
                ans[cnt][0] = i, ans[cnt][1] = j, ans[cnt][2] = i+1, ans[cnt][3] = j;
                a[i+1][j]++;
                cnt++;
            } else if (j+1<w) {
                ans[cnt][0] = i, ans[cnt][1] = j, ans[cnt][2] = i, ans[cnt][3] = j+1;
                a[i][j+1]++;
                cnt++;
            }
        }
    }

    cout << cnt << endl;
    rep(i,cnt) rep(j,4) {
        printf("%d%c", ans[i][j]+1, j==3?'\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 16768
#include <cstdio>

using namespace std;

int get_sum(int num,int sum,int *u,int n){
	int i,j;
	if(num==0&&sum==0){
		return 1;
	}
	if(n>9){
		return 0;
	}
	return (get_sum(num-1,sum-u[n],u,n+1)+get_sum(num,sum,u,n+1));
}

int main()
{
	int sum,num;
	int u[10];
	int i;
	while(1){
		scanf("%d %d",&num,&sum);
		if(num==0&&sum==0) break;
		for(i=0;i<10;i++){
			u[i]=i;
		}
		printf("%d\n",get_sum(num,sum,u,0));
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())

A = list(map(int,input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    f = 0
    for i in A:
        ans *= i
        if ans > 10**18:
            print(-1)
            f = 1
            break
    if f == 0:
        print(ans)

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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());
        var p = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var ans = 0;

        for (int i = 0; i < n - 2; i++)
        {
            var c = p[i..(i+3)].OrderBy(x => x).ElementAt(1);
            if (c == p[i + 1])
                ans++;
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 28428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>

#define INF 100000000

using namespace std;

int main()
{
    int n;
    cin >> n;
    double x, SUM_BTC = 0;
    int SUM_JPY = 0;
    string u;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> u;
        if (u == "JPY")
        {
            SUM_JPY += (int)x;
        }
        else
        {
            SUM_BTC += x;
        }
    }
    printf("%.5f\n", (double)SUM_JPY + SUM_BTC * 380000.0);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int fanc(int n);

int main(void)
{
    long long int ans;
    int n;
    scanf("%d",&n);
    printf("%lld\n",fanc(n));
    return 0;
}

long long int fanc(int n)
{
    if (n < 2) {
        return 1;
    } else {
        return (n * fanc(n-1));
    }
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
map<ll,ll>mp;
int main(){
  ll s,cnt=0;
  cin>>s;
  while(1){
    mp[s]++;
    cnt++;
    if(mp[s]==2){
      cout<<cnt<<endl;
      return 0;
    }
    if(s%2)s=3*s+1;
    else s/=2;
  }
  return 0;
}


Measured memory_bytes: 256
void main() {
    import std.stdio, std.string, std.conv;

    auto rd = readln.split.to!(int[]);
    int N = rd[0], Y = rd[1];

    foreach (x ; 0 .. N + 1) {
        foreach (y ; 0 .. N + 1 - x) {
            int z = N - x - y;

            if (10000*x + 5000*y + 1000*z == Y) {
                writeln(x, ' ', y, ' ', z);
                return;
            }
        }
    }

    writeln(-1, ' ', -1, ' ', -1);
}

Measured memory_bytes: 256
# https://abc113.contest.atcoder.jp/tasks/abc113_c
def pad(n):
    return '{:0>6}'.format(n)


N, M = map(int, input().split())
work = [None for _ in range(M)]
orig = [None for _ in range(M)]  # retains original order
for i in range(M):
    Pi, Yi = map(int, input().split())
    data = [Pi, Yi, 1, i]
    work[i] = data
    orig[i] = data

work.sort(key=lambda x: x[1])  # sort by year
work.sort(key=lambda x: x[0])  # sort by prefectures

for i in range(1, M):
    if work[i][0] == work[i - 1][0]:
        work[i][2] = work[i - 1][2] + 1

ans = ''
for di in orig:
    ans += (pad(di[0]) + pad(di[2])) + '\n'
print(ans)


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


using namespace std;
double pi=3.14159265358979323846264338;
long long sum;
long long arr[200001];
int main(){
	int n;
	cin>>n;
	long long sum=0;
	long long ans=0;
	long long m=1000000007;
	for(int i=0;i<n;i++){cin>>arr[i];sum+=arr[i];}
	for(int i=0;i<n;i++){
		sum-=arr[i];
		ans+=sum%m*arr[i];
		ans=ans%m;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5196
import java.io.*;
import java.util.*;



public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
                    
        str = br.readLine();
        int N = Integer.parseInt(str);
        str = br.readLine();
        String[] strs = str.split("\\s");
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = Integer.parseInt(strs[i]);
        }

        int count = 0;
        for(int i=0; i<N; i++){
            int minj = i;
            for(int j= i; j<N; j++){
                if(A[j] < A[minj]){
                    minj = j;
                }
            }
            if( i != minj){
                int temp = A[i];
                A[i] = A[minj];
                A[minj] = temp;
                count++;
            }
        }

        StringBuilder sb = new StringBuilder();
        for(int i=0;i<N;i++){
            sb.append(A[i]);
            if(i != N-1){
                sb.append(" ");
            }
        }
        sb.append("\n");
        sb.append(count);

        System.out.println(sb.toString());

        br.close();
    }

    
}


Measured memory_bytes: 24600
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, m;

	void run(){
		sc.useDelimiter("[,]|(\\s)+");
		n=sc.nextInt();
		m=sc.nextInt();
		@SuppressWarnings("unchecked")
		LinkedList<E>[] es=new LinkedList[n];
		for(int i=0; i<n; i++){
			es[i]=new LinkedList<E>();
		}

		for(int i=0; i<m; i++){
			int u=sc.nextInt()-1;
			int v=sc.nextInt()-1;
			int cost1=sc.nextInt();
			int cost2=sc.nextInt();
			es[u].add(new E(v, cost1));
			es[v].add(new E(u, cost2));
		}

		int s=sc.nextInt()-1;
		int g=sc.nextInt()-1;
		int m1=sc.nextInt();
		int m2=sc.nextInt();

		int ans=m1-m2-(dijkstra(es, s, g)+dijkstra(es, g, s));
		println(""+ans);
	}

	int dijkstra(LinkedList<E>[] es, int s, int g){
		int n=es.length;
		int[] d=new int[n];
		PriorityQueue<P> que=new PriorityQueue<P>();

		Arrays.fill(d, INF);
		d[s]=0;
		que.offer(new P(s, 0));
		for(; !que.isEmpty();){
			P p=que.poll();
			if(d[p.v]<p.d){
				continue;
			}
			// debug(p);
			for(E e : es[p.v]){
				// debug("\t"+e.to);
				if(d[e.to]>d[p.v]+e.cost){
					d[e.to]=d[p.v]+e.cost;
					que.offer(new P(e.to, d[e.to]));
				}
			}
			// debug(d);
		}
		// debug();
		return d[g];
	}

	class E{
		int to, cost;

		E(int to, int cost){
			this.to=to;
			this.cost=cost;
		}
	}

	class P implements Comparable<P>{
		int v, d;

		P(int v, int d){
			this.v=v;
			this.d=d;
		}

		@Override
		public int compareTo(P p){
			return d-p.d;
		}

		@Override
		public String toString(){
			return v+","+d;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.*;

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

        int ans;
        int ori = 753;
        int min = 1000;
        String tmp = "";
        int imin;
        for(int i = 0;i<s.length();i++){
            if(i+2==s.length()){
                break;
            }
            tmp = s.substring(i,i+3);
            imin = Integer.valueOf(tmp);
            imin = Math.abs(imin - ori);
            if(imin < min){
                min = imin;
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int 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;
}

int main() {
  int A, B;
  cin >> A >> B;
  int ans = max(0, A - B * 2);
  cout << ans << endl;
}

Measured memory_bytes: 256
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;
typedef unsigned int uint;
typedef long long ll;

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n, k;
    cin>>n>>k;
    vector<int> a(n);
    fori(n)
        cin>>a[i];

    int amin=*min_element(a.begin(), a.end());
    //int amax=*max_element(a.begin(), a.end());
    vector<bool> win(k+1);
    vector<bool> vis(k+1, false);

//cout<<"n="<<n<<" k="<<k<<" amin="<<amin<<endl;
    for(int i=0; i<amin; i++) {
        win[i]=false;
        vis[i]=true;
    }

    function<bool(int)> isWin=[&](int nextK) {
        assert(nextK>=0);

//cout<<"isWin("<<nextK<<")"<<endl;
        if(vis[nextK])
            return win[nextK];

        // if at least one position is reachable which is not win, nextK is win.
        bool lwin=false;
        for(int i=0; i<n; i++) {
            if(nextK>=a[i] && !isWin(nextK-a[i])) {
                lwin=true;
                break;
            }
        }
        vis[nextK]=true;
//cout<<"win["<<nextK<<"]="<<lwin<<endl;
        return win[nextK]=lwin;
    };

    for(int i=amin; i<k; i++) 
        isWin(i);

    int ans=isWin(k);
    cout<<(ans?"First":"Second")<<endl;

/* k stones.
 * 0 to min(a[i])-1 is loosing pos.
 * So, min(a[i]) to min(a[i])-1+max(a[i]) is winning pos. 
 * So, if loosing pos is reacheable its winning pos, if not then its loosing pos...
 */


}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int R, C; cin >> R >> C&&R;) {
		vector<vector<int>> v(R, vector<int>(C));
		rep(i, 0, R) rep(j, 0, C) { cin >> v[i][j]; }
		dump(v);
		int ans = 0;
		for (int mask = 0; mask < (1 << R); mask++) {
			vector<int> cnt(C);
			rep(i, 0, R) {
				if ((mask >> i) & 1) {
					rep(j, 0, C) {
						cnt[j] += v[i][j];
					}
				}
				else {
					rep(j, 0, C) {
						cnt[j] += !v[i][j];
					}
				}
			}
			int tmp = 0;
			rep(i, 0, C) {
				tmp += max(cnt[i], R - cnt[i]);
			}
			chmax(ans, tmp);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3344
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		String[] list = s.split("");
      	int[] a = new int[s.length()];
		for(int i=0; i<a.length; ++i){
			a[i] = Integer.parseInt(list[i]);
		}
      	if(a[0]+a[1]+a[2]+a[3]==7){
          System.out.println(a[0]+"+"+a[1]+"+"+a[2]+"+"+a[3]+"=7");
        }else if(a[0]+a[1]+a[2]-a[3]==7){
          System.out.println(a[0]+"+"+a[1]+"+"+a[2]+"-"+a[3]+"=7");
        }else if(a[0]+a[1]-a[2]+a[3]==7){
          System.out.println(a[0]+"+"+a[1]+"-"+a[2]+"+"+a[3]+"=7");
        }else if(a[0]-a[1]+a[2]+a[3]==7){
          System.out.println(a[0]+"-"+a[1]+"+"+a[2]+"+"+a[3]+"=7");
        }else if(a[0]-a[1]-a[2]+a[3]==7){
          System.out.println(a[0]+"-"+a[1]+"-"+a[2]+"+"+a[3]+"=7");
        }else if(a[0]-a[1]+a[2]-a[3]==7){
          System.out.println(a[0]+"-"+a[1]+"+"+a[2]+"-"+a[3]+"=7");
        }else if(a[0]+a[1]-a[2]-a[3]==7){
          System.out.println(a[0]+"+"+a[1]+"-"+a[2]+"-"+a[3]+"=7");
        }else{
          System.out.println(a[0]+"-"+a[1]+"-"+a[2]+"-"+a[3]+"=7");
        }
	}
}

Measured memory_bytes: 39448
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

const int dx8[] = { -1,-1, 0, 1,1,1, 0,-1 }; const int dy8[] = { 0,1,1, 1, 0, -1,-1,-1 };
struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	map<pii, int> rab;
	REP(i, n) {
		int a, b, w;
		cin >> a >> b >> w;
		rab[{a, b}] = w;
	}
	int ans = 0;
	for (auto it = rab.begin();it != rab.end();it++) {
		int ma = 0;
		REP(j,4) {
			int sum=0;
			sum += it->second;
			REP(k,3)
			if (rab.find({ it->first.first + dx8[(j * 2 + k) % 8],it->first.second + dy8[(j * 2 + k) % 8] }) != rab.end()) {
				sum += rab[{ it->first.first + dx8[(j * 2 + k) % 8], it->first.second + dy8[(j * 2 + k) % 8] }];
			}

			ma = max(sum,ma);
		}
		ans = max(ans, ma);
	}
	cout << ans << " / 1" << endl;
}

Measured memory_bytes: 9336
O = list(input())
E = list(input())

res = []

if len(O) - len(E) == 0:
    for i, j in zip(O, E):
        res.append(i)
        res.append(j)
else:
    E.append('')
    for i, j in zip(O, E):
        res.append(i)
        res.append(j)
    res.pop(-1)
 
pw = ''.join(res)
print(pw)

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

void solve(){

 int n;
 cin >> n;
 vector<int> p(n);
 rep(i, n) cin >> p[i];
 int k = 0;
 rep(i, n) if(p[i] != i + 1) k++;
 if(k <= 2) cout << "YES" << endl;
 else cout << "NO" << endl;
 


}


int main(){
   solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <array>
#include <valarray>

using namespace std;

int main()
{
    int result = 0;
    int S_count = 0;
    char c;
    while ((c = getchar()) == 'S' || c == 'T'){
        if (c == 'S'){
            ++result;
            ++S_count;
        }else{
            if (S_count > 0){
                --result;
                --S_count;
            }else{
                ++result;
            }
        }
    }
    printf("%d\n", result);
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    string s;cin>>s;
    int cnt=0,ans=0;
    for(auto x:s){
        if(x=='R')cnt++;
        else ans=max(cnt,ans),cnt=0;
    }
    if(cnt)ans=max(cnt,ans);
    cout<<ans<<endl;
    return 0;
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ms memset
//#define MAXN 10005
//#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N, K;
int H[100005];
int memo[100005];

int solve(int x){

	if(x == N - 1) return 0;

	if(x >= N) return INF;

	int &state = memo[x];
	if(state != -1) return state;

	int minimo = INF;
	for(int i = 1; i <= K; i++){
		minimo = min( abs( H[x] - H[x+i] ) + solve(x+i), minimo );
	}

	return state = minimo;

}


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

	cin >> N >> K;
	for(int i = 0; i < N; i++){
		cin >> H[i];
	}

	ms(memo, -1, sizeof memo);

	cout << solve(0) << "\n";

	return 0;	
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
int x,y;
cin >> x >>y;
ll ans = 0;
 if(x==1&&y==1)ans+=400000;
 if(x==1) ans+=300000;
 if(x==2) ans+=200000;
 if(x==3) ans+=100000;
 if(y==1) ans+=300000;
 if(y==2) ans+=200000;
 if(y==3) ans+=100000;
 cout << ans << endl;
 }

Measured memory_bytes: 256
# 10^n - 2*9^n + 8^n
MODC = 1000000007
n = gets.strip.to_i
ans = 10.pow(n,MODC)
ans += (MODC - 9.pow(n,MODC))*2
ans += 8.pow(n,MODC)
ans %= MODC
p ans


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

// Combination Table 
ll C[51][51]; // C[n][k] -> nCk 

void comb_table (int N)
{ 
    for (int i = 0 ;i <= N; i++)
    { 
        for (int j = 0 ;j <= i; j++)
        { 
            if (j == 0 or j == i)
            {
                C[i][j] = 1LL; 
            }
            else
            { 
                C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]); 
            } 
        } 
    } 
}

int main()
{
    int n,a,b;
    ll ans=0;
    double ave=0;
    cin>>n>>a>>b;
    vector<ll> v(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>v[i];
    }
    sort(all(v));
    reverse(all(v));
    comb_table(n);
    
    for(int i = 0; i < a; i++)
    {
        ave+=v[i];
    }
    ave/=a;
    int mincnt=0;
    int maxcnt=0;
        
    for(int i = 0; i < n; i++)
    {
        if(v[i]==v[a-1]) 
        {
            maxcnt++;
            if(i<a) mincnt++;
        }
    }
    

    if(v[0]==v[a-1])
    {
        for(int i = mincnt; i <= min(b,maxcnt); i++)
        {
            ans+=C[maxcnt][i];
        }
    }
    else
    {
        ans+=C[maxcnt][mincnt];
    }
    

    cout<<fixed;
    cout<<ave<<endl;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] lrd = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var l = lrd[0];
        var r = lrd[1];
        var d = lrd[2];
        var ans = 0;
        for (int i = l; i <= r; i++)
        {
            if (i % d == 0) ans++;
        }


        // 出力
        Console.WriteLine(ans);
    }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            sb.delete(0,sb.length());
            String line = br.readLine();
            sb.append(line);
            if (line.equals("-")) break;
            int m = Integer.parseInt(br.readLine());
            for (int i=0; i<m; i++){
                int hi = Integer.parseInt(br.readLine());
                sb.append(sb.substring(0,hi));
                sb.delete(0,hi);
            }
            System.out.println(sb.toString());
        }
    }
}

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

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

	vector<int> p(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
	}

	int min = p[0];
	int ans = 1;
	for (int i = 1; i < n; ++i)
	{
		if (min >= p[i])
		{
			min = p[i];
			++ans;
		}
	}

	cout << ans;
}


Measured memory_bytes: 1024
n = int(input())
l = []
dic = {}


for i in range(n):
    a = int(input())
    l.append(a)
    if(dic.get(a) is None):
        dic[a] = 1
    else:
        dic[a] += 1

mi = max(dic)
if(dic[mi]>=2):
    for i in range(n):
        print(mi)
else:
    del(dic[mi])
    mi2 = max(dic)
    for i in range(n):
        if(l[i]==mi):
            print(mi2)
        else:
            print(mi)

        

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

int main()
{
    int n, m, l;
    long t;
    vector<vector<long> > a, b;

    cin >> n >> m >> l;

    for (int j = 0; j < n; ++j) {
        a.push_back(vector<long>());
        for (int i = 0; i < m; ++i) {
            cin >> t;
            a[j].push_back(t);
        }
    }

    for (int j = 0; j < m; ++j) {
        b.push_back(vector<long>());
        for (int i = 0; i < l; ++i) {
            cin >> t;
            b[j].push_back(t);
        }
    }

    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < l; ++i) {
            t = 0;
            for (int k = 0; k < m; ++k) {
                t += a[j][k] * b[k][i];
            }
            cout << t;
            if (i < l - 1) {
                cout << " ";
            }
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 1416
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using T = std::pair<int, std::pair<int, int>>;

int main() {
  const int N = 100000;
  int w, h, nums;
  int p[N], q[N];
  long long ans = 0;
  int ux = 0;
  int uy = 0;
  std::priority_queue<T, std::vector<T>, std::greater<T>> heap;
  std::cin >> w >> h;
  for (int i = 0; i < w; ++i) {
    std::cin >> p[i];
    heap.push(T(p[i], {0, i}));
  }
  for (int i = 0; i < h; ++i) {
    std::cin >> q[i];
    heap.push(T(q[i], {1, i}));
  }
  while (not heap.empty()) {
    long long cost = heap.top().first;
    int kind = heap.top().second.first;
    //int id = heap.top().second.second;
    heap.pop();
    if (kind == 0) {
      nums = h + 1 - uy;
      ++ux;
    } else {
      nums = w + 1 - ux;
      ++uy;
    }
    ans += nums * cost;
  }
  std::cout << ans << std::endl;
  return 0;
}

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

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

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i == p[i - 1]) {
      if (i + 1 == p[i]) i++;
      ans++;
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int N, K;
    cin >> N >> K;

    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);

    for (int i = K; i < N; i++) {
        if (A.at(i - K) < A.at(i)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 4844
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

struct Point {
	int x, y;
};

struct Node {
	int a, b;
	double d;
};

Point piles[10001];

int N, M;

int s[10001];

double distanc(int i, int j)
{
	int dx = piles[i].x - piles[j].x;
	int dy = piles[i].y - piles[j].y;
	return sqrt(dx*dx+dy*dy);
}

bool compare_node(const Node &n1, const Node &n2)
{
	if (n1.d != n2.d)
		return n1.d < n2.d;
	if (n1.a != n2.a)
		return n1.a < n2.a;
	return n1.b < n2.b;
}

int find_root(int i)
{
	if (s[i]!=i)
		s[i] = find_root(s[i]);
	return s[i];
}

bool same_set(int i, int j)
{
	return find_root(i)==find_root(j);
}

void union_set(int i, int j)
{
	int root1 = find_root(i);
	int root2 = find_root(j);
	s[root1] = root2;
}


int main()
{
	//freopen("in.txt", "r", stdin);

	while (scanf("%d%d", &N, &M)==2) {
		int i, j;

		for (i=1; i<=N; i++) {
			scanf("%d%d", &piles[i].x, &piles[i].y);
		}

		vector<Node> v;
		Node node;

		for (i=0; i<M; i++) {
			scanf("%d%d", &node.a, &node.b);
			node.d = distanc(node.a, node.b);
			v.push_back(node);
		}
		sort(v.begin(), v.end(), compare_node);

		vector<int> remove_v;
		for (i=1; i<=N; i++)
			s[i] = i;
		for (i=M-1; i>=0; i--) {
			if (!same_set(v[i].a, v[i].b)) {
				union_set(v[i].a, v[i].b);
				remove_v.push_back(i);
			}
		}

		double sum = 0.0;
		j = remove_v.size()-1;
		for (i=0; i<M; i++) {
			if (j>=0 && i==remove_v[j]) {
				j--; continue;
			}
			sum += v[i].d;
		}
		printf("%.3lf\n", sum);
	}


	return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " "
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pw(x) (1ll << (x))
#define endl '\n'
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int N = 3030, P = 998244353;

int n, s, a[N], f[N][N];
void upd(int &a, int b) {
	if((a += b) >= P) a -= P;
}
int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	cin >> n >> s;
	rep(i, 1, n + 1) cin >> a[i];
	f[0][0] = 1;
	rep(i, 1, n + 1) rep(j, 0, s + 1) if(f[i - 1][j]) {
		if(j + a[i] <= s) upd(f[i][j + a[i]], f[i - 1][j]);
		upd(f[i][j], f[i - 1][j] * 2ll % P);
	}
	cout << f[n][s] << endl;
	return 0;
}


Measured memory_bytes: 39160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, A, x, y, max, ans = 0, tmp = 0;
  bool contra = true;
  cin >> N;
  max = pow(2, N);
  vector<int> bit(N, 0);
  vector<vpli> stats(N);
  vll num(N);

  for (int i = 0; i < N; i++) {
    cin >> A;
    num.at(i) = A;
    vpli stat(A);
    for (int j = 0; j < A; j++) {
      cin >> x >> y;
      stat.at(j) = make_pair(x, y);
    }
    stats.at(i) = stat;
  }

  for (int i = 1; i < max; i++) {
    bit.at(0)++;
    for (int j = 0; j < N; j++) {
      if (bit.at(j) == 2) {
        bit.at(j) = 0;
        bit.at(j+1)++;
      }
      else if (bit.at(j) == 1) {
        tmp++;
      }
    }

    for (int k = 0; k < N; k++) {
      if (bit.at(k) == 1) {
        for (int l = 0; l < num.at(k); l++) {
          if (bit.at(stats.at(k).at(l).first - 1) != stats.at(k).at(l).second) {
            contra = false;
            break;
          }
        }
      }
      if (!contra) break;
    }

    if (contra) {
      if (ans < tmp) ans = tmp;
    }
    
    contra = true;
    tmp = 0;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        int N = in.nextInt();
        int K = in.nextInt();

        int sum =0;

        int [] p =new int[N];

        for (int i = 0; i < N; i++) {
            p[i] = in.nextInt();
        }
        Arrays.sort(p);
        for (int i = 0; i < K; i++) {
            sum +=p[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 30380
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int res = 0;
        for (int i = 0; i < n; i++)
        {
            var a = int.Parse(Console.ReadLine());
            for (int j = 2; j * j <= a; j++)
                if (a % j == 0) goto end;
            res++;
            end:;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 17908
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long A,B,t=0,i,j,a;
  int long long ans=0;
  
  cin >> A >> B;
 
  t=__gcd(A,B);
  
  a=t;
  vector<int> v;
 
  for ( i = 2; i <= sqrt(t); i++)
  {
    if (a%i!=0)
    {
      continue;
    }
    v.push_back(i);
    while (a%i==0)
    {
      a/=i;
    }
  }

  if (a!=1)
  {
    v.push_back(a);
  }
  
  
  ans=v.size();
 
  printf("%lld\n",ans+1);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
using namespace std;
int main (int argc, char *argv[]) {
	int H,W;
	while (true) {
		cin >> H >> W;
		cin.ignore();
		if (H == 0 && W == 0) break;
		vector<string> map(H);
   	for (int i=0;i<H;i++) {getline(cin,map[i]);}
		vector<vector<bool> > flags(H,vector<bool>(W,false));
		queue<pair<int,int> > que;
		que.push(make_pair(0,0));
		while (!que.empty()) {
			pair<int,int> p = que.front(); que.pop();
			int x = p.first, y = p.second;
			if (flags[y][x]) {
				cout << "LOOP" << endl;
				break;
			}
			flags[y][x] = true;
			char d = map[y][x];
			if (d == '>') que.push(make_pair(x+1,y));
			else if (d == '<') que.push(make_pair(x-1,y));
			else if (d == '^') que.push(make_pair(x,y-1));
			else if (d == 'v') que.push(make_pair(x,y+1));
			else if (d == '.') {
				cout << x << " " << y << endl;
				break;
			}
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int n,m,a,b,d[N];
vector<int> v[N];
int main(){
    scanf("%d%d",&n,&m);
    while(m--){
	scanf("%d%d",&a,&b);
	v[a].push_back(b);
    }
    for(int i=0;i<=n;i++)d[i]=0;
    for(int i=0;i<=n;i++){
	for(auto x:v[i])d[x]=max(d[x],d[i]+1);
	d[i+1]=max(d[i+1],d[i]);
    }
    printf("%d",d[n]);
    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

struct rmqsegtree{
  vector< pair<int, int> > t; //<data, at>
  pair<int, int> re;
  int n;
  void dflt(void){ re.first = INT_MAX; re.second = -1; return; }
  void use(void){
    int i; dflt();
    for(i = 0;;++i)if((1 << i) >= n)break;
    ++i; t.resize(1 << i); t[0].first = 1 << (i - 1); t[0].second = 1 << i;
    for(i = 1;i < t[0].second;++i)t[i] = re;
    for(i = 0;i < n;++i)t[i + t[0].first].second = i;
    return;
  }
  void build(vector<int> a){
    for(n = 1;;n <<= 1)if(n >= a.size())break;
    t.resize(n << 1); dflt();
    t[0].first = n; t[0].second = t[0].first << 1; n = a.size();
    for(int i = 1;i < t[0].second;++i)t[i] = re;
    for(int i = 0;i < n;++i){
      t[t[0].first + i].first = a[i]; t[t[0].first + i].second = i;
    }
    for(int i = t[0].first - 1;i >= 1;--i)
      t[i] = (t[i << 1] <= t[(i << 1) + 1]) ? t[i << 1] : t[(i << 1) + 1];
    return;
  }
  void update(int at, int data){
    t[t[0].first + at].first = data;
    for(int x = t[0].first + at;x > 1;){
      x >>= 1;
      if(t[x << 1].first < t[(x << 1) + 1].first)t[x] = t[x << 1];
      else t[x] = t[(x << 1) + 1];
    }
    return;
  }
  pair<int, int> query(int l, int r, int k, int kl, int kr){
    //printf("%d %d %d %d %d\n", l, r, k, kl, kr);
    if(l <= t[k].second && t[k].second < r)return t[k];
    if(k >= t.size())return re;
    if(kl >= r || kr <= l)return re;
    if(l <= kl && kr <= r)return t[k];
    pair<int, int> a = query(l, r, k << 1, kl, (kl + kr) >> 1);
    pair<int, int> b = query(l, r, k * 2 + 1, (kl + kr) >> 1, kr);
    return (a.first < b.first) ? a : b;
  }
  pair<int, int> find(int l, int r){ return query(l, r, 1, 0, t[0].first); }
  void deb(void){
    int x = 1;
    printf("t[0] = (%d, %d)\n", t[0].first, t[0].second);
    for(int i = 1;i < t[0].second;++i){
      printf("%11d", t[i].first);
      if(i == (1 << x) - 1){ puts(""); ++x; }
    }
    return;
  }
};

typedef long long ll;

vector<int> aa;
int where[200001] = {0};
int n;
rmqsegtree R;

ll solve(int mi, int l, int r){
  if(r - l == 1)return mi;
  if(r - l == 2)return aa[l] + aa[l + 1] + min(aa[l], aa[l + 1]);
  int qwe = min(where[mi] - l + 1, r - where[mi]), rty = max(where[mi] - l + 1, r - where[mi]);
  ll res = (ll)qwe * (ll)(qwe + 1);
  res += (ll)(1 + r - l - rty - 1) * (ll)(1 + r - l - rty);
  res >>= 1;
  res += (ll)qwe * (ll)(rty - qwe);
  res *= (ll)mi;
  bool isl = (where[mi] - l > 0), isr = (r - where[mi] > 1);
  if(isl)res += solve(R.find(l, where[mi]).first, l, where[mi]);
  if(isr)res += solve(R.find(where[mi] + 1, r).first, where[mi] + 1, r);
  return res;
}

signed main(void){
  scanf("%d", &n);
  aa.resize(n);
  for(int i = 0;i < n;++i){
    scanf("%d", &aa[i]);
    where[aa[i]] = i;
  }
  R.build(aa);

  printf("%lld\n", solve(1, 0, n));

  return 0;
}


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

int main(){
	long long N; cin >> N;

	long long cnt = 0;
	vector<long long> ret;
	for(long long i = 1; i*i <= N; ++i){
		if(N%i == 0){
			ret.push_back(i);
			if(i*i != N) ret.push_back(N/i);
		}
	}

	for(long long i = 0; i < ret.size(); ++i){
		long long ans = ret[i]-1;
		if(ans == 0) continue;
		if(N/ans == N%ans) cnt += ans;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pii pair<int, int> 
#define pll pair<long , long>
#define all(a) a.begin(), a.end()
#define int long long
#define ll long long
#define mod 998244353
//#define int long long
#define loop(i,a,b) for(int i=a;i<b;i++)
#define bloop(i,a,b) for(int i=a;i>=b;i--)

int max(int a, int b) { return (a > b)? a : b; } 
bool cmp(char ch,char c)
{
    return ch>c;
}
// bool sortinrev( vector<pair<int,string>> &a,  vector< pair<int,string>> &b) 
// { 
//        return (a.first > b.first); 
// } 
using namespace std;

int32_t main()
{
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
     //cin>>t;
    while(t--)
        {
           int n,c=-1;
           cin>>n;
           //vector<char > vect;
           string x;
           vector<pair<int,string>> name;
           unordered_map<string,int > umap;
           for(int i=0;i<n;i++)
           {
               cin>>x;
               umap[x]++;
               c=max(umap[x],c);
           }
          // cout<<c<<endl;
           vector<string> vect;
          for(auto x: umap)
          {
              if(x.second ==c)
              {
                  vect.pb(x.first);
              }
          }
      sort(vect.begin(),vect.end());
      for(int i=0;i<vect.size();i++)
        cout<<vect[i]<<endl;
        }
    return 0;
}



Measured memory_bytes: 25284
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

bool ok(){
	string s;
	cin>>s;
	string t(s);
	reverse(t.begin(),t.end());
	if(t!=s) return false;
	int k=s.size()/2;
	return (s.substr(0,k)==s.substr(k+1,k));
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout<<(ok()?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}
//a,m=MOD MOD逆元
long double n;
long double dp[301][301][301];
long double cal(int i,int j,int k){
    if(dp[i][j][k]!=-1)
        return dp[i][j][k];
    if(i==0&&j==0&&k==0)
        return 0.0;
    long double res = n;
    if(i>=1)
        res += cal(i - 1, j, k) * i;
    if(j>=1)
        res += cal(i + 1, j - 1, k) * j;
    if(k>=1)
        res += cal(i, j + 1, k - 1) * k;
    res /= (i + j + k);
    return dp[i][j][k] = res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,w;
    cin>>n>>w;
    V val(n);
    V wei(n);
    rep(i,n)cin>>wei[i]>>val[i];
    vector<vector<long long>> dp(n+1,vector<long long>(w+1,0));
    for(int i=1;i<n+1;i++){
        for(int j=0;j<w+1;j++){
            dp[i][j]=dp[i-1][j];
            if(j-wei[i-1]>=0){
                dp[i][j] = max(dp[i][j],dp[i-1][j-wei[i-1]]+val[i-1]);
            }
        }
    }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}



Measured memory_bytes: 3636
#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(){
	long long int ans = 0;
	int n;
	cin >> n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				ans += __gcd(__gcd(i,j),k);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
 string s;
  cin >> s;
  
  int cnt = 0;
  for (int i = 0;i < s.length()/2; i++)
  {
   if (s[i] != s[s.length() - 1 -i]) 
     cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
P = [int(i) - 1 for i in input().split()]

a = [0] * N
b = [0] * N
rank = 1
for p in P:
    a[p] = rank
    b[p] = rank
    rank += 1

b.reverse()

for i in range(1,N):
    a[i] += a[i-1]
    b[i] += b[i-1]

b.reverse()

print(*a)
print(*b)

Measured memory_bytes: 6304