akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cassert>
#include <cmath>
#include <map>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 200000;
int frec[1 + nmax];
int sol[1 + nmax];

int main() {
  int n, x;
  std::cin >> n >> x;
  if(x == 1 || x == n * 2 - 1)
    std::cout << "No";
  else {
    if(n == 2)
      std::cout << "Yes\n" << 1 << " " << 2 << " " << 3 << '\n';
    else {
      sol[n] = x;
      sol[n - 1] = x - 1;
      sol[n + 1] = x + 1;
      frec[x] = frec[x - 1] = frec[x + 1] = 1;
      if(2 < x) {
        sol[n + 2] = x - 2;
        frec[x - 2] = 1;
      } else {
        sol[n - 2] = x + 2;
        frec[x + 2] = 1;
      }
      int ptr = 1;
      for(int i = 1;i <= 2 * n - 1; i++) {
        if(sol[i] == 0) {
          while(frec[ptr] == 1)
            ptr++;
          sol[i] = ptr;
          frec[ptr] = 1;
        }
      }
      std::cout << "Yes\n";
      for(int i = 1;i <= 2 * n - 1; i++)
        std::cout << sol[i] << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 5148
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
main = mapM_ (print . solve) . analyze . map readInt . B.lines =<< B.getContents
readInt = fst . fromJust . B.readInt
analyze [] = []
analyze (n:cs) = (n,as):analyze bs where (as,bs) = splitAt (n-1) cs
solve (n,as) = dfs 0 where
  g = V.accum (flip (:)) (V.replicate n []) . flip zip [1..] . map pred $ as
  dfs i = maximum . (0:) . zipWith (+) [1..] . reverse . sort . map dfs $ g V.! i

Measured memory_bytes: 47100
#include <iostream>
#define N 2005
using namespace std;
int n, x, w[N], b[N], dw[2*N][N], db[2*N][N], dp[N][N];
char c;
int main() {
	int i, j;
	cin>>n;
	for(i=1; i<=2*n; i++) {
		cin>>c>>x;
		c=='W' ? w[x]=i : b[x]=i;
		for(j=0; j<n; j++) {
			dw[i][j] = dw[i-1][j], db[i][j] = db[i-1][j];
			c=='W' ? dw[i][j] += x>j : db[i][j] += x>j;
		}
	}
	for(j=1; j<=n; j++) dp[0][j] = 1e9;
	for(i=0; i<=n; i++) for(j=0; j<=n; j++) {
		if(i) dp[i][j] = dp[i-1][j] + dw[w[i]][i] + db[w[i]][j];
		if(j) dp[i][j] = min(dp[i][j], dp[i][j-1] + dw[b[j]][i] + db[b[j]][j]);
	}
	cout<<dp[n][n];
	return 0;
}

Measured memory_bytes: 78720
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <set>
const int maxn=1e5+10;
typedef std::pair<int,int> pii;
typedef std::set<int>::iterator tit;
std::set<int> ed[2][maxn];
std::set<pii> todo;
int fa[maxn];
void addedge(int id,int u,int v)
{
    ed[id][u].insert(v);
    ed[id][v].insert(u);
    if(ed[id^1][u].find(v)!=ed[id^1][u].end()) todo.insert(std::make_pair(u,v));
}
void rename(int u,int v)
{
    fa[u]=v;
    for(tit it=ed[0][u].begin();it!=ed[0][u].end();it++)
    {
        ed[0][*it].erase(u);
        addedge(0,v,*it);
    }
    for(tit it=ed[1][u].begin();it!=ed[1][u].end();it++)
    {
        ed[1][*it].erase(u);
        addedge(1,v,*it);
    }
    ed[0][u].clear();
    ed[1][u].clear();
}
int getf(int x)
{
    return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int n;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(!isdigit(ch))
    {
        f=(ch=='-'?-f:f);
        ch=getchar();
    }
    while(isdigit(ch))
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return f<0?-x:x;
}
int main()
{
    n=read();
    for(int i=1;i<n;i++)
    {
        int u,v;
        u=read();v=read();
        addedge(0,u,v);
    }
    for(int i=1;i<n;i++)
    {
        int u,v;
        u=read();v=read();
        addedge(1,u,v);
    }
    int cnt=0;
    for(int i=1;i<=n;i++) fa[i]=i;
    while(todo.size()>0)
    {
        pii cur=*todo.begin();
        todo.erase(todo.begin());
        cur.first=getf(cur.first);
        cur.second=getf(cur.second);
        if(cur.first==cur.second)continue;
        ed[0][cur.first].erase(cur.second);
        ed[1][cur.first].erase(cur.second);
        ed[0][cur.second].erase(cur.first);
        ed[1][cur.second].erase(cur.first);
        if(ed[0][cur.first].size()+ed[1][cur.first].size()<ed[0][cur.second].size()+ed[1][cur.second].size()) rename(cur.first,cur.second);
        else rename(cur.second,cur.first);
        cnt++;
    }
    if(cnt==n-1)puts("YES");else puts("NO");
    return 0;
}


Measured memory_bytes: 30848
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
  //    #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------



signed main(){
string s="CODEFESTIVAL2016",t;
	int n,m,k;
cin>>t;
	int ans=0;
	for(int i=0;i<16;i++){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

//printf("%.10f\n",ans);


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

int main(){
	int n = 1;
	int q = 1;
	int a, b;
	cin >> n >> q;

	vector< vector<int> > arr(n-1);
	for (int i = 0; i < n-1; i++) {
		cin >> a >> b;
		arr[a-1].push_back(b);
	}

	vector<mp::cpp_int> score(n);
	vector<mp::cpp_int> sum(n);
	for (int i = 0; i < n; i++) {
		score[i] = 0;
		sum[i] = 0;
	}
	for (int i = 0; i < q; i++) {
		cin >> a >> b;
		sum[a-1] += b;
		score[a-1] += b;
	}
	for (int i = 0; i < n-1; i++) {
		int size = arr[i].size();
		for (int j = 0; j < size; j++) {
			sum[arr[i][j]-1] += sum[i];
			score[arr[i][j]-1] += sum[i];
		}
	}
	cout << score[0];
	for (int i = 1; i < n; i++) {
		cout << " " << score[i];
	}
	return 0;
}

Measured memory_bytes: 25856
n,x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    num = a[i] + a[i+1]
    if num > x:
        ans += num - x
        if a[i+1] - (num - x) < 0:
            a[i+1] = 0
        else:
            a[i+1] -= num - x
print(ans)

Measured memory_bytes: 14540
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

int solve(int bit,vi& xs,vi& ys,vi& memo)
{
	if(memo[bit]!=-1)
		return memo[bit];
	if(bit==0xffff)
		return memo[bit]=1;
	
	rep(i,4) rep(j,4){
		int p=i*4+j;
		if(bit&1<<p)
			continue;
		int res=0;
		rep(k,4){
			int ii=i+ys[k],jj=j+xs[k],pp=ii*4+jj;
			if(ii<0 || 4<=ii || jj<0 || 4<=jj || (bit&1<<pp))
				continue;
			int next=bit|1<<p|1<<pp;
			res+=solve(next,xs,ys,memo);
		}
		return memo[bit]=res;
	}
	assert(false);
}

int main()
{
	for(;;){
		vi xs(4),ys(4);
		rep(i,4)
			cin>>xs[i]>>ys[i];
		if(xs[0]>4)
			break;
		
		vi memo(1<<16,-1);
		cout<<solve(0,xs,ys,memo)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
s=input()
n=len(s)

if n==2:
  if s[0]==s[1]:
    print(1, 2)
  else:
    print(-1, -1)
  exit()

for i in range(n-2):
  t=s[i:i+3]
  if t[0]==t[1] or t[1]==t[2] or t[0]==t[2]:
    print(i+1, i+3)
    exit()
print(-1, -1)

Measured memory_bytes: 3188
(stdin => {
  // Define Function
  const nsort = ([a, b]) => [a, b].sort((x, y) => x - y).join(' ')

  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const nlist = inputs.slice(0, -1)
    .map(v => v.split(' ').map(Number))

  const result = Array.from(nlist, nsort)

  console.log(result.join('\n'))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))



Measured memory_bytes: 18492
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

int n, h, a[100005], b[100005];
int main()
{
	cin >> n >> h;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];
	//找出最大砍得伤害 
	
	int maxa = -1;//记一下初始值
	for (int i = 1; i <= n; i++)
		maxa = max(a[i], maxa);
	//找出有价值的扔的伤害 ,存在了d[1] ~ d[cur] 
	int d[100005], cur = 0, ans = 0;//记一个光标
	for (int i = 1; i <= n; i++)
		if (b[i] > maxa)
		d[++cur] = b[i];//已经有了所有伤害值
	sort(d + 1, d + cur + 1);//排一下序
	//从高到低开始扔
	while (h > 0 && cur > 0){//武器还有 而且 它还没死时继续扔 
		h -= d[cur--];//光标移动一位
		ans++; 
	}
	//如果没死，继续砍
	if (h > 0)
		ans += int(ceil(h * 1./ maxa));//变一下浮点数
	cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 1408
#include <iostream>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    
    vector<int> vec1(n);
    
    int cnt=0, x=vec[0];
    vec1[0] = 0;
    for(int i=1;i<n;i++){
        if(x >= vec[i]){
            x = vec[i];
            cnt ++;
        }else{
            vec1[i] = cnt;
            cnt = 0;
            x = vec[i];
        }
    }
    if(cnt != 0){
        vec1[n-1] = cnt;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(ans < vec1[i]){
            ans = vec1[i];
        }
    }
    
    cout << ans <<endl;
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#ifndef repeat
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#endif
#ifndef repeat_from
#define repeat_from(i,m,n) for (int i = (m); i < (n); ++i)
#endif
#ifndef repeat_one
#define repeat_one(i,n) for (int i = 1; i <= (n); ++i)
#endif
#ifndef repeat_rev
#define repeat_rev(i,n) for (int i = (n)-1; 0 <= i; --i)
#endif
#ifndef foreach
#define foreach(it, cont) for (typeof(cont.begin()) it = cont.begin(); it != cont.end(); ++it)
#endif
using namespace std;
#define MAX_N 7
int p, q, a, n;
vector<int> num;
int dfs(int sum, int prod) {
    int acc = 0;
    for (int i = (num.empty() ? 1 : num.back()); i * prod <= a; ++i) {
        int sum0 = sum * i + 1 * prod; // b/a + d/c = (ad + bc) / ac
        int prod0 = prod * i;
        int d = p * prod0 - sum0 * q; // p/q = a/b <=> pb = aq ; k * (p/q - a/b)
        if (0 < d) {
            if ((int)num.size()+2 <= n) {
                num.push_back(i);
                acc += dfs(sum0, prod0);
                num.pop_back();
            }
        } else if (d == 0) {
            acc += 1;
        }
    }
    return acc;
}
int solve() {
    num.clear();
    return dfs(0, 1);
}
int main() {
    ios_base::sync_with_stdio(false);
    while (true) {
        cin >> p >> q >> a >> n;
        if (p == 0 and q == 0 and a == 0 and n == 0) break;
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

using namespace std;

void erase(multimap<int, int>& mm, int i, int j)
{
	auto it = mm.find(i);
	while (it->second != j) {
		it++;
	}
	mm.erase(it);
}

bool count_sides(multimap<int, int>& rel)
{
	int count = 0;
	int prev  = 0;
	auto it = rel.begin();
	while (it != rel.end()) {
		if (prev != it->first) {
			if (count & 1) return false;
			prev = it->first;
			count = 0;
		}
		count++;
		it++;
	}
	if (count & 1) return false;

	return true;
}

bool search(multimap<int, int>& rel, int n)
{
	int  count  = 0;
	int  c_count = 0;
	int  g_num  = 1;
	int  ind_c  = 1;
	bool is_ind = true;

	int p = rel.begin()->first;

	vector<int> nexts(n + 1);
	vector<int> prevs(n + 1);
	vector<int> gnums(n + 1);
	vector<bool> is_used(n + 1);
	is_used[p] = true;

	while (!rel.empty()) {
		auto it = rel.find(p);
		if (it == rel.end()) {
			prevs[p] = 0;

			p = rel.begin()->first;
			if (gnums[p] == 0) {
				g_num++;
				ind_c++;
				is_ind = true;
			}
			if (is_used[p]) {
				c_count++;

				//cout << p << endl;
			}
			is_used[p] = true;

			continue;
		}


		while (it->first == p && it->second == prevs[p]) it++;

		int n_p = it->second;

		nexts[p]   = n_p;
		is_used[p] = true;

		if (gnums[n_p] != 0 && gnums[n_p] != gnums[p]) {
			is_ind = false;
			ind_c--;
		}

		gnums[p] = g_num;
		gnums[n_p] = g_num;

		if (nexts[n_p] != 0) {
			is_used[n_p] = true;
			count++;

			int cur_p  = n_p;
			int cur_np = nexts[n_p];
			while (cur_np != n_p) {
				nexts[cur_p] = 0;
				prevs[cur_np] = 0;

				erase(rel, cur_p, cur_np);
				erase(rel, cur_np, cur_p);

				cur_p  = cur_np;
				cur_np = nexts[cur_p];
			}
			erase(rel, cur_p, cur_np);
			erase(rel, cur_np, cur_p);
			nexts[cur_p] = 0;

			p     = n_p;
			if (rel.find(p) != rel.end()) c_count++;
		}
		else {
			//cout << p << " " << n_p << " " << is_used[n_p] << endl;
			if (is_used[n_p]) {
				//cout << n_p << endl;
				c_count++;
			}
			prevs[n_p] = p;
			p     = n_p;
			is_used[n_p] = true;
		}
	}

	//cout << c_count << endl;
	count += c_count / 3;

	if (count >= 3 && ind_c <= 3) return true;

	return false;
}

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

	multimap<int, int> rel;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a; cin >> b;

		rel.insert(make_pair(a, b));
		rel.insert(make_pair(b, a));
	}

	bool ok = count_sides(rel);

	if (ok) {
		ok = search(rel, n);
	}
	if (ok) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 10752
#include<stdio.h>



int main () {
    int i, j, k, n, a, b, Dice[7], side[5] = {2, 3, 5, 4, 2};
    char order[7][3] = {"", "", "N", "W", "E", "S", "NN"};
    
    //ダイスの目の入力
    for (i=1; i<7; i++) { //1 ~ 6 Dice[]
        scanf("%d", &Dice[i]);
    }
    
    //質問の数の入力
    scanf("%d", &n);
    
    //上面を合わせる
    //側面の入力
    for (i=0; i<n; i++) {
        scanf("%d %d", &a, &b);
        
        for (j=1; Dice[j] != a; j++) {
        }// 1 ~   aじゃない
            //回す
            for(k=0;order[j][k]!='\0';k++){
                
                Dice[0] = Dice[1];
                
                switch(order[j][k]){
                        
                    case 'E':
                        Dice[1] = Dice[4];
                        Dice[4] = Dice[6];
                        Dice[6] = Dice[3];
                        Dice[3] = Dice[0];
                        break;
                        
                    case 'N':
                        Dice[1] = Dice[2];
                        Dice[2] = Dice[6];
                        Dice[6] = Dice[5];
                        Dice[5] = Dice[0];
                        break;
                        
                    case 'S':
                        Dice[1] = Dice[5];
                        Dice[5] = Dice[6];
                        Dice[6] = Dice[2];
                        Dice[2] = Dice[0];
                        break;
                        
                    case 'W':
                        Dice[1] = Dice[3];
                        Dice[3] = Dice[6];
                        Dice[6] = Dice[4];
                        Dice[4] = Dice[0];
                        break;
                        
                }
            }
        
        for(j=0; b!=Dice[side[j]]; j++);
        
        printf("%d\n", Dice[side[j+1]]);
        
        
    }
    
    
    
    return 0;
}



Measured memory_bytes: 2048
import math
def main():
    n = int(input())
    r = 0
    for x in range(1, n + 1):
        if x % 3 == 0 and x % 5 == 0:
            continue
        elif x % 3 == 0:
            continue
        elif x % 5 == 0:
            continue
        else:
            r += x
    
    print(r)

main()


Measured memory_bytes: 9072
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);CIN(A);
    COUT((N*N)-A);
    return 0;
}


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

int main() {
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];

    int index = 0;
    size_t len = s[0].size()+s[1].size()+s[2].size();
    for (int i = 0; i < len; i++) {
        char c = s[index][0];
        
        if (s[index].empty()) {
            cout << char(index + 'A') << endl;
            break;
        }
        s[index].erase(s[index].begin());
        index = c - 'a';
    }
}


Measured memory_bytes: 256
n,k= map(int, input().split()) 
lst = [] 
lst2 = []
sum=0
j=0
lst = [int(item) for item in input().split()]
i=0 
while i<n:
	if i==0:
		while i<k-1:
			sum=sum+lst[i]
			i=i+1
	else:
		sum=sum-lst[j]
		sum=sum+lst[i]
		j=j+1
	lst2.append(sum)
	i=i+1

x=len(lst2)
for i in range(1,x):
	if lst2[i]>lst2[i-1]:
		print("Yes")
	else:
		print("No")


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin>>s;
	int ans=0, cnt=0;
	rep(i, s.size()){
		if (s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
			cnt++;
			ans = max(ans, cnt);
		}else{
			cnt=0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
const int maxn = 3000 + 10;
const int mod = 1e9 + 7;

ll dp[maxn][maxn], pd[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i <= n; i++)
		dp[0][i] = 1;

	for (int i = 0; i < m; i++){
		for (int r = 0; r <= n; r++){
			dp[i][r] %= mod;
			int b = n - r;
			// r - r
			if (r > 0)
				dp[i + 1][r - 1] += dp[i][r];
			// r - b
			if (r > 0)
				dp[i + 1][r] += dp[i][r];

			// b - r
			if (r < n)
				dp[i + 1][r] += dp[i][r];
			
			// b - b
			if (r < n)
				dp[i + 1][r + 1] += dp[i][r];
		}
	}
	ll answer = 0;
	for (int i = 0; i <= n; i++)
		answer = (answer + dp[m][i]) % mod;
	memset(dp, 0, sizeof dp);
	for (int i = 0; i <= n; i++)
		dp[0][i] = 1;
	for (int i = 0; i < m; i++){
		for (int r = 1; r <= n; r++){
			dp[i][r] %= mod;
			// r - r
			if (r > 1)
				dp[i + 1][r - 1] += dp[i][r];
			// r - b
			if (r > 1)
				dp[i + 1][r] += dp[i][r];

			// b - r
			if (r < n)
				dp[i + 1][r] += dp[i][r];
			
			// b - b
			if (r < n)
				dp[i + 1][r + 1] += dp[i][r];

		}
	}
	for (int i = 1; i <= n; i++){
		dp[m][i] %= mod;
		answer = (answer - dp[m][i] + mod) % mod;
	}
	cout << answer << endl;
}


Measured memory_bytes: 72192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }

            List<Integer> colors = new ArrayList<>();
            colors.add(A[0]);
            for (int i = 1; i < N; i++) {
                int low = 0, hi = colors.size() - 1;
                for (int j = 0; j < 1000 && low < hi; j++) {
                    int mid = low + (hi - low) / 2;
                    int v = colors.get(mid);
                    if (v >= A[i]) {
                        low = mid + 1;
                    } else if (v < A[i]) {
                        hi = mid;
                    }
                }
                if (colors.get(low) < A[i]) {
                    colors.remove(low);
                    colors.add(low, A[i]);
                } else {
                    colors.add(A[i]);
                }
            }
            out.println(colors.size());
        }

    }
}



Measured memory_bytes: 50092
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
  fast();
  int n=D();
  int x=n/15;
  ll sum=1;
  for(int i=1;i<=n;++i)
    sum=(sum*i)%1000000007;
  cout<<sum%1000000007<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){

ll a,b,c,d,e,f;

ll n; 
cin>>n;

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

a=*max_element(v.begin(), v.end());

vector<ll> x(a);

for(ll i=0;i<a;i++){

for(ll z=0;z<n;z++){
  b=pow((v[z]-(i+1)),2);
  x[i]+=b;
}

}

f=*min_element(x.begin(), x.end());
cout << f << endl;

}

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

int main() {
  int N,M,X,Y;cin>>N>>M>>X>>Y;
  int r=999,l=-999;
  for(int i=0; i<N; i++){
    int x;cin>>x;
    l=max(l,x);
  }
  for(int i=0; i<M; i++){
    int y;cin>>y;
    r=min(r,y);
  }
  if(l<r&&X<l&&Y>=r)cout<<"No War"<<endl;
  else cout<<"War"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n);
    vector<int> b(n);
    for (auto &&i : a) scanf("%d", &i);
    for (auto &&i : b) scanf("%d", &i);
    for (int j = (1 << 29)-1; j; j >>= 1) {
        int x = (j+1)/2;
        for (auto &&i : a) {
            i &= j;
        }
        for (auto &&i : b) {
            i &= j;
        }
        sort(b.begin(), b.end());
        u32 v = 0;
        for (auto &&i : a) {
            v += (lower_bound(b.begin(), b.end(), 2*x-i) - lower_bound(b.begin(), b.end(), x-i))+
                    (lower_bound(b.begin(), b.end(), 4*x-i) - lower_bound(b.begin(), b.end(), 3*x-i));
            v %= 2;
        }
        ans += (v & 1)*x;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, q;
int cnt[100010];
ll ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		cnt[a]++;
		ans += a;
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int b, c; cin >> b >> c;
		ans -= (ll)cnt[b] * b;
		ans += (ll)cnt[b] * c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << ans << endl;
	}
}

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

int main(void) {
	int N,K;
	int X[100000];
	long long int ans=0;
	int l_num=0,r_num=0,m_num=0;
	cin >> N >> K;
	for (int i = 0;i < N;i++) {
		cin >> X[i];
	}
	for (int i = 0;i <= N - K;i++) {
		long long int n = 0;
		if (X[i] < 0 && X[i + K - 1] < 0)
			n = abs(X[i]);
		else if (X[i] < 0 && X[i + K - 1] > 0)
			n = min(abs(X[i]), abs(X[i + K - 1])) * 2 + max(abs(X[i]), abs(X[i + K - 1]));
		else
			n = abs(X[i + K - 1]);
		if (i == 0)
			ans = n;
		else
			ans = min(ans,n);
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) cin >> b[i];
    REP(i,0,n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    REP(i,0,n){
        ll cnt1, cnt2;
        cnt1 = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        cnt2 = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
        ans += cnt1 * (n - cnt2);
    }

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

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  for (int i = N; i > 0; --i) {
    int sq = sqrt(i);
    if (sq * sq == i) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int fact(int n){
    if(n == 1) return 1;
    else return n * fact(n-1);
}

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> array(n);
    for(int i=0;i<n;i++) cin >> array.at(i).first >> array.at(i).second;
    sort(array.begin(),array.end());
    double sum = 0;
    do{
        for(int i=0;i<n-1;i++){
            int d2 = (array.at(i+1).first - array.at(i).first) * (array.at(i+1).first - array.at(i).first) +
                    (array.at(i+1).second - array.at(i).second) * (array.at(i+1).second - array.at(i).second);
            double d = sqrt((double)d2);
            sum += d;
        }
    } while(next_permutation(array.begin(),array.end()));

    int kaijou = fact(n);
    double ave = sum / (double)kaijou;
    printf("%.10lf \n",ave);
}


Measured memory_bytes: 3764
#include<stdio.h>
int du[110];
int main()
{
    int n,m,i,x,y;
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&x,&y);
        du[x]++;
        du[y]++;
    }
    for(i=1;i<=n;i++)
        printf("%d\n",du[i]);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){

int i,j,n,v;
int a[3][101];

scanf("%d", &n);
	
for(j=1;j<=2;j++){
	for(i=1;i<=n;i++){
		scanf("%d",&v);
		a[j][i] = v;
	}
}

int line,count;
int l,m,max;
count = 0;
max = 0;

for(i=1;i<=n;i++){

	for(l = 1; l <= i; l++){
		count = count + a[1][l];
	}

	for(m = l-1; m <= n; m++){
		count = count + a[2][m];
	}

	if(max < count){
		max = count;
	}

	count = 0;
}

printf("%d", max);

return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> que;
    for(int i = 0; i < n; ++i){
        double temp;
        cin >> temp;
        que.push(temp);
    }
    
    while(que.size() > 1){
        double x = que.top();   que.pop();
        double y = que.top();   que.pop();
        que.push((x+y)/2);
    }
    
    double res = que.top();
    cout << res << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<char> a(n);
  
  rep(i,m) {
    int s;
    char c;
    cin >> s >> c;
    if(n !=1 && s == 1 && c =='0') {
      cout << -1 <<endl;
      return 0;
    }
    if(a[s - 1] == '\0') {
      a[s - 1] = c;
    } else if(a[s - 1] != c) {
      cout << -1 << endl;
      return 0;
    }
  }
  rep(i,n) {
    if(a[i] == '\0') a[i] = '0';
  } 
  if(n !=1 && a[0] == '0') a[0] = '1';
    
  rep(i,n) cout << a[i];
  cout << endl;
}


Measured memory_bytes: 256
X=int(input())
def is_prime(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True
flag=False
while(flag==False):
    if is_prime(X):
        print(X)
        flag=True
        break
    X+=1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int main() {
int N, M; cin >> N >> M;
VP ab(N); 
rep(i, 0, N) {
	scanf("%d %d", &ab[i].first, &ab[i].second);
}
sort(ALL(ab));

int num = 0, sal = 0;
priority_queue<int> Bqu; // 報酬の降順キュー

rep(i, 1, M+1){ // i 日前の仕事
	while(num < N){
		if (ab[num].first <= i ) {
			Bqu.push(ab[num].second);
			++num;
		}
		else break;
	}
	if (!Bqu.empty()) {
		sal += Bqu.top();
		Bqu.pop();
	}
}

cout << sal << "\n";
return 0;
}

// 境界のチェック


Measured memory_bytes: 1660
//#pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <cstring>
#include <memory.h>
#include <cassert>

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long 
#define pii pair <int, int>
#define ld double

using namespace std;

const int maxn = (int)4e5 + 10;
int l[maxn], r[maxn];

int t[4 * maxn];
int st[4 * maxn];

void sets(int it, int x) {
	t[it] += x;
	st[it] += x;
}

void push(int it) {
	if (st[it] != 0) {
		sets(2 * it, st[it]);
		sets(2 * it + 1, st[it]);
		st[it] = 0;
	}
}

void change(int it, int l, int r, int lm, int rm, int x) {
	if (l == lm && r == rm) {
		sets(it, x);
	}
	else {
		push(it);
		int m = (l + r) >> 1;

		if (rm <= m) {
			change(2 * it, l, m, lm, rm, x);
		}
		else if (lm > m) {
			change(2 * it + 1, m + 1, r, lm, rm, x);
		}
		else {
			change(2 * it, l, m, lm, m, x);
			change(2 * it + 1, m + 1, r, m + 1, rm, x);
		}

		t[it] = max(t[2 * it], t[2 * it + 1]);
	}
}

bool cmp(pii a, pii b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second > b.second;
}

ll inter(pii a, pii b) {
	a.first = max(a.first, b.first);
	a.second = min(a.second, b.second);
	return max(0, a.second - a.first + 1);
}

int main() {
	int n;

	cin >> n;

	ll ans = 0;

	vector <pii> v;

	for (int i = 0; i < n; i++) {
		scanf("%d %d", &l[i], &r[i]);
		ans = max(ans, (ll)r[i] - l[i] + 1);
		v.push_back(mp(l[i], r[i]));
	}

	multiset <int> rm, lm;

	for (int i = 0; i < n; i++) {
		rm.insert(r[i]);
		lm.insert(l[i]);
	}

	if (n != 1)
		for (int i = 0; i < n; i++) {
			lm.erase(lm.find(l[i]));
			rm.erase(rm.find(r[i]));

			ans = max(ans, (ll)r[i] - l[i] + 1 + max(0, (*rm.begin()) - (*lm.rbegin()) + 1));

			lm.insert(l[i]);
			rm.insert(r[i]);
		}

	sort(v.begin(), v.end(), cmp);

	int maxx = -1;

	vector <pii> g;

	for (int i = 0; i < n; i++) {
		while (!g.empty() && g.back().second >= v[i].second) {
			g.pop_back();
		}

		g.push_back(v[i]);
	}

	for (int i = 0; i < (int)g.size() - 1; i++) {
		ans = max(ans, inter(g[0], g[i]) + inter(g[i + 1], g.back()));
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 14068
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B
--
import qualified Data.List as L
import qualified Data.Set as S

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt2 :: Parser (Int,Int)
parseInt2 = liftM2 (,) parseInt parseInt

parse :: Parser (Int, [(Int,Int)])
parse = do
    n<-parseInt
    m<-parseInt
    liftM ((,) n) $ replicateM m parseInt2

main=do
    (n,as) <- fromJust.evalStateT parse <$> B.getContents
    print.length.filter (chk (S.fromList as)).map (1:) $ perm [2..n]

perm [] = [[]]
perm xs = concat [map (x:) $ perm (filter (/=x) xs)|x<-xs]

chk _ [_] = True
chk s (a:b:r) = and[ or[S.member (a,b) s, S.member (b,a) s], chk s (b:r)]

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

ans = 0
pre = -100
for i in A:
    i = i-1
    ans += B[i]
    if pre+1 == i:
        ans += C[pre]
    pre = i
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int N, T; cin >> N >> T;
  vector<int> t(N, 0);
  for (int i = 0; i < N; ++i) {
    cin >> t[i];
  }

  ll ans = 0;
  for (int i = 1; i < N; ++i) {
    ans += min(T, t[i]-t[i-1]);
  }

  cout << ans+T << endl;
}

Measured memory_bytes: 1024
import copy

N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])




Measured memory_bytes: 13352
import java.math.BigInteger;
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		BigInteger a = new BigInteger(sc.next());
		a = a.subtract(BigInteger.ONE);
		BigInteger b = new BigInteger(sc.next());
		BigInteger c = new BigInteger(sc.next());
		BigInteger d = new BigInteger(sc.next());

		BigInteger ans = b.subtract(a);

		BigInteger val = b.divide(c).subtract(a.divide(c));
		ans = ans.subtract(val);

		val = b.divide(d).subtract(a.divide(d));
		ans = ans.subtract(val);

		BigInteger divisor = c.multiply(d).divide(Divisor.gcd(c, d));
		val = b.divide(divisor).subtract(a.divide(divisor));
		ans = ans.add(val);

		System.out.println(ans);
	}
}



class Divisor{
    public static BigInteger gcd(BigInteger a, BigInteger b){
        if(b.equals(BigInteger.ZERO))return a;
        return gcd(b, a.remainder(b));
    }

    static BigInteger x, y;
    public static BigInteger extGcd(BigInteger a, BigInteger b){
        if(b.equals(BigInteger.ZERO)){
            x = BigInteger.ONE;
            y = BigInteger.ZERO;
            return a;
        }
        BigInteger ans = extGcd(b, a.remainder(b));
        BigInteger tmp = y;
        y = x;
        x = tmp;
        y = y.subtract(a.divide(b).multiply(x));
        return ans;
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> c(m);
    rep(i,m) cin>>c[i];
    int dp[50010]={100000};
    rep(i,n+10) dp[i]=inf;
    dp[0]=0;
    //cout<<c[0]<<endl;
    //rep(i,n) cout<<dp[i]<<" ";
    //cout<<endl;
    //cout<<"start"<<endl;
    for(int i=0;i<m;i++){//m種類
        for(int j=0;j<=n;j++){//j円
            /*if(i==0 && j==0){
                rep(i,n) cout<<dp[i]<<" ";
                cout<<endl;
                cout<<"end"<<endl;
            }*/
            if(j+c[i]<=n){
                dp[j+c[i]]=min(dp[j+c[i]],dp[j]+1);
            }
        }   
        //break; 
    }
    //rep(i,n) cout<<dp[i]<<" ";
    //cout<<endl;
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, d, ans = 0;
	int x[10][10];
	int i, j, k;
	double cal;
	
	scanf("%d %d", &n, &d);
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < d; j++) {
			scanf("%d", &x[i][j]);
		}
	}
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			if (i == j) continue;
			cal = 0;
			for (k = 0; k < d; k++) {
				cal += pow((x[i][k] - x[j][k]), 2);
			}
			cal = sqrt(cal);
			if (cal == (int)cal) {
				ans++;
			}
		}
	}
	
	printf("%d\n", ans / 2);
	
	return (0);
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  ll h;
  cin >> h;
  ll ans = 0;
  ll num = 1;
  while (h > 0) {
    ans += num;
    num *= 2;
    h /= 2;
  }

  cout << ans << endl;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, r;
    cin >> n >> r;
    if (n >= 10)
        print(r);
    else
        print(r + 100 * (10 - n));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define nyan "(=^･ω･^=)"
#define read_input         freopen("in.txt","r", stdin)
#define print_output       freopen("out.txt","w", stdout)
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int r, s, p;
    cin >> r >> s >> p;

    vector<int> v;

    for(int i = 1, x, y; i <= p; i++) {
        cin >> x >> y;

        int t = 0;
        if(y <= s) t += s-y+1;
        else t = y - s;

        t += r - x + 1;
        v.pb(t);
    }

    sort(v.begin(), v.end(), greater<int>());

    int mx = -1;
    for(int i = 0; i < p; i++)
        mx = max(mx, v[i] + i);

    cout << mx << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 100002
#define lim9 1000000002

#define deg(rad) (((rad)/2/M_PI)*360)
#define pow(x) (x)*(x)
#define mid(min, max) ((min + max) / 2)

int main() {
	innn(a, b, c);

	out(a + b + c > 21 ? "bust" : "win");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100005
using namespace std;

int n, l, m, r, md, ans, a[N], h[N], bu[N][20], s[20];
vector<int> b[N];
void f(int p, int q) {
    int i;
    h[p] = q;
    for (i= 0; i< b[p].size(); i++) {
        f(b[p][i], q + 1);
    }
}

int g(int p) {return p > 0 ? p : -p;}
int main()
{
    int i, j, t1, t2;
    cin >> n;
    for (i =1; i <= n; i++) {
        scanf ("%d", &a[i]);
    }
    cin >> l;
    j = 1;
    for (i = 1; i < n; i++) {
        for (; j <= n; j++) {
            if (a[j] - a[i] > l) break;
        }
        b[j - 1].push_back(i);
        bu[i][0] = j - 1;
    }
    f(n, 1);
    s[0] = 1;
    for (i = 1; i <= 18; i++) {
        s[i] = s[i - 1] * 2;
        for (j = 1; j <= n; j++) {
            bu[j][i] = bu[bu[j][i - 1]][i - 1];
        }
    }
    cin >> m;
    while (m--) {
        scanf ("%d %d", &t1, &t2);
        if (t1 > t2) swap(t1, t2);
        ans = 0;
        for (i = 18; i >= 0; i--) {
            if (h[t1] <= s[i]) continue;
            if (bu[t1][i] <= t2) {
                t1 = bu[t1][i];
                ans += s[i];
            }
        }
        if (t1 < t2) ans++;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 19584
#include <iostream>
#include <queue>
#include <algorithm>
typedef long long ll;
using namespace std;

int main() {
	int k;
	cin >> k;
	queue<ll> v;
	for (int i = 1; i <= 9; i++)
		v.push(i);
	ll num;
	for (int i = 1; i <= k; i++) {
		num = v.front();
		v.pop();
		if (num % 10 != 0)
			v.push(10 * num + num % 10 - 1);
		v.push(10 * num + num % 10);
		if (num % 10 != 9)
			v.push(10 * num + num % 10 + 1);
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int n;
    cin >> n;
    vi p(n);
    in(n,p);
    
    int ans = 0;
    int f = 100000000;
    rep(i,n){
        if(p[i] <= f){
            ans ++;
            f = p[i];
        }
        
    }

    out(ans);


    return 0;
}


Measured memory_bytes: 1024