akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1001001001;
int a[100100];
int dp[100100];

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

    fill(dp, dp+n, INF);
    for(int i=0; i<n; i++) {
        *lower_bound(dp, dp+n, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp+n, INF) - dp << endl;
    return 0;
}


Measured memory_bytes: 3876
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i=0;i<n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<int> dp1(n,0), dp2(n,0), dp3(n,0);
    dp1[0] = a[0];
    dp2[0] = b[0];
    dp3[0] = c[0];
    for (int i=1;i<n;i++){
        dp1[i] = a[i] + max(dp2[i-1],dp3[i-1]);
        dp2[i] = b[i] + max(dp1[i-1],dp3[i-1]);
        dp3[i] = c[i] + max(dp1[i-1],dp2[i-1]);
    }
    cout << max(dp1[n-1],max(dp2[n-1],dp3[n-1])) << "\n";
}


Measured memory_bytes: 5560
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	var s string
	fmt.Scan(&s)

	firstPos := -1
	lastPos := -1

	slice := strings.Split(s, "")

	// max := -1

	// for i := 0; i < len(slice)-1; i++ {
	// 	if slice[i] == "A" {
	// 		for j := i + 1; j < len(slice); j++ {
	// 			if slice[j] == "Z" {
	// 				if max < len(slice[i:j+1]) {
	// 					max = len(slice[i : j+1])
	// 				}
	// 			}
	// 		}
	// 	}
	// }

	for i := 0; i < len(slice); i++ {
		if slice[i] == "A" {
			firstPos = i
			break
		}
	}

	for j := len(slice) - 1; j >= 0; j-- {
		if slice[j] == "Z" {
			lastPos = j
			break
		}
	}

	fmt.Println(lastPos - firstPos + 1)
}


Measured memory_bytes: 5248
#define ll long long
#define ldd long double
#define mpp make_pair
#define pb push_back
#define ff first
#define ss second
#include<bits/stdc++.h>
using namespace std;
int main(){
    ll n,m,y,x,z,h,t,i,j,k=0;
    ll cnt=0,cnt1=0,sum=0,sum1=0,flag=0,flag1=0,maxi=LLONG_MIN,mini=LLONG_MAX,temp=0,ans=0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    ll a[n+1],b[n];
    for(i=0;i<=n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        cin>>b[i];
    }
    for(i=0;i<n;i++){
        sum=a[i]+a[i+1];
        if(sum<=b[i]){
            ans+=sum;
            a[i+1]=0;
        }
        else if(sum>b[i]){
            if(a[i]>=b[i]){
                ans+=b[i];
            }
            else if(a[i]<b[i]){
                ans+=b[i];
                a[i+1]-=(b[i]-a[i]);
                //a[i+1]=max(a[i+1],0);
            }
        }
    }
    cout<<ans;


return 0;
}


Measured memory_bytes: 1792
n=input()
wb = list(map(int, input().split()))
num=0
while True:
#	print(num, wb)
	wb2 = list(map(lambda x: x%2, wb))
	if any(wb2) == 0:
		num += 1
		wb = list(map(lambda x: x/2, wb))
	else:
		break
print(num)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;
    
#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int n,l;

int func(int i){
    return l + i - 1;
}

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

    int ans = 0;
    for(int i=1; i<=n; i++){
        ans += l + i - 1;
    }

    int minusAns = 999;
    // 総当たりする。
    for(int i=1; i<=n; i++){
        if(abs(func(i)) < abs(minusAns)){
            minusAns = func(i);
        }
    }

    cout << ans - minusAns << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
//const ll mod = 1000000007LL;
const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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



  cin >> n;
  cin >> s;
  if (n >= 3200) cout << s << endl;
  else cout << "red" << endl;




  return 0;
}


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

