akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n;
	cin>>n;
	vector<ll> a(n),b(n),c(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	for(ll i=0;i<n;i++)
		cin>>b[i];
	for(ll i=0;i<n;i++)
		cin>>c[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	
	ll ans=0;
	for(ll i=0;i<n;i++)
	{
		vector<ll>::iterator lower,upper;
    	lower = lower_bound (a.begin(), a.end(),b[i]);  
    	upper = upper_bound (c.begin(), c.end(),b[i]);
		ans+=(lower-a.begin())*(n-(upper-c.begin()));
	
	}
	cout<<ans;

    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 5584
n=int(input())
lst=list(map(int,input().split()))

for i in range(n):
    a=lst[i]
    j=i-1
    while j>=0 and lst[j]>a:
        lst[j+1]=lst[j]
        j-=1
    lst[j+1]=a
    print(" ".join(map(str,lst)))




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


int main() {
  int n; cin >> n;
  if(n==1){ cout << "Hello World" << endl; }
  else {
    int a, b; cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;  
}

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

num = [0 for _ in range(N+1)]
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            num[j] += 1
            cur //= j


def Count(m):
    return len(list(filter(lambda x: x >= m - 1, num)))


ans = Count(75) + (Count(3)-1)*Count(25) + Count(15) * (Count(5)-1)\
      + Count(5)*(Count(5)-1)*(Count(3)-2)//2
print(ans)


Measured memory_bytes: 38512
#include <iostream>
#include <cmath>

using namespace std;

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

	long long M = (long long)sqrt(S);
	while (M * M < S) {
		++M;
	}
	cout << M << " 0 " << M - 1 << " " << M << " 0 " << M * M - S << endl;
}


Measured memory_bytes: 256
A = []
for i in range(3):
  A.append(list(map(int, input().split())))
B = [[0 for i in range(3)] for j in range(3)]
N = int(input())
for i in range(N):
  b = int(input())
  for j in range(3):
    for k in range(3):
      if A[j][k] == b:
        B[j][k] = 1
c = []
for i in range(3):
  c.append(B[i][0] & B[i][1] & B[i][2])
  c.append(B[0][i] & B[1][i] & B[2][i])
c.append(B[0][0] & B[1][1] & B[2][2])
c.append(B[0][2] & B[1][1] & B[2][0])
if sum(c) > 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 62044
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

struct Card
{
    char suit, number;
    void showMe();
};

void Card::showMe()
{
    cout << suit << number;
}

void showCards(Card *a, size_t size)
{
    for (size_t i = 0; i < size; ++i)
    {
        cout << (i == 0 ? "" : " ");

        a[i].showMe();
    }
    cout << endl;
}

void doBubbleSort(Card *a, size_t size)
{
    bool flag = true;
    for (size_t i = 0; flag; ++i)
    {
        flag = false;
        for (size_t j = size - 1; j > i; --j)
        {
            if (a[j].number < a[j - 1].number)
            {
                swap(a[j], a[j - 1]);
                flag = true;
            }
        }
    }
}

void doSelectionSort(Card *a, size_t size)
{
    for (size_t i = 0; i < size; ++i)
    {
        size_t minj = i;
        for (size_t j = i; j < size; ++j)
        {
            if (a[j].number < a[minj].number)
            {
                minj = j;
            }
        }
        if (i != minj)
        {
            swap(a[i], a[minj]);
        }
    }
}

bool compareCards(Card *a, Card *b, size_t sizeA)
{
    bool result = true;
    for (size_t i = 0; i < sizeA; ++i)
    {
        result *= (a[i].suit == b[i].suit);
    }
    return result;
}

int main()
{
    size_t size;
    string str;
    Card a[36], b[36];
    cin >> size;
    for (size_t i = 0; i < size; ++i)
    {
        cin >> str;
        a[i].suit = str[0];
        a[i].number = str[1];
        b[i] = a[i];
    }
    doBubbleSort(a, size);
    doSelectionSort(b, size);
    showCards(a, size);
    cout << "Stable" << endl;
    
    showCards(b, size);
    
    if (compareCards(a, b, size))
    {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }
}


Measured memory_bytes: 3128
#include<stdio.h>
#include<ctype.h>

void push(int);
int pop();

int top = 0; 
int S[101];

int main(){

  char A[100];
  int i, j;

  while(scanf("%s",A) != EOF){
    //printf("%d %d\n",top,A[top]);
    //fflush(stdout);
    if(isdigit(A[0])){
      push(atoi(A));
    }
    else{
      
      i = pop();
      j = pop(); 
 
      if(A[0] == '+')
	push( i + j);
      else if(A[0] =='-')
	push( j - i);
      else if (A[0] == '*')
	push (i * j);
      }
  }

  printf("%d\n",pop()  );

  return 0;
}

int pop(){
  return S[--top + 1];
}

void push(int x){
  //printf("%d %d\n",top,S[top]);
  // fflush( stdout );
  S[++top] = x;
}

Measured memory_bytes: 548
/**
 *    author:  tourist
 *    created: 03.02.2018 17:19:21       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  if (x % y == 0) { 
    cout << -1 << endl;
  } else {
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long li;
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  // ここでストリームに obj を書き込みます。
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

void add_prime(map<int,int>& mp,int a){
  map<int,int> factor;
  int i=2;
  if(df)print(a);
  while(i*i<=a){
    while(a%i==0){
      factor[i]++;
      a/=i;
    }
    i++;
  }
  if(a>1) factor[a]++;
  if(df)print(factor);
  for(pair<int,int> x:factor){
    chmax(mp[x.first],x.second);
  }
}

li inv(int a){
  if(a==1)return 1;
  return ((MOD-MOD/a)*inv(MOD%a))%MOD;
}

li lcm(map<int,int>& mp){
  li ret=1;
  for(pair<int,int> x:mp){
    rep(i,x.second){
      (ret*=x.first)%=MOD;
    }
  }
  return ret;
}

int main(){
  int n; cin >>n;
  map<int,int> mp;
  li ans=0;
  rep(i,n){
    int a; cin >>a;
    add_prime(mp,a);
    (ans+=inv(a))%=MOD;
  }
  if(df)print(mp);
  
  (ans*=lcm(mp))%=MOD;
  
  print(ans);
}


Measured memory_bytes: 768
import java.util.*;
import java.util.regex.Matcher;

/**
 * Created by Seiya on 2016/10/16.
 */

public class Main {

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

        long N = scanner.nextLong();

        ArrayList<Long> list = new ArrayList<Long>();
        long i = 1;
        double last = Math.sqrt(N);
        while(true){
            if(N % i == 0){
                list.add(N / i);
            }
            if(i > last)break;
            i++;
        }

        long ans = 99999999;
        for (int j = 0; j < list.size(); j++) {
            int temp = Math.max(log10(list.get(j)), log10(N / list.get(j)));
            ans = Math.min(ans, temp);
        }
        System.out.println(ans);


    } // mainMethod

    public static int log10(long n){
        int ans = 0;
        while(n > 0){
            n /= 10;
            ans++;
        }

        return ans;
    }


} // MainClass


Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0LL, a + b - n) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  cin >> s;
  int c=0, d=0;
  rep(i,0,s.size()){
    if(s.at(i)=='C') c++;
    if(s.at(i)=='F' && c>=1) d++;
  }
  if(d>=1) co("Yes");
  else co("No");
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 222222;
vector<int> graph[N];
bool vis[N];
int cnt;
int n, m;

void dfs(int u) {
    if(vis[u]) {
        return;
    }
    cnt++;
    vis[u] = true;
    rall(v, graph[u]) {
        dfs(v);
    }
}

int solve() {
    cin >> n >> m;
    rep(i, 1, m) {
        int u, v;
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    int ans = 0;
    rep(u, 1, n) {
        if(!vis[u]) {
            int p = cnt;
            dfs(u);
            ans = max(ans, cnt - p);
        }
    }
    cout << ans << endl;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 21444
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,x;
  int z=0;
  int ans=1;
  cin >> n >> x;
  for(int i=0;i<n;i++){
    int buf;
    cin >> buf;
    z+=buf;
    if(z<=x)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   string s;
   cin >>s;
   bool heisei=true;
   if(s[5]-'0'>0)heisei=false;
   else if(s[6]-'0'>4)heisei=false;
   if(heisei)puts("Heisei");
   else puts("TBD");
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> a(N, vector<int> (M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> a[i][j];
        }
    }
    vector<int> cnt(M+1);
    int m, ind;
    int ans;
    ans = inINF;
    for (int i = 0; i < M; i++) {
        fill(ALL(cnt), 0);
        for (int j = 0; j < N; j++) {
            cnt[a[j][0]]++;
        }
        m = 0;
        ind = 0;
        for (int j = 1; j <= M; j++) {
            if(cnt[j] > m){
                m = cnt[j];
                ind = j;
            }
        }
        ans = min(ans, m);

        for (int j = 0; j < N; j++) {
            a[j].erase(remove(ALL(a[j]), ind));
        }

    }
    printf("%d\n", ans);
    
}

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

#define N 200200

int n, a[N], b[N];

long long solve() {
    long long rlt = 0;
    while (1) {
        bool fg = 1;
        for (int i = 1; i <= n; i ++) {
            if (a[i] > b[i]) return -1;
            if (a[i] == b[i]) continue;
            int k = b[i>1?i-1:n] + b[i<n?i+1:1];
            if (b[i] <= k) continue;
            if (b[i] - a[i] < k) return -1;
            fg = 0;
            rlt += (b[i] - a[i]) / k;
            b[i] = (b[i] - a[i]) % k + a[i];
        }
        if (fg) break;
    }
    if (!rlt) return -1;
    return rlt;
}

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


Measured memory_bytes: 1792
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbg=2e18;
//My own input/output stream
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putsp()
#define putii(x,y) puti(x),putnum(y),putsp()
#define putiii(x,y,z) putii(x,y),putnum(z),putsp()
#define putsi(x) putnum(x),putendl()
#define putsii(x,y) puti(x),putnum(y),putendl()
#define putsiii(x,y,z) putii(x,y),putnum(z),putendl()
inline ll getnum()
{
	register ll r=0;register bool ng=0;register char c;c=getchar();
	while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	if(c=='-')ng=1,c=getchar();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=getchar();
	if(ng)r=-r;return r;
}
template <class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline void putsp(){putchar(' ');}
inline void putendl(){putchar('\n');}
inline char mygetchar(){register char c=getchar();while(c==' '||c=='\n')c=getchar();return c;}
char s[811][811];
int n,m,k;
int dis[811][811];
int q[1280011],qsz;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int main()
{
	memset(dis,-1,sizeof(dis));
	getiii(n,m,k);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i][j]=='S')
			{
				q[qsz++]=i;
				q[qsz++]=j;
				dis[i][j]=0;
			}
		}
	}
	for(int i=0;i<qsz;i+=2)
	{
		int x=q[i],y=q[i+1];
		for(int j=0;j<4;j++)
		{
			int nx=x+dx[j],ny=y+dy[j];
			if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&dis[nx][ny]==-1&&s[nx][ny]=='.')
			{
				dis[nx][ny]=dis[x][y]+1;
				q[qsz++]=nx;
				q[qsz++]=ny;
			}
		}
	}
	int ans=23333333;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
//			cout<<dis[i][j]<<" ";
			if(dis[i][j]!=-1&&dis[i][j]<=k)
			{
				int dis=min(min(i-1,n-i),min(j-1,m-j));
				if(dis==0)ans=1;
				else ans=min(ans,(dis-1)/k+2);
			}
		}
//		cout<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int n, w;
  ll INF = 100100100100100;
  cin >> n >> w;
  vi weight(n+1), value(n+1);
  rep(i,n) cin >> weight[i+1] >> value[i+1];
  vector<vector<ll>> dp(n+1, vector<ll>(100001, INF));
  dp[0][0] = 0;
  for(int i=1; i<=n; i++){
    for(int v=0; v<=100000; v++){
      if(v-value[i]>=0) dp[i][v] = min(dp[i-1][v], dp[i-1][v-value[i]] + weight[i]);
      else dp[i][v] = dp[i-1][v];
    }
  }
  ll ans = 100000;
  while(dp[n][ans] > w) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 83232
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

struct Node {
    int key;
    Node *prev, *next;
};

Node *nil;

void init() {
    nil = (Node*)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key) {
    Node *x = (Node*)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void printlist() {
    Node *cur = nil->next;
    int isf = 0;
    while (true) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

int main() {
    int n, key;
    char command[20];
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; ++i) {
        scanf("%s%d", command, &key);
        if (command[0] == 'i') {
            insert(key);
        } else if (command[0] == 'd') {
            if (strlen(command) > 6) {
                if (command[6] == 'F') {
                    deleteFirst();
                } else if (command[6] == 'L') {
                    deleteLast();
                }
            } else {
                deleteKey(key);
            }
        }
    }

    printlist();

    return 0;
}




Measured memory_bytes: 33820
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
char s1[10001];
int main()
{ 
    scanf("%s",s1);cout<<s1[0];
    scanf("%s",s1);cout<<s1[0];
    scanf("%s",s1);cout<<s1[0];
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 1e3 + 7;
const int maxm = 1e5 + 7;
const int mod = 1e9 + 7;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
map<ll,int>num;
int main()
{
    IO;
    ll n;
    cin>>n;
    for (ll i=2;i*i<=n;++i)
    {
        if (n%i==0)
        {
            while (n%i==0)
            {
                num[i]++;
                n/=i;
            }
        }
    }
    if (n!=1)
    num[n]++;
    int ans=0;
    for (auto it:num)
    {
        int cnt=1;
        while (cnt*(cnt+1)/2<=it.second)
        cnt++;
        cnt--;
        ans+=cnt;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3648
/*
	AOJ_0112: A Milk Shop
*/
#include	<iostream>
#include	<vector>
#include	<algorithm>

using namespace std;

int main(void) {
	int n, buf;
	long long int sum;
	while (1) {
		vector<int> order;
		sum = 0;
		
		cin >> n;
		if (n == 0) { break; }

		for (int i = 0; i < n; i++) {
			cin >> buf;
			order.push_back(buf);
		}
		sort(order.begin(), order.end());
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < i; j++) {
				sum += order[j];
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1320
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    map<string, ll> mp;
    rep(i,n) {
        string t;
        cin >> t;
        sort(t.begin(), t.end());
        ans += mp[t];
        mp[t]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 11376
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define PB push_back
#define MP make_pair
#define S second
#define F first
//#define D cout<<"*\n";
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define mod 1000000007 
#define inf 1e10;
const double pi = 3.14159265358979323846; 


signed main()
{
    fast
    int t=1;
   // cin>>t;
    
    while(t--)
    {
      
      string s,b;
      cin>>s>>b;
     
      int dp[s.size()+1][b.size()+1];
      memset(dp,0,sizeof(dp));
      int l1=s.size();
      int l2=b.size();
      for(int i=1;i<=s.size();i++)
      {
      	for(int j=1;j<=b.size();j++)
      	{
      	//	cout<<s[i-1]<<" "<<b[j]<<"\n";
      		if(s[i-1]==b[j-1])
      		{
      			dp[i][j]=dp[i-1][j-1]+1;
			  }
			  else
			  {
			  	dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			  }
		  }
	  }
	  
	  int t=dp[l1][l2];
	  int st;
	  for(int i=l2;i>=0;i--)
	  {
	  	if(dp[l1][i]==t)
	  	st=i;
	  }
	  /*
	  string ans=" ";
	  
	  for(int i=l1;i>0;i--)
	  {
	  	if(dp[i][st]==dp[i-1][st])
	  	continue;
	  	
	  	ans=s[i-1]+ans;
	  	st--;
	  }
	  cout<<ans;*/
	int index = dp[l1][l2]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = l1, j = l2; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (s[i-1] == b[j-1]) 
      { 
          lcs[index-1] = s[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (dp[i-1][j] > dp[i][j-1]) 
         i--; 
      else
         j--; 
   }
   for(int i=0;lcs[i]!='\0';i++)
   cout<<lcs[i]; 
    }
	return 0;
}

	

Measured memory_bytes: 70656
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF (1<<21)

typedef struct
{
  int d,color;
}G;

int n,M[N][N];
G B[N];

void SSSP();

int main()
{
  int i,j,u,k,v,c;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j] = INF;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v] = c;
    }
  }

SSSP();

  return 0;
}

void SSSP()
{
  int min,i,j,u;

  for(i=0;i<n;i++){
    B[i].d = INF;
    B[i].color = WHITE;
  }

  B[0].d = 0;
  B[0].color = GRAY;

  while(1){
    min = INF;
    u = -1;

    for(i=0;i<n;i++){
      if(min > B[i].d && B[i].color != BLACK){
        u = i;
        min = B[i].d;
      }
    }

    if(u == -1)break;
    B[u].color = BLACK;

    for(i=0;i<n;i++){
      if(B[i].color != BLACK && M[u][i] != INF){
        if(B[i].d > B[u].d + M[u][i]){
          B[i].d  = B[u].d + M[u][i];
          B[i].color = GRAY;
        }
      }
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n",i,B[i].d);
  }

}



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

class Node
{
    internal int key, id;
    public int parentid
    {
        get { return id / 2; }
    }
    public int leftid
    {
        get { return 2 * id; }
    }
    public int rightid
    {
        get { return 2 * id + 1; }
    }
    public Node(int id, int key) {
        this.id = id;
        this.key = key;
    }
}

class A
{
    public static void Main() {
        int n = int.Parse(Console.ReadLine());
        Node[] nodes = new Node[n+1];
        int[] data = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        for(int i = 0; i < n; i++) {
            nodes[i + 1] = new Node(i + 1, data[i]);
        }
        for (int i = 1; i <= n; i++) {
            StringBuilder output = new StringBuilder();
            output.Append("node " + nodes[i].id + ": key = " + nodes[i].key + ", ");
            if (nodes[i].parentid >= 1) {
                output.Append("parent key = " + nodes[nodes[i].parentid].key + ", ");
            }
            if (nodes[i].leftid <= n) {
                output.Append("left key = " + nodes[nodes[i].leftid].key + ", ");
            }
            if (nodes[i].rightid <= n) {
                output.Append("right key = " + nodes[nodes[i].rightid].key + ", ");
            }
            Console.WriteLine(output);
        }
    }
    
}


Measured memory_bytes: 9208
#include<stdio.h>
int main() {
    int s1,s2,s3;
  
    scanf("%d%d%d", &s1, &s2, &s3);
  
    if((s1==s2) && (s2==s3) || (s1!=s2) && (s2!=s3) && (s1!=s3)) {
       printf("No");
    }else {
       printf("Yes");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1732
/*input
10 10 1
1 10 9 1
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;
int n, m, q, ret = 0;
vector<vector<int>> Q;

void go(vector<int> arr, int index) {
	if(index == n) {
		for(int i=1; i<n; i++) {
			if(!arr[i] || !arr[i-1] || arr[i] < arr[i-1])
				return;
		}
		int sum = 0;
		for(int i=0; i<q; i++) {
			int a = Q[i][1] - 1, b = Q[i][2] - 1, c = Q[i][3], d = Q[i][0];
			if(arr[b] - arr[a] == c) {
				sum += d;
			}
		}
		ret = max(ret, sum);
		return;
	}
	for(int i=arr[index-1]; i<=m; i++) {
		arr[index] = i;
		go(arr, index + 1);
	}
}

void run() {
	int i, j;
	cin >> n >> m >> q;
	Q.resize(q, vector<int>(4, 0));
	for(i=0; i<q; i++)
		cin >> Q[i][1] >> Q[i][2] >> Q[i][3] >> Q[i][0];
	sort(Q.rbegin(), Q.rend());
	vector<int> a(n, 0);
	a[0] = 1;
	go(a, 1);
	cout << ret << endl;
}

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


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

struct star {
  long double p[3], v[3], r, rv;
  star() {
    p[0] = p[1] = p[2] = v[0] = v[1] = v[2] = r = rv = 0.0L;
  }
};

struct event {
  long double t;
  long long s1, s2;
  bool operator<(const event &r) const { return t < r.t; }
};

long long n;
vector<long double> res;
vector<star> stars;

void solve();
long double calc(int x, int y);
long double d(long double x) { return x * x; }

int main() {
  cout << fixed << setprecision(10);
  while(1) {
    cin >> n;
    if(n == 0) break;
    res.resize(n);
    stars.resize(n);
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < 3; ++j) cin >> stars[i].p[j];
      for(int j = 0; j < 3; ++j) cin >> stars[i].v[j];
      cin >> stars[i].r >> stars[i].rv;
    }
    solve();
    for(int i = 0; i < n; ++i) cout << res[i] << endl;
  }
  return 0;
}

void solve() {
  vector<event> v;
  vector<bool> erased(n, 0);
  for(int i = 0; i < n; ++i)
    v.push_back({stars[i].r / stars[i].rv, i, i});
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j) {
      long double etime = calc(i, j);
      if(etime > 0) v.push_back({etime, i, j});
    }
  sort(v.begin(), v.end());
  for(int i = 0; i < v.size(); ++i)
    if(!erased[v[i].s1] && !erased[v[i].s2]) {
      erased[v[i].s1] = erased[v[i].s2] = 1;
      res[v[i].s1] = res[v[i].s2] = v[i].t;
    }
}

long double calc(int x, int y) {
  star tmp;
  for(int i = 0; i < 3; ++i) {
    tmp.p[i] = stars[x].p[i] - stars[y].p[i];
    tmp.v[i] = stars[x].v[i] - stars[y].v[i];
  }
  tmp.r = stars[x].r + stars[y].r;
  tmp.rv = stars[x].rv + stars[y].rv;
  long double a, b, c, res = 1e18;
  a = d(tmp.rv);
  for(int i = 0; i < 3; ++i) a -= d(tmp.v[i]);
  b = tmp.r * tmp.rv;
  for(int i = 0; i < 3; ++i) b += tmp.p[i] * tmp.v[i];
  c = d(tmp.r);
  for(int i = 0; i < 3; ++i) c -= d(tmp.p[i]);
  if(d(b) < a * c || a == 0.0L) return -1;
  c = sqrtl(d(b) - a * c);
  if((b + c) / a > 0) res = min(res, (b + c) / a);
  if((b - c) / a > 0) res = min(res, (b - c) / a);
  if(res == 1e18) return -1;
  return res;
}


Measured memory_bytes: 4580
#include<iostream>

int main(){
	int a, b, c, x;
	std::cin >> a >> b >> c >> x;

	int cnt = 0;
	for(int i = 0; i <= a; i++){
		for(int j = 0; j <= b; j++){
			int tmp = x - 500 * i - 100 * j;
			if(tmp < 0)break;
			else if(tmp - 50 * c <= 0)cnt++;
		}
	}

	std::cout << cnt << std::endl;
}


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


int main(){
  string S;
  cin >> S;
  int min = 1000000000;
  for(int i = 0 ; i < S.length()-2; i++){
    string number = S.substr(i,3);
    int num = stoi(number);
    int y = num - 753;
    if(y < 0) y = -y;
    if(min > y){min = y;}
  }
  cout << min;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long X,Y;
    long long ans=0;

    cin >> X >> Y;

    while(Y>=X){
        X*=2;
        ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    string s;
    while(cin>>s) {
        for(int i=0; i<(int)s.length(); i++) {
            if(s[i] == '@'){
                for(int j=0; j < (s[i+1]-'0'); j++)
                    putchar(s[i+2]);
                    i += 2;
            } else {
                putchar(s[i]);
            }
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin>>N;

  bool fou=false;
  rep(i,N){
    char c; cin>>c;
    if(c=='Y') fou=true;
  }

  cout<< ( fou ? "Four" : "Three" )<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, str(input()).split()))
B = list(map(int, str(input()).split()))


monstar_count = 0
for i in range(N):
    if B[i] >= A[i]:
        monstar_count += A[i]
        B[i] = B[i] - A[i]
        if B[i] >= A[i+1]:
            monstar_count += A[i+1]
            A[i+1] = 0
        else:
            monstar_count += B[i]
            A[i+1] = A[i+1] - B[i]
    else:
        monstar_count += B[i]

print(monstar_count)


Measured memory_bytes: 18476
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<>());
    cout<<(s<t?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
k = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
print(sum(all(sum((b >> (j - 1)) & 1 for j in k[i]) % 2 == p[i] for i in range(m)) for b in range(2 ** n)))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n < 357) {
		    System.out.println(0);
		    return;
		}
		int now = 1000;
		ArrayDeque<Integer> deq = new ArrayDeque<>();
        ArrayDeque<Integer> next = new ArrayDeque<>();
        deq.add(0);
        int size = 0;
		while (deq.size() > 0) {
		    int x = deq.poll();
		    if (x > n) {
		        continue;
		    }

		    next.add(x * 10 + 3);
		    next.add(x * 10 + 5);
		    next.add(x * 10 + 7);
		    if (x > Integer.MAX_VALUE / 10 - 10) {
		        break;
		    }
		    deq.add(x * 10 + 3);
		    deq.add(x * 10 + 5);
		    deq.add(x * 10 + 7);
		}
		int count = 0;
		while (next.size() > 0) {
		    int x = next.poll();
		    if (x <= n && is753(x)) {
		        count++;
		    }
		}
		System.out.println(count);
	}
	
	static boolean is753(int x) {
	    int[] mod = new int[10];
	    while(x > 0) {
	        mod[x % 10]++;
	        x /= 10;
	    }
	    return mod[3] > 0 && mod[7] > 0 && mod[5] > 0;
	}
}


Measured memory_bytes: 25940
#include<bits/stdc++.h>
using namespace std;
int solve(int a[],int dp[],int n,int k1){
  dp[0]=0;
  for(int i=1;i<n;i++){
     int ans=INT_MAX;
    for(int k=1;k<=k1;k++){
     if(i-k>=0)
    ans=min(ans,abs(a[i]-a[i-k])+dp[i-k]);
    }
    dp[i]=ans;
  }
  return dp[n-1];
}
int main(){
  int n,k1;
  cin>>n>>k1;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int dp[n]={0};
  cout<<solve(a,dp,n,k1);

  return 0;
}


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


int main(){   
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    for(int i=0; ; i++){
        if(s[i] != t[i]){
            s[i] = t[i];
            cnt++;
        }
        if(s == t){
            cout << cnt << endl;
            return 0;
        } 
    }
    
}


Measured memory_bytes: 3912
#include <stdio.h>

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int sumP = a+b, sumQ = a+c, sumR = b+c;
	if(sumP <= sumQ && sumP <= sumR)
		printf("%d\n", sumP);
	else
		if(sumQ <= sumR)
			printf("%d\n", sumQ);
		else
			printf("%d\n", sumR);
		



	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] array = new int[N];
		for(int i=0;i<N;i++) {
			array[i] = sc.nextInt();
		}
		Arrays.sort(array);
		int alice=0,bob=0,flag=0;
		for(int i=N-1;i>=0;i--) {
			if(flag==0) {
				alice+=array[i];
				flag=1;
			}else {
				bob+=array[i];
				flag=0;
			}
		}
		System.out.println(alice-bob);
	}
}


Measured memory_bytes: 22996
// https://beta.atcoder.jp/contests/arc081/submissions/1530796
// user : xuyuan 

#include<bits/stdc++.h>
using namespace std;
char s[2005][2005];
int n,m,a[2005],b[2005];
int main()
{
	scanf("%d%d",&n,&m);
	int ans=max(n,m);
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m-1;j++)if(i&&!(s[i-1][j+1]^s[i][j]^s[i-1][j]^s[i][j+1]))a[j]++;else a[j]=1;
		int t=0;
		for(int j=0;j<=m-1;j++)
		{
			while(t&&a[b[t-1]]>=a[j])
			{
				int x=b[--t];
				if(t==0)ans=max(ans,(j+1)*a[x]);else ans=max(ans,(j-b[t-1])*a[x]);
			}
			b[t++]=j;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define REP(i, n) for (ll i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (ll i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int main()
{
    ll N, W;
    cin >> N >> W;
    ll w[N], v[N];
    REP(i, N) cin >> w[i] >> v[i];

    ll dp[N+1][100001];
    REP(i, N+1) REP(j, 100001) dp[i][j] = INT_MAX;
    dp[0][0] = 0;

    REP(i, N) REP(j, 100001)
    {
        if (j-v[i] >= 0 && dp[i][j-v[i]] != INT_MAX)
            dp[i+1][j] = dp[i][j-v[i]] + w[i];
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
    }

    ll ret = 0;
    REP(i, 100001) if (dp[N][i] <= W) ret = max(ret, i);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
    int vertical = ty-sy, horizontal = tx-sx; 
    string ans = "";
    ans += string(vertical, 'U') + string(horizontal, 'R') + string(vertical, 'D') + string(horizontal, 'L');
    ++ vertical, ++ horizontal;
    ans += 'L' + string(vertical,'U') + string(horizontal,'R') + 'D' + 'R' + string(vertical, 'D') + string(horizontal,'L') + 'U';
    cout << ans << endl;
    return 0;
}

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

lis = [0]*(N+1)
for a in A[1:]:
    lis[a] += 1

sum_combinations = 0
for x in lis[1:]:
    if x >= 2:
        sum_combinations += x*(x-1)//2

for i in range(1,N+1):
    ans = sum_combinations
    num = lis[A[i]]
    if num >= 2:
        ans += (num-1)*(num-2)//2 - num*(num-1)//2
    
    print(ans)

Measured memory_bytes: 32128
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};



void solve(){

    ll n;
    cin>>n;

    ll arr[n+1];
    repA(i,1,n)
    cin>>arr[i];


    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);

    repA(i,3,n){
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }

    db1(dp[n]);
    
}
int main(){ 



int t=1;
//cin>>t;
while(t--){
 solve();
}
  return 0; 
}





Measured memory_bytes: 1792
#pragma comment(linker, "/stack:200000000")
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
#define y1 sfasfd 
using namespace std;
 
mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;
const int N = 4e5 + 123;
int n;
int get(int a){
	int res = 0;
	while(a != 0){
		res += a % 10;
		a /= 10;
	}
	return res;		
}
int main(){
	cin >> n;
	int ans = 1e9;
	for(int i = 1; i < n ; i++){
		ans = min(ans , get(i) + get(n - i));
	}
	cout << ans;
}

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

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

    int count = 1;
    int pos = 0;
    for (int i = 0; i < n; i++){
        int l;
        cin >> l;
        pos += l;
        if (pos <= x){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	double velocity;
	while(cin >> velocity)
	{
		double time = velocity / 9.8;
		double height = 4.9 * time * time;
		int level = 0;
		cout << (unsigned long long int)((height + 5) / 5 + 1.0) << endl;
	}
}

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

Measured memory_bytes: 0
#include<iostream>
#include <cmath>

using namespace std;
main(){
  int n,k, f;
  cin >> n>>k;
  
  for(int i = 0; i < n ;i++){
    cin >>f;
  }
  
  cout << ceil( float (n-1)/(k-1))<< endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

const int maxN = 200000 + 233;
int n;
vector<int> G[maxN];
int f[maxN];
int diam = 0;
int DFS(int u, int fa) {
	int mx = 0, sec = 0;
	for(int v : G[u]) if(v != fa) {
		int d = DFS(v, u);
		if(d > mx) sec = mx, mx = d;
		else chmax(sec, d);
	}
	chmax(diam, mx + sec + 1);
	return mx + 1;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i < n; ++i) {
		int x, y; cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	f[0] = 0; f[1] = 1; f[2] = 0;
	for(int i = 3; i <= n; ++i) f[i] = 3 - f[i - 1] - f[i - 2];
	DFS(1, -1);
	cout << (f[diam] == 0 ? "Second" : "First") << endl;
	return 0;
}


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

main(){
    int N;
    int d[100];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> d[i];    
    }

    sort(d,d + N, greater<int>());

    int mochi = 1;

    for (int i = 0;i < N - 1;i++){
        if (d[i] > d[i+1]){
            mochi++;
        }
    }

    cout << mochi << endl;
    return 0;
}


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

int main() {
    int a;
    int b;
    int c;
 
   cin >> a >> b >> c;
   
   int d = a + b;
   int e = d*c/2;
   
  

   cout << e << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli mod = 1e9+7;

lli solve(string s, string pt){
    int n = s.length();
    int m = pt.length();
    vector<lli> csum_top(n+1, 0),csum_bottom(n+1, 0),pow10(n+1, 1);
    for(int i=0; i<n; i++){
        csum_top[i+1] = (csum_top[i]*10 +s[i]-'0') %mod;
        csum_bottom[i+1] = (csum_bottom[i] +(s[n-1-i]-'0')*pow10[i]) %mod;
        pow10[i+1] = pow10[i]*10 %mod;
    }
    if(pt == "0"){
        for(lli &a: csum_top){
            a = (a-1+mod) %mod;
        }
    }
    lli res = 0;
    for(int i=0; i+m-1<n; i++){
        string sub = s.substr(i, m);
        if(sub > pt){
            res += (csum_top[i]+1)*pow10[n-i-m] %mod;
        }else if(sub < pt){
            res += csum_top[i]*pow10[n-i-m] %mod;
        }else{
            res += csum_top[i]*pow10[n-i-m] %mod;
            res += csum_bottom[n-i-m]+1;
        }
        res %= mod;
    }
    return res;
}
lli numpt(string s, string pt){
    int n = s.length();
    int m = pt.length();
    lli res = 0;
    for(int i=0; i+m-1<n; i++){
        if(s.substr(i, m) == pt) res++;
    }
    return res;
}

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << (solve(b, c) -solve(a, c) +numpt(a, c) +mod) %mod << endl;
    return 0;
}



Measured memory_bytes: 3332
#include <stdio.h>

int main(void)
{
	int i, j;
	int a[4], b[4];
	int hit, blow;
	
	while (scanf("%d", &a[0]) != EOF){
		for (i = 1; i < 4; i++) scanf("%d", &a[i]);
		for (i = 0; i < 4; i++) scanf("%d", &b[i]);
		
		hit = blow = 0;
		for (i = 0; i < 4; i++){
			for (j = 0; j < 4; j++){
				if (a[i] == b[j]){
					if (i == j){
						hit++;
					}
					else {
						blow++;
					}
				}
			}
		}
		
		printf("%d %d\n", hit, blow);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

long Max2(long a,long b){
if(a>b){
    return a;
}else{
    return b;
}
}

long Min2(long a,long b){
if(a>b){
    return b;
}else{
    return a;
}
}


string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









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


//Answer


int main() {

long A,B,C,ans=1;
cin>>A>>B;
C=GCM(A,B);

long PL=1000001;
for(long i=2;i<PL;i++){
    if(C%i==0){
        C=C/i;
        ans++;
        while(C%i==0){
            C=C/i;
        }
        
    }
}
if(C>1){
    ans++;
}
cout<<ans<<endl;

}





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

long long gcd(long long a, long long b)
{ return b == 0 ? a : gcd(b, a%b); }

int main()
{
	int T;
	cin >> T;
	while (T--) {
		long long a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a < b || d < b) cout << "No" << endl;
		else {
			if (c >= b) cout << "Yes" << endl;
			else {
				auto div_down = [](long long a, long long b) {
					return a%b == 0 ? a/b-1 : a/b;
				}; 
				long long k = div_down(a-c, b);
				if (a-k*b < b) cout << "No" << endl;
				else {
					long long x = a-(k+1)*b;
					long long g = gcd(b, d);
					long long k = div_down(b-x, g);
					if (k*g+x > c) cout << "No" << endl;
					else cout << "Yes" << endl;
				}
			}
		}
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 2e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, x, ans[maxn];

int nxt(int val)
{
	if (val == 2 * n - 1)
		return 1;
	return val + 1;
}

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

	cin >> n >> x;
	if (x == 2 * n - 1 || x == 1)
		cout << "No" << endl;
	else
	{
		cout << "Yes" << endl;
		ans[n - 1] = x;
		int now = nxt(x);
		for (int i = n; i != n - 1; i = (i + 1) % (2 * n - 1))
			ans[i] = now, now = nxt(now);
		for (int i = 0; i < 2 * n - 1; i++)
			cout << ans[i] << endl;
	}
}



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

using namespace std;

int n; 
int a[200002];
long long ans=9999999999;
long long num[2000002];

inline long long minn(long long aa,long long bb)
{
	if(aa<bb)return aa;
	return bb;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		num[i]=num[i-1]+a[i];
	}

	for(int i=1;i<=n-1;i++)
	{
		ans=minn(ans,abs(num[n]-num[i]-num[i]));
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 3840