int main(){
    string s;
    int k;
    cin >> s >> k;
    vector<string> dict(5, "zzzzzz");
    for(int len = 1; len <= 5; len++){
        for(int j = 0; j+len <= s.size(); j++){
            string sub = s.substr(j, len);
            for(int i = 0; i < 5; i++){
                if(sub == dict[i])break;
                if(sub < dict[i]){
                    dict.insert(dict.begin() + i, sub);
                    dict.pop_back();
                    break;
                }
            }
        }
    }
    cout << dict[k-1] << endl;
    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

pair<int, int> a[N];
int b[N];
vector<pair<int, int>> G[N];
bool vis[N];
vector<int> ans;
int n, m;
void dfs(int u, int fa, int id) {
    vis[u] = 1;
    for (auto t : G[u]) {
        int v = t.first;
        if (vis[v]) continue;
        dfs(v, u, t.second);
    }
    if (fa == 0 && b[u] && u != n + 1) {
        puts("-1");
        exit(0);
    }
    if (fa != 0 && b[u]) {
        b[u] ^= 1;
        b[fa] ^= 1;
        ans.push_back(id);
    }
}
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &a[i].first, &a[i].second);
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        b[i] = a[i].second ^ a[i - 1].second;
    }
    for (int i = 1; i <= m; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        x = lower_bound(a + 1, a + n + 1, make_pair(x, 0)) - a;
        y = upper_bound(a + 1, a + n + 1, make_pair(y, 2)) - a;
        G[x].push_back({y, i});
        G[y].push_back({x, i});
    }
    dfs(n + 1, 0, 0);
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) dfs(i, 0, 0);
    }
    printf("%d\n", ans.size());
    sort(ans.begin(),ans.end());
    for (int i = 0; i < ans.size(); i++) {
        printf("%d%c", ans[i], " \n"[i + 1 == ans.size()]);
    }
    return 0;
}


Measured memory_bytes: 15228
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   int ans = 0;
   rep(i, 0, n) rep(j, i + 1, n) { chmax(ans, abs(a[i] - a[j])); }
   cout << ans << endl;
   return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;

    char c;

    cin >> c;

    if(c>='A' && c<='Z')
    {
        cout << 'A' << endl;
    }
    else

    {
        cout << 'a' << endl;
    }





    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
    int a, b, c, i;
    int count = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (i = a; i<=b; i++)
    {
        if (c%i == 0)
    {
        count++;
    }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
int main(){
  int H, W, sx, sy, gx, gy;
  cin >> H >> W >> sx >> sy >> gx >> gy;
  vector<vector<char>> maze(H+2,vector<char>(W+2,'#'));
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      cin >> maze[i][j];
    }
  }
  
  int INF = 1e9;
  
  vector<vector<int>> dist(H+2,vector<int>(W+2,INF));
  queue<P> Q;
  P start = {sx,sy};
  Q.push(start);
  dist[sx][sy] = 0;
  
  queue<P> Q2;
  Q2.push(start);
  
  vector<int> dx = {0,1,-1,2,-2};
  vector<int> dy = {0,1,-1,2,-2};
  
  vector<int> DX = {0,1,0,-1};
  vector<int> DY = {1,0,-1,0};
  
  while(Q.size()){
    P p = Q.front();
    Q.pop();
    for(int i=0; i<4; i++){
      int a = p.first + DX[i];
      int b = p.second + DY[i];
      if(maze[a][b] == '#'){
        continue;
      }
      if(dist[a][b] > dist[p.first][p.second]){
        dist[a][b] = dist[p.first][p.second];
        P add = {a,b};
        Q.push(add);
        Q2.push(add);
      }
    }
    if(Q.size() == 0){
      vector<P> after(0);
      while(Q2.size()){
        P q = Q2.front();
        Q2.pop();
        for(int i=0; i<5; i++){
          for(int j=0; j<5; j++){
            int x = q.first + dx[i];
            int y = q.second + dy[j];
            if(x < 0 || x >= H+2 || y < 0 || y >= W+2){
              continue;
            }
            if(maze[x][y] == '#'){
              continue;
            }
            if(abs(dx[i]) + abs(dy[j]) > 1){
              if(dist[x][y] > dist[q.first][q.second] + 1){
                dist[x][y] = dist[q.first][q.second] + 1;
                P add = {x,y};
                Q.push(add);
                after.push_back(add);
              }
            }
          }
        }
      }
      for(int i=0; i<after.size(); i++){
        Q2.push(after[i]);
      }
    }
  }
  
  if(dist[gx][gy] == INF){
    cout << -1 << endl;
    return 0;
  }
  cout << dist[gx][gy] << endl;
}

Measured memory_bytes: 8732
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	cat ans = 0;
	for(int i = 0; i < N; i++) for(int j = i+1; j < N; j++)
		if(A[i] > A[j]) ans += K;
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++)
		if(A[i] > A[j]) ans += (1LL*K*(K-1)/2) % 1000000007;
	cout << (ans % 1000000007) << "\n";
	return 0;
}

// look at my code
// my code is amazing


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

int main(){
  int64_t a,b,c;
  cin >> a >> b >> c;
  int64_t n=c-a-b;
  bool ans=(n>0&&4*a*b<n*n);
  cout << (ans?"Yes":"No") << endl;
  return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    rep(i,3) rep(j,3){char temp;cin>>temp;if(i==j)cout<<temp;}
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 10960
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			var xl = new Tuple<long, long>[n];
			for (int i = 0; i < n; i++) {
				long x = cin.Long();
				long l = cin.Long();
				xl[i] = new Tuple<long, long>(x, l); 
			}

			var lr = new Tuple<long, long>[n];
			for (int i = 0; i < n; i++) {
				long l = xl[i].Item1 - xl[i].Item2;
				long r = xl[i].Item1 + xl[i].Item2;
				lr[i] = new Tuple<long, long>(l, r);
			}

			var lr2 = lr.OrderBy(x => x.Item2).ThenBy(x => x.Item1).ToArray();
			long ans = 0;
			long rr = long.MinValue;
			for (int i = 0; i < n; i++) {
				if (lr2[i].Item1 >= rr) {
					++ans;
					rr = lr2[i].Item2;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 31168
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

class UnionFindPathCompression():
    def __init__(self, n):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.size = [1]*n
        

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.size[py] += self.size[px]
            else:
                self.parents[py] = px
                self.size[px] += self.size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1


N,M = map(int,input().split())
ufpc = UnionFindPathCompression(N)
for i in range(M):
    a,b = map(int,input().split())
    ufpc.union(a-1,b-1)

ans = 0
for i in range(N-1):
    if ufpc.find(i) != ufpc.find(i+1):
        ufpc.union(i,i+1)
        ans += 1
print(ans)

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[N+1];
	int B[N];

	for (int i = 0; i < N+1; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < N; i++)
	{
		cin >> B[i];
	}
	
	ll ans = 0;
	for (int i = N-1; i >= 0; i--)
	{
		if(B[i]>A[i+1]){
			ans += A[i+1];
			B[i] -= A[i+1];
			A[i+1] = 0;
			if(B[i]>A[i]){
				ans += A[i];
				B[i] -= A[i];
				A[i] = 0;
			}else{
				ans += B[i];
				A[i] -= B[i];
				B[i] = 0;
			}
		}else{
			ans += B[i];
			A[i+1] -= B[i];
			B[i] = 0;
		}
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 1024
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
A=sorted(LI())
B=sorted(LI())
C=sorted(LI())
ans=0
for i in range(n):
    ans+=bisect_left(A,B[i])*(n-bisect_right(C,B[i]))
    #print(bisect_left(A,B[i]))
    #print(n-bisect_right(C,B[i]))
print(ans)

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

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(string[] S)
        {
            long[] count = new long[5];
            foreach (string s in S)
            {
                switch (s[0])
                {
                case 'M': ++count[0]; break;
                case 'A': ++count[1]; break;
                case 'R': ++count[2]; break;
                case 'C': ++count[3]; break;
                case 'H': ++count[4]; break;
                }
            }
            long sum = 0;
            for (int i = 0; i < 5; ++i)
            {
                for (int j = i + 1; j < 5; ++j)
                {
                    for (int k = j + 1; k < 5; ++k)
                    {
                        sum += count[i] * count[j] * count[k];
                    }
                }
            }
            return sum;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            string[] S = new string[N];
            for (int i = 0; i < N; ++i) { S[i] = Read(); }
            Console.WriteLine(Solve(S));
        }
    }
}


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

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    cout << (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m=0,a; cin>>n;
  for(int i=2;i<=n;i++) m+=(i-1);
  int x[n],y[n];
  long double z,b=0;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  long double p,q;
  for(int i=0;i<n;i++){
    for(int ii=i+1;ii<n;ii++){
      p=x[i]-x[ii]; q=y[i]-y[ii];
      z=sqrt(p*p+q*q);
      b+=z;
    }
  }
  cout<< fixed << setprecision(8) << b*(n-1)/m<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
	int n;
	cin>>n;
	vector<long long>a;
    long long sum=0;  
    for(int i=0;i<n-1;i++) {
        long long x;
        cin>>x;
        a.push_back(x);
    }
    sum=a[0];
    for(int i=1;i<n-1;i++){
        sum+=(min(a[i],a[i-1]));
    }
    cout<<sum+a[n-2];
    return 0; 
} 


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5+1;

ll fac[MAX];  /// fac[n] = n!
ll finv[MAX]; /// (fac[n] * finv[n]) % MOD = 1
ll inv[MAX];  /// (n * inv[n]) % MOD = 1

void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR (i, 2, MAX) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}

ll nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

ll nHk (int n, int k) {
  return nCk(n-1+k, n-1);
}

vi soinsu(int n) {
  vi res;
  int k = 2;
  int count = 0;
  while (n > 1) {
    if (n%k == 0) {
      count++;
      n /= k;
    }
    else {
      if (count > 0) {
        res.push_back(count);
        count = 0;
      }
      k++;
    }
  }
  if (count > 0) res.push_back(count);
  return res;
}

int main() {

  init();

  int N, M;
  cin >> N >> M;
  vi res = soinsu(M);

  ll ans = 1;
  FORE (x, res) {
    ans *= nHk(N, x);
    ans %= MOD;
  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 4992
from sys import stdin, stdout

INF = float('inf')
n, W = map(int, stdin.readline().split())

dp = [[-INF for i in range(W + 1)] for j in range(2)]
dp[0][0] = 0
cur = 0

for i in range(n):
    w, c = map(int, stdin.readline().split())
    for j in range(W + 1):
        dp[cur ^ 1][j] = max(dp[cur ^ 1][j], dp[cur][j])
        
        if j + w <= W:
            dp[cur ^ 1][j + w] = max(dp[cur ^ 1][j + w], dp[cur][j] + c)
        
        dp[cur][j] = -INF
    
    cur ^= 1

stdout.write(str(max(dp[cur])))

Measured memory_bytes: 137040
import java.util.Scanner;

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

        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        int Z = scanner.nextInt();
        int N;

        N = X;
        X = Y;
        Y = N;

        N = X;
        X = Z;
        Z = N;

        System.out.println(X + " " + Y + " " + Z);
    }
}

Measured memory_bytes: 21076
N = int(input())
T = list(map(int,input().split()))
M = int(input())
TT = sum(T)
PT = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    P = PT[i][0]
    TTT = PT[i][1]
    print(TT-(T[P-1]-TTT))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long int a , b , cnt;
    cin >> a >> b;
    a = __gcd(a , b);
    vector<long long int> v;
    if(a % 2 == 0){
        v.push_back(2LL);
        while(a % 2 == 0){
            a /= 2;
        }
    }
    for(long long int i = 3 ; i * i <= a ; i += 2){
        if(a % i == 0){
            v.push_back(i);
            while(a % i == 0){
                a /= i;
            }
        }
    }
    if(a > 1)
        v.push_back(a);
    cnt = v.size() ;
    cnt  = cnt + 1;
    cout << cnt ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

string S, T;

int main() {
	cin >> S >> T;
	int N = S.size();
	int M = T.size();
	
	int pos = -1;
	for (int i = N - M; i >= 0; i--) {
		
		bool ok = true;
		REP(j, M) {
			if (S[i + j] == '?') continue;
			if (S[i + j] == T[j]) continue;
			ok = false;
		}
		
		if (ok) {
			pos = i;
			break;
		}
	}
	
	if (pos == -1) puts("UNRESTORABLE");
	else {
		string ans = S.substr(0, pos);
		ans += T;
		ans += S.substr(pos + M);
		
		REP(i, ans.size()) if (ans[i] == '?') ans[i] = 'a';
		cout << ans << endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.size()<=k)
        cout<<s;
    else
    {
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"...";
    }


}



Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if (a == 7 && b == 5 && c == 5) || (a == 5 && b == 7 && c == 5) || (a == 5 && b == 5 && c == 7) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(void)
{
  int a,b;
  cin >> a >> b;
  if((a*b)%2==0)
  {
    cout << "Even" << endl;
    return 0;
  }
  else
  {
    cout << "Odd" << endl;
  	return 0;
  }
}

Measured memory_bytes: 256
/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 21-Jun-2020 18:06:47
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;


int solve() {
    string res = "";
    long long n; cin >> n;
    while (n > 0) {
        --n;
        int rem = n % 26;
        res += rem + 'a';
        n /= 26;
    }

    reverse(all(res));
    cout << res << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
n = int(input())
t, a = map(int, input().split())
list_H = list(map(int, input().split()))

ans = []

for i in range(n):
    ans.append(abs(a-(t-0.006*list_H[i])))

min_value = min(ans)

for i in range(n):
    if ans[i] == min_value:
        print(i+1)
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n,k;
    cin>>n>>k;
    int a[n],dp[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        for(int j=1;j<=k;j++){
            if(j<=i){
                dp[i] = min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
//use proconio::fastout;
use proconio::{input,marker::*};
//use std::collections::*;
use std::cmp::*;

fn main() {
  input! {
    S:String
  }
  let S:String=S;
  let mut ans = match &*S {
    "RRR" => 3,
    "RRS" => 2,
    "SRR" => 2,
    "SSS" => 0,
    _ => 1,
  };
  println!("{}", ans);
}


Measured memory_bytes: 2112
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<iostream>
#include<fstream>
#include<cstring>

using namespace std;

int main(){
	int x,y;
	scanf("%x %x",&x,&y);
	if(x<y)   printf("<\n");
	if(x>y)   printf(">\n");
	if(x==y)  printf("=\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		System.out.println(H * W - (h * W + (w * H - h * w)));
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;struct food{int t;int d;bool operator<(const food b)const{return d>b.d;}}a[100000+5];int n,k;stack<int > q;set<int > s;long long sum,sum1;int main(){cin>>n>>k;for(int i=0;i<n;i++)scanf("%d %d",&a[i].t,&a[i].d);sort(a,a+n);for(int i=0;i<k;i++){sum+=a[i].d;if(s.count(a[i].t))q.push(a[i].d);s.insert(a[i].t);}sum+=s.size()*s.size();sum1=sum;int i=k;while(i<n&&!q.empty()){if(!s.count(a[i].t)){sum1=sum1-q.top()+a[i].d-s.size()*s.size()+(s.size()+1)*(s.size()+1);q.pop();s.insert(a[i].t);sum=max(sum1,sum);}i++;}cout<<sum<<'\n';}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, p;
   string s;
   cin >> n;
   map<string, map<int, int>> mp;
   for (int i = 1; i <= n; i++)
   {
      cin >> s >> p;
      mp[s][p] = i;
   }
   for (auto itr = mp.begin(); itr != mp.end(); itr++)
      for (auto jtr = itr->second.rbegin(); jtr != itr->second.rend(); jtr++)
         cout << jtr->second << endl;

   return 0;
}


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

int main()
{
		int a, b, c;
		int x, y, z;
		
		cin >> a >> b >> c;

		if (a < b) {
				if (b < c) {
						x = a;
						y = b;
						z = c;
				} else if(b > c) {
						if (a < c) {
								x = a;
								y = c;
								z = b;
						} else if (a > c) {
								x = c;
								y = a;
								z = b;
						} else if (a == c) {
								x = a;
								y = c;
								z = b;
						}
				} else if (b == c) {
						x = a;
						y = b;
						z = c;
				}
		} else if (a > b) {
				if (b > c) {
						x = c;
						y = b;
						z = a;
				} else if (b < c) {
						if (a > c) {
								x = b;
								y = c;
								z = a;
						} else if (a < c) {
								x = b;
								y = a;
								z = c;
						} else if(a == c) {
								x = b;
								y = a;
								z = c;
						}
				} else if (b == c) {
						x = b;
						y = c;
						z = a;
				}
		} else if (a == b) {
				if (a < c) {
						x = a;
						y = b;
						z = c;
				} else if (a > c) {
						x = c;
						y = b;
						z = a;
				}
		}

		cout << x << ' ' << y << ' ' << z << "\n";

		return 0;
}

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

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

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

for i, ai in enumerate(a):
    cnt = 0
    for j, bj in enumerate(b):
       cnt += ai[j] * bj
    print(cnt)


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

int main()
{
    int a,b,c,t;
    cin >> a >> b >> c;
    for(int i=0;i<3;i++)
    {
        if(a>=b)
        {
            t=b;
            b=a;
            a=t;
        }
        if(b>=c)
        {
            t=c;
            c=b;
            b=t;
        }
    }
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main(void)
{
	int i,n;
	int x,y,b,p;
	int xb,yp,xbyp,xbyp2,xbyp3,xbyp4;
	int b2,p2,xb2,yp2;
	scanf("%d",&n);
	
		
		
	for(i=1;i<=n;i++){
		scanf("%d %d %d %d",&x,&y,&b,&p);
		xb=x*b;
		yp=y*p;		
		if(b>=5 && p>=2){
			xbyp2=(xb+yp)*8/10;	
			printf("%d\n",xbyp2);
		}
		else {
			xbyp=xb+yp;
			
			if(b<5){
				b=5;
			}
			if(p<2){
				p=2;
			}
			
			xb2=x*b;
			yp2=y*p;
			xbyp3=(xb2+yp2)*8/10;
			
			if(xbyp3<xbyp){
				printf("%d\n",xbyp3);
			}
			else {
				printf("%d\n",xbyp);
			}
		}

	}
	return 0;
}
		

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

int main() {
	int n;
	cin>>n;
	int prev = 987654321;
	int sum = 0;
	for(int i = 0;i<n-1;i++){
		int t, a;
		cin>>t;
		a = min(t, prev);
		sum += a;
		prev = t;
	}
	cout<<sum + prev;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int c = 1;
		string ans = "Yes";
		for(var i=0;i<=30;i++){
			if(c==N){
				ans = "No";
				break;
			} else if(c>N){
				c /= 2;
				break;
			} else {
				c *= 2;
			}
		}
		Console.WriteLine(ans);
		if(ans=="Yes"){
			Console.WriteLine("1 2");
			Console.WriteLine("2 3");
			Console.WriteLine("3 "+(N+1));
			Console.WriteLine((N+1)+" "+(N+2));
			Console.WriteLine((N+2)+" "+(N+3));
			for(var i=3;i<=(N+1)/2;i++){
				Console.WriteLine((N+1)+" "+(i*2-1));
				Console.WriteLine((i*2-1)+" "+(i*2-2));
				Console.WriteLine((N+1)+" "+(N+i*2-2));
				Console.WriteLine((N+i*2-2)+" "+(N+i*2-1));
			}
			if(N%2==0){
				int d = N-c+1;
				Console.WriteLine(N+" "+d);
				Console.WriteLine((N*2)+" "+(c+N));
			}
		}
	}
}

Measured memory_bytes: 19880
{-# LANGUAGE TupleSections #-}

import qualified Data.ByteString.Char8 as B
import           Data.Maybe (fromJust)
import qualified Data.Map.Strict as M
import           Control.Monad (replicateM)

modT :: Integer
modT = 1000000007

main :: IO ()
main = do
  n <- getInt
  m <- M.fromListWith (+) . fmap ((, 1) . convert) <$> replicateM n getInts
  print . solve $ m

convert :: [Int] -> (Int, Int)
convert [a, b]
  | a == 0 && b == 0 = (0, 0)
  | a == 0 = (0, 1)
  | b == 0 = (1, 0)
  | otherwise = let gcd' = gcd a b
                in if b < 0
                   then (-div a gcd', -div b gcd')
                   else (div a gcd', div b gcd')

solve :: M.Map (Int, Int) Int -> Integer
solve map = let zero = M.findWithDefault 0 (0, 0) map
                ans = solve' . M.delete (0, 0) $ map
            in (fromIntegral zero + ans - 1) `mod` modT

solve' :: M.Map (Int, Int) Int -> Integer
solve' map = go 1 map
  where
    go :: Integer -> M.Map (Int, Int) Int -> Integer
    go acc map = if M.null map
                 then acc
                 else whenNotNull acc map

    whenNotNull :: Integer -> M.Map (Int, Int) Int -> Integer
    whenNotNull acc map =
      let ((a, b), count) = M.elemAt 0 map
          inv = if a > 0
                then (-b, a)
                else (b, -a)
          count' = M.findWithDefault 0 inv map
          ccount = ((2 ^ count `mod` modT) + (2 ^ count' `mod` modT) - 1)
            `mod` modT
          nacc = (ccount * acc) `mod` modT
          nmap = M.delete (a, b) . M.delete inv $ map
      in nacc `seq` nmap `seq` go nacc nmap

getInt = fst . fromJust . B.readInt <$> B.getLine

getInts = fmap (fst . fromJust . B.readInt) . B.words <$> B.getLine


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

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a < 10 && b < 10 ? a * b : -1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n=5;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]==0)
            {
                cout<<i+1;
        break;
    }
    }
}
return 0;
}

Measured memory_bytes: 3628
#include<iostream>

int main()
{
	int a, b, k;

	std::cin >> a >> b >> k;
	int l = a;
	if (a > b)
		l = b;

	int count = 0;
	for (int i = l; i >0 ; --i) {
		if ((a%i == 0) && (b%i) == 0)
			++count;
		if (count == k) {
			std::cout << i;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#if LOCAL_ENVIRONMENT == 1
#include "debug.hpp"
#endif
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}

#if LOCAL_ENVIRONMENT == 1
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define debugTable(dp) debugDPTable(dp);
#else
#define debug(x) {}
#define debugBit(x,n) {}
#define debugTable(dp) {}
const long long INF = 1LL<<60;
#endif
 
int main()
{
#if LOCAL_ENVIRONMENT == 1
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  ll N = input();
  ll W = input();
 
  vector<ll> weight;
  vector<ll> value;
  
  ll max_v = 1;
  for(ll i=0;i<N;i++){
    ll w = input();
    ll v = input();
    weight.push_back(w);
    value.push_back(v);
    max_v += v;
  }
 
  vector<vector<ll>> dp(N+1, vector<ll>(max_v));
  for (int i = 0; i <= N; ++i) for (int j = 0; j < max_v; ++j) dp[i][j] = INF;
  dp[0][0] = 0;
 
  for (int i = 0; i < N; i++) {
    for (int sum_v = 0; sum_v < max_v; sum_v++) {
      // i 番目の品物を選ぶ場合
      if (sum_v - value[i] >= 0){
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
      }
      // i 番目の品物を選ばない場合
      dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v]);
    }
  }

  debugTable(dp)

  int ret = 0;
  for (int i = 0; i <= N; ++i) {
    for (int sum_v = 0; sum_v < max_v; ++sum_v) {
      if(dp[i][sum_v] <= W){
        ret = max(ret, sum_v);
      }
    }
  }
  output(ret);
 
  return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=5e5+5;
int mod=1e9+7;

ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}


int main()
{
    FIO
string s;
cin>>s;
int ans=1;
string x;
x+=s[0];
string cu;
for(int i=1;i<s.size();i++)
{
    cu+=s[i];
    if(x!=cu)
    {
    ///cout<<cu<<" "<<x<<endl;
        ans++;
        x=cu;
        cu="";
    }
}

    cout<<ans;

    return 0;
}



Measured memory_bytes: 720
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;
 
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops") 
 
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;  
 
#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif

 
std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}
 
const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;
 
const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
		int x; cin >> x;
        if(x >= 30) cout << "Yes" << '\n';
        else cout << "No" << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n;
  cin >> n;
  printf("%lld",KAI(n));
}

Measured memory_bytes: 1792