akhauriyash/Code-Regression huggingface dataset:
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *STOI GDOI APIO CTS NOIP 2019 RP++                        *
 ***********************************************************/
//#pragma GCC optimize(3)
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) ((x>y)?x:y)
#define Min(x,y) ((x<y)?x:y)
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (int)(1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register ll a=b;a<=c;a++)
#define FORD(a,b,c) for (register ll a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}

template<typename T>
inline void write(T a){
    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}

inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//

signed main(){
    int n=read();
    writeln((n-2)*180);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

double dist(double x, double y){
    return sqrt(x*x + y*y);
}

int main()
{
   int N, D;
   cin >> N >> D;
   vector<double> x(N); vector<double> y(N);
   for(int i = 0 ; i < N ; i++){
       cin >> x[i]; cin >> y[i];
   }

    int cnt = 0;

    for(int i = 0 ; i < N ; i++)
    {
       if (dist(x[i], y[i]) <= D)
       cnt++;
    }

    cout << cnt;
}

Measured memory_bytes: 6496
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int main(void){
	
	int H,W,i,j;
	
	while(1){
	
	scanf("%d %d",&H,&W);
	
	if(H==0 && W==0)break;
	
	else{
		for(i=0;i<H;i++){
		
		for(j=0;j<W;j++){printf("#");}
		printf("\n");
		}
	}
	
	printf("\n");
	
	}
	
return 0;}

Measured memory_bytes: 572
N = int(input())
S = input().strip()

for i,s in enumerate(S):
    if i == 0:
        cnt_MIN = S[1:].count("E") #Westを向かなければならない人の数
        cnt = cnt_MIN
    else:
        if S[i-1] == "W":
            cnt += 1
        if S[i] == "E": 
            cnt -= 1
    if cnt < cnt_MIN:
        cnt_MIN = cnt
print(cnt_MIN)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};
const int mod = 1000000007;
//const int mod = 998244353;


int main() {
    ll n,x,m; cin >> n >> x >> m;
    vector<int> id(m,-1); //余りxにいつ到達したか
    vector<int> a; //通った余り
    int len = 0; //全体の長さ
    ll tot = 0; //全体の和
    while (id[x] == -1) {
        a.push_back(x);
        id[x] = len;
        len++;
        tot += x;
        x = (x*x)%m;
    }
    int c = len - id[x]; //周期の長さ
    ll s = 0; //周期の和
    for (int i=id[x]; i<len; i++) {
        s += a[i];
    }
    ll ans = 0;
    if (n <= len) {
        rep(i,n) ans += a[i];
    } else {
        ans += tot;
        n -= len;
        ans += s*(n/c);
        n %= c;
        rep(i,n) ans += a[id[x]+i];
    }
    cout << ans << endl;
}

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

public class Main {
  public static void main(String[] args) throws IOException {
    try {
      BufferedReader input = new BufferedReader(new InputStreamReader(System.in), 1);
      int x = Integer.valueOf(input.readLine());
      if (1 <= x && x <= 100) {
        System.out.println(cubic(x));
      }
    } catch (Exception e) {
      System.exit(0);
    }

  }

  private static int cubic(int x) {
    return x * x * x;
  }
}

Measured memory_bytes: 24428
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main () {
    int K,S;
    cin>>K>>S;
    int count = 0;
    for (int x = 0; x <= S; x++) {
        for (int y = 0; y <= S - x; y++) {
            if (x <= K && y <= K && S - x - y <= K) count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;

int main(){
  int a;
  string s;

  cin>>a>>s;

  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}


Measured memory_bytes: 256
while true
	array=Array.new 102
	102.times{|i|array[i]=[]}
	while true
		args = gets
		exit if args == nil
		args=args.split(" ").map{|e|e.to_i}
		break if args[0]==0 && args[1]==0

		array[args[0]].push args[1]
		array[args[1]].push args[0]
	end
	flag=true
	2.times{|t|e=t+1
		if array[e].length%2==1
			#OK
		else
			flag = false
		end
	}
	98.times{|t|e=t+3
		if array[e].length%2==0
			#OK
		else
			flag=false
			break
		end
	}
	puts "OK" if flag
	puts "NG" if !flag

end

Measured memory_bytes: 6108
#include<cstdio>
int main(void){
	int a[4][3][10];
	int p;
	int q;
	int r;
	int s;
	int n;
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				a[i][j][k] = 0;
			}
		}
	}
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d %d %d %d", &p, &q, &r, &s);
		a[p - 1][q - 1][r - 1] = a[p - 1][q - 1][r - 1] + s;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 3; j++){
			for (int k = 0; k < 10; k++){
				printf(" %d",a[i][j][k]);
			}
			printf("\n");
		}
		if(i<3)printf("####################\n");
	}
	return 0;
}

Measured memory_bytes: 2732
#include <iostream>

using namespace std;

int main() {
	int n; cin >> n;
	switch (n%10) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
		cout << "bon" << endl;
		break;
	}

	return 0;
}

Measured memory_bytes: 3632
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    h = list(map(int, input().rstrip('\n').split()))
    dp = [0] * n
    for i in range(1, n):
        if i == 1:
            dp[i] = abs(h[i] - h[i-1])
        else:
            dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2])
    print(dp[-1])


if __name__ == '__main__':
    slove()


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

typedef long long lint;
typedef long double louble;

const char lf = '\n';

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

namespace dejavu
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf+bufl;

	inline void fs(){fwrite(buf,1,s-buf,stdout),s=buf;}
	
	inline void pc(int c){if(s==t)fs();*s++=c;}

	inline void py(int x)
	{
		if(x<0)pc('-'),x=-x;
		if(!x)return pc('0');
		static int stk[10];int top=0;
		while(x)stk[++top]=x%10,x/=10;
		while(top)pc('0'+stk[top]),top--;
	}

	struct flusher{~flusher(){fs();}}flusher;
}
using dejavu::pc;
using dejavu::py;

const int _ = 303 , __ = _<<1;

int n,nn;bool ed[__][__]={0};

inline void make(int ps)
{
	int lg=0;
	while(ps%4==0)ps/=4,lg++;
	if(ps%4==1)
	{
		for(int i=1;i<=nn;i++)
			for(int j=1;j<=nn;j++)
				ed[i][j]|=(((i-1)>>lg)+((j-1)>>lg))&1;
	}
	else
	{
		for(int i=1;i<=nn;i++)
			for(int j=1;j<=nn;j++)
				ed[i][j]|=((i-1)>>lg)&1;
	}
}

int main()
{
	n=ty(),nn=n+n,make(ty()),make(ty());
	int cnt=n*n;

	for(int i=1;i<=nn && cnt>0;i++)
		for(int j=1;j<=nn && cnt>0;j++)
			if(!ed[i][j])py(i-1),pc(' '),py(j-1),pc(lf),cnt--;
	
	return 0;
}


Measured memory_bytes: 1280
h,w,n=map(int,input().split())
dic={}
dx=[-2,-1,0]
dy=[-2,-1,0]
ans=[0]*10
for _ in range(n):
  a,b=map(int,input().split())
  for x in dx:
    for y in dy:
      if 1<=a+y and a+y+2<=h and 1<=b+x and b+x+2<=w:
        if (a+y,b+x) not in dic:
          dic[(a+y,b+x)]=1
        else:
          dic[(a+y,b+x)]+=1
ans[0]=(h-2)*(w-2)-len(dic)
for v in dic.values():
  ans[v]+=1
for i in range(10):
  print(ans[i])


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

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

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

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

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);

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

int main() {
	int n,k;
	cin >> n >> k;
	VI d(k);
	REP(i,0,k) cin >> d[i];
	/*
	int ans = 0;
	for(int i = 0;;++i) {
		int one = n % 10;

	}
	*/
	REP(i,n,100000) {
		bool b = true;
		int j = i;
		while (j > 0) {
			int one = j % 10;
			if (find(all(d), one) != end(d)) {
				b = false;
				break;
			}
			j /= 10;
		}
		//cout << j << " " << b << endl;
		if (b) {
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int D[111][111] = {};
    REP(i, N) REP(j, N) cin >> D[i][j];

    if(N == 3) {
        long long ans = LLONG_MAX;
        vector<int> perm(N);
        REP(i, N) {
            perm[i] = i;
        }
        do{
            long long sum = 0;
            REP(i, N) {
                sum += D[ perm[i] ][ perm[(i + 1) % N] ];
            }
            ans = min(ans, sum);
        }while(next_permutation(perm.begin(), perm.end()));

        cout << ans << endl;
    } else {
        long long ans = 0;
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                ans += min(D[i][j], D[j][i]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n;i++)
vector<vector<bool>>used(129,vector<bool>(129,true));
vector<string>graph(130);
int n;
bool inrange(int x,int y){return(0<=x&&x<n&&0<=y&&y<n);}
void bfs(int y,int x){
    int dx[]={0,0,1,-1};
    int dy[]={1,-1,0,0};
    used[y][x]=false;
    
    using pii =pair<int,int>;
    queue<pii>q;
    q.push(pii(y,x));
    while(!q.empty()){
        pii now=q.front(); q.pop();
        rep(i,4){
            int _x=now.second+dx[i];
            int _y=now.first+dy[i];
            if((!inrange(_x,_y))||
               graph[_y][_x]=='x')continue;
            if(!used[_y][_x])continue;
            q.push(pii(_y,_x));
            used[_y][_x]=false;
        }
    }
}
int main(){
    cin>>n;
    rep(i,n)cin>>graph[i];
    int cnt=0;
    rep(i,n)rep(j,graph[i].size()){
        if(graph[i][j]=='o'&&used[i][j]){bfs(i,j); cnt++;}
        //ep(i,n){rep(j,graph[i].size())if(used[i][j])cout<<"o";else cout<<"x"; cout<<endl;}
    }
    cout<<cnt/3<<endl;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, len(s)) {
        reps(j, i + 1, len(s) + 1) {
            string sub = s.substr(i, j - i);
            bool f = true;
            rep(k, len(sub)) {
                if ((sub[k] != 'A') && (sub[k] != 'C') && (sub[k] != 'G') && (sub[k] != 'T')) {
                    f = false;
                    break;
                }
            }
            if (f) ans = max(ans, len(sub));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

H=INT()
# 1-indexedにしたいので先頭に番兵的なものを足す
A=['']+LIST()

def maxHeapify(A, i):
    l=i*2
    r=i*2+1
    if l<=H and A[l]>A[i]:
        mx=l
    else:
        mx=i
    if r<=H and A[r]>A[mx]:
        mx=r
    if mx!=i:
        A[i],A[mx]=A[mx],A[i]
        maxHeapify(A, mx)

for i in range(H//2, 0, -1):
    maxHeapify(A, i)

print(*A)



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

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

Measured memory_bytes: 256
#include<cstdio>
#define ri register int
#define rc register char
#define ll long long int
#define rl register long long int
#define in inline
#define gc getchar
in ll read()
{
	rl x=0,p=1;
	rc ch=gc();
	while(ch<'0' || ch>'9')
	{
		if(ch=='-')
		{
			p=-1;
		}
		ch=gc();
	}
	while(ch>='0' && ch<='9')
	{
		x=x*10+ch-'0',ch=gc();
	}
	return x*p;
}
ll h,w;
int main()
{
	h=read(),w=read();
	if(h==1 || w==1)
	{
		puts("1");
	}
	else
	{
		printf("%lld\n",(h*w+1)/2);
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[] p=new int[n];
        for(int i=0;i<n;i++){
            p[i]=sc.nextInt();
        }

        List<Integer> lst =new ArrayList<>();

        for(int i=0;i<n-2;i++){
            if(p[i]<=p[i+1]&&p[i+1]<=p[i+2]){
                lst.add(p[i+1]);
            }else if(p[i]>=p[i+1]&&p[i+1]>=p[i+2]){
                lst.add(p[i+1]);
            }

        }

            System.out.println(lst.size());



    }
}



Measured memory_bytes: 22996
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    x=int(readline().strip())
    if x<1200:
        print("ABC")
    else:
        print("ARC")
    #n,m,k=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(1)

    return


resolve()


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

int a[300010];
int main(){
  int n;
  long long ans = 0;
  cin >> n;

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

  sort(a,a+n*3);

  int i,j;
  for(i = 0,j = n*3-2;i < n;i++,j-=2){
    ans += a[j];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
import itertools

p = list(map(int,input().split()))
N = p[0]
M = p[1]
X = p[2]

l = [[int(i) for i in input().split()] for j in range(N)]
l_a = []
k_1 = list(range(1,N+1))
for i in itertools.combinations_with_replacement(k_1, N):
    l_a.append(list(set(i)))
l_a = list(map(list, set(map(tuple, l_a))))
l_v = float('inf')
f_1 = False
for ls in l_a:
    ls = list(set(ls))
    ans = [0] * M
    val = 0
    for a in ls:# a = [1,2]ながさM
        for ix,i in enumerate(l[a-1][1:]):
            ans[ix] += i
        val += l[a-1][0]
    b = [i for i in ans if i >= X]
    if len(b) == len(ans):
        l_v = min(l_v, val)
        f_1 = True
if f_1:
    print(l_v)
else:
    print(-1)

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

void solveA(){
  string s;
  cin >> s;

  int m=10*(s[5]-48) + s[6] -48;
  int d=10*(s[8]-48) + s[9] -48;

  if(m<=4 && d<=30){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }
}
void solveB(){

}
void solveC(){

  
}

void solveD(){
}

int main(){
  solveA();
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll str_cnt(str s){
  map<char,ll> mp;
  REP(i,s.length()){
    mp[s[i]]++;
  }
  return mp.size();
}

int main(){
  ll n;
  cin >> n;
  str s;
  cin >> s;
  ll ans = 0;
  REP(i,n-1){
    str s1 = s.substr(0,i+1);
    str s2 = s.substr(i+1);
    ll cnt = 0;
    for(char f = 'a'; f <= 'z'; f++){
      if(s1.find(f)!=string::npos&&s2.find(f)!=string::npos) cnt++;
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
double l;
double t[500010],v[500010];

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

  cin>>n>>l;
  rep(i,n)cin>>t[i]>>v[i];

  deque<P> deq;
  deq.push_back(P(t[0],v[0]));
  printf("%.10f\n", t[0]);
  double crtsum=t[0]*v[0],crtv=v[0];
  repl(i,1,n){
    deq.push_back(P(t[i],v[i]));
    crtsum+=t[i]*v[i]; crtv+=v[i];
    while(crtv>l){
      double rmv=crtv-l;
      if(deq.front().se<rmv){
        crtsum-=deq.front().fi*deq.front().se;
        crtv-=deq.front().se;
        deq.pop_front();
      }else{
        crtsum-=deq.front().fi*rmv;
        deq.front().se-=rmv;
        crtv=l;
      }
    }
    while(deq.size()>=2&&deq[deq.size()-2].fi>deq[deq.size()-1].fi){
      P p1=deq.back(); deq.pop_back();
      P p2=deq.back(); deq.pop_back();
      deq.push_back(P((p1.fi*p1.se+p2.fi*p2.se)/(p1.se+p2.se),p1.se+p2.se));
    }
    printf("%.10f\n", crtsum/l);
  }

  return 0;
}


Measured memory_bytes: 26512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n, p[114514];
	scanf("%d", &n);
	rep (i, n)
		scanf("%d", p + i);
	
	int dp[114514];
	fill_n(dp, n, -1);
	dp[0] = 0;
	queue<int> q;
	q.push(0);
	while (dp[n - 1] < 0)
	{
		int cur = q.front(); q.pop();

		for (int i = 1; i <= 6; ++i)
		{
			int to = min(n - 1, cur + i);
			while (true)
			{
				if (dp[to] < 0)
					dp[to] = dp[cur] + 1;
				else
				{
					to = -1;
					break;
				}

				if (p[to])
					to += p[to];
				else
					break;
			}
			if (to >= 0)
				q.push(to);
		}
	}
	printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	int a,b,sum=0;
	scanf("%d %d",&a,&b);
	sum+=(a+b);
	if(sum>=10)
	{
		printf("error\n");
	}
	else
	{
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 20 20:53:47 2019

@author: ctiuser
"""


N = int(input())
A = list(map(int,input().split()))

counta = 0
Ans = [0 for i in range(N)]
ans = []
for i in range(N,0,-1):
    tmp = N // i
    res = A[i-1]
    for j in range(tmp):
        res ^= Ans[(j+1)*i-1]
    if res == 1:
        Ans[i-1] = 1
        ans.append(i)
        counta += 1

ans.reverse()

print(counta)
if counta > 0:
    print(' '.join(map(str,ans)))


Measured memory_bytes: 19904
A,B=gets.split.map &:to_i
x=0;
def getnum(a,i)
    flr=(a+1)/(2**(i+1))*2**(i+1)-1
    c=a-flr-2**i
    if c<0 then c=0 end
    c+=(flr+1)/2
    return c
end
50.times{|i|
    b=getnum(B,i)
    a=getnum(A-1,i)
    if (b-a)[0]==1 then x+=2**i end
}
p x

Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int main() {
	int n;
	scanf("%d",&n);
	printf("%d\n",n*(n-1)/2-n/2);
	if(n&1)
	{
		fup(i,1,n,1)fup(j,i+1,n,1)if(i+j!=n)printf("%d %d\n",i,j);
		return 0;
	}
	else
	{
		fup(i,1,n,1)fup(j,i+1,n,1)if(i+j!=n+1)printf("%d %d\n",i,j);
		return 0;
	}
}

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

//I am fucking stupid
//Stupidity level  -> 1/0


const int MAXN  = 101010;
vector<int>v1[MAXN];
int gr[MAXN];

void DFS(int x,int par)
{
    for(auto itr : v1[x])
    {
        if(itr!=par)
        {
            DFS(itr, x);
            gr[x]^=(gr[itr]+1);
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
        int n;
        cin>>n;
        for(int i = 0 ;i<MAXN;i+=1){
            v1[i].clear();
            gr[i] = 0;
        }
        for(int i = 1;i<=n-1;i+=1)
        {
            int x,y;
            cin>>x>>y;
            v1[x].push_back(y);
            v1[y].push_back(x);
        }
        DFS(1, -1);
        if(gr[1]==0)
        {
            cout<<"Bob"<<endl;
        }
        else{
            cout<<"Alice"<<endl;
        }
    
    return 0;
    
}




Measured memory_bytes: 12416
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  out(nin()<1200?'ABC':'ARC')
}
main()

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

int popcount(unsigned int bit, int n){
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        if(bit & (1<<i))count++;
    }
    return count;
}

vector<unsigned int> perm(unsigned int a, unsigned int b, unsigned int n){
    if(n <= 1){
        vector<unsigned int> d(2);
        d.at(0) = a; d.at(1) = b;
        return d;
    }
    else {
    int x = 0;
    while(!((a ^ b) & (1<<x)))x++;

    unsigned int s = ((a>>(x+1))<<x) | ((x>0)? ((a<<(32-x))>>(32-x)):0);
    unsigned int t = ((b>>(x+1))<<x) | ((x>0)? ((b<<(32-x))>>(32-x)):0);

    unsigned int c = s ^ 1;

    vector<unsigned int> q(1<<(n-1));
    q = perm(s, c, n-1);
    vector<unsigned int> r(1<<(n-1));
    r = perm(c, t, n-1);
    vector<unsigned int> ans(1<<n);

    for(int i = 0; i < (1<<n); i++)
    {
        if(i < (1<<(n-1))){
            ans.at(i) = ((q.at(i)>>x)<<(x+1)) | ((x>0)? ((q.at(i)<<(32-x))>>(32-x)):0) | (a & (1<<x));
        }
        else{
            ans.at(i) = ((r.at(i-(1<<(n-1)))>>x)<<(x+1)) | ((x>0)?((r.at(i-(1<<(n-1)))<<(32-x))>>(32-x)):0) | (b & (1<<x));
        }
    }
    return ans;
    }
}

int main() {
    unsigned int N, A, B;
    cin >> N >> A >> B;

    int n = popcount(A ^ B, N);

    if(n%2 == 0)cout << "NO\n";
    else{
        vector<unsigned int> ans(1<<N);
        ans = perm(A, B, N);

        cout << "Yes\n";
        for(int i = 0; i < (1<<N); i++)
        {
            cout << ans.at(i) << ' ';
        }

        cout << '\n';
        
    }

}

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


int cmp(const void* p, const void* q) {
	return *(char*)p - *(char*)q;
}

int cmp2(const void* p, const void* q) {
	return *(char*)q - *(char*)p;
}

int main(void) {
	char s[110], t[110];

	scanf("%s", s);
	scanf("%s", t);

	qsort(s, strlen(s), sizeof(char), cmp);
	qsort(t, strlen(t), sizeof(char), cmp2);
	if (strcmp(s, t) < 0)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, n);
	multiset<double> vls;
	REP(i, 0, n) {
		int v;
		cin >> v;
		vls.insert(1.0 * v);
	}

	while (vls.size() > 1) {
		auto it = vls.begin();
		double m = (*it + *(++it)) / 2.0;
		vls.erase(vls.begin(), ++(++vls.begin()));
		vls.insert(m);
	}

	cout << *(vls.begin()) << endl;
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A [] = new int [N];
	    
	    for(int i = 0; i < N; i++) {
	    	A[i]=sc.nextInt();
	    }
	    sc.close();
	    Arrays.sort(A);
	    
	    int total = 0;
	    for(int i = 0; i < N-1; i++) {
	    	total+=A[i];
	    }
	    System.out.println(total+A[N-1]/2);

	}

}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,D,ans=0;
	cin>>N>>D;
	vector<vector<ll>> X(N,vector<ll>(D));
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			cin>>X[i][j];
		}
	}
	for(int i=0;i<N;i++){
		for(int j=i;j<N;j++){
			if(i==j) continue;
			ll tmp=0;
			for(int k=0;k<D;k++){
				tmp+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}
			//tmp判別
			for(int l=0;l<=300;l++){
				ll tmp2=l*l;
				if(tmp==tmp2) ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 5;

ll n;
ll a[mx][3];
ll dp[mx][3];

ll fn(ll i, ll j)
{
	if(dp[i][j] != -1)
		return dp[i][j];
	if(i == n)
		return a[i][j];
	if(i > n)
		return -1e18;
	ll res = -1e18;
	for(ll k=0; k<=2; k++)
	{
		if(k == j)
			continue;
		ll m = fn(i+1, k) + a[i][j];
		res = max(res, m);
	}
	return dp[i][j] = res;
}

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

	cin >> n;
	for(ll i=1; i<=n; i++)
	{
		for(ll j=0; j<=2; j++)
		{
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof dp);
	//cout << fn(1, 0) << " " << fn(1, 1) << " " << fn(1, 2) << "\n";
	cout << max(fn(1, 0), max(fn(1, 1), fn(1, 2))) << "\n";
	return 0;
}


Measured memory_bytes: 11264
//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define fi first
#define se second
#define int long long
using namespace std;

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x * f;
}

///------------------head------------------
signed main(signed argc, char *argv[]){
	int T=read();
	while(T--){
		int A=read(),B=read(),C=read(),D=read();
		if (A < B) {puts("No"); continue;}
		A %= B;
		if (A > C) {puts("No"); continue;}
		if (B > D) {puts("No"); continue;}
		//printf("%lld %lld %lld %lld",A,B,C,D);
		int G = __gcd(B,D);
		int k = B/G-1,a = A % B;
		if ((a+((B-a-1)/G)*G) % B > C)
		{puts("No"); continue;}
		else
		{puts("Yes"); continue;}
	}
	return 0;
}

/* Examples: */
/*

*/

/*

*/


Measured memory_bytes: 256
#include <stdio.h>

int main (void) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    int cnt = 0, money = b;
    while ( money >= a && cnt < c ) {
        money -= a;
        cnt++;
    }

    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n;
    vector<vector<int>> c(100010);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        c[a].push_back(i);
    }
    cin >> m;
    vector<vector<int>> edge(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<int> num(n);
    vector<int> adjmax(n);
    for (int i = 0; i < 100010; ++i) {
        if (!c[i].size()) continue;
        bool f = true;
        while (f) {
            for (int a : c[i]) {
                adjmax[a] = max(adjmax[a], num[a] - 1);
                for (int b : edge[a]) {
                    adjmax[a] = max(adjmax[a], num[b] - 1);
                    adjmax[b] = max(adjmax[b], num[a] - 1);
                }
            }

            f = false;
            for (int a : c[i]) {
                for (int b : edge[a]) {
                    if (num[a] < adjmax[b] + 1) {
                        f = true;
                        num[a] = adjmax[b] + 1;
                    }
                }
            }
        }
        for (int a : c[i]) {
            adjmax[a] = max(adjmax[a], num[a]);
            for (int b : edge[a]) {
                adjmax[a] = max(adjmax[a], num[b]);
                adjmax[b] = max(adjmax[b], num[a]);
            }
        }
    }
    long long ans = 0;
    for (int i : num) ans += max(i, 1);
    cout << ans << "\n";
    return 0;
}



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

int n;

template <typename T>
void print(vector<T> vec)
{
    int n = vec.size();
    for (int i = 0; i < n; i++)
    {
        cout << vec[i] << (i == n - 1 ? "\n" : " ");
    }
}

#include <vector>

//cnt:sawpの回数
template <typename T>
void selectionSort(vector<T> &A, int &cnt)
{
    int n = A.size();
    cnt = 0;
    for (int i = 0; i < n; i++)
    {
        int minj = i;
        for (int j = i; j < n; j++)
        {
            if (A[j] < A[minj])
                minj = j;
        }
        if (A[i] != A[minj])
        {
            cnt++;
            swap(A[i], A[minj]);
        }
    }
}

int main()
{
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        cin >> A[i];
    int c = 0;
    selectionSort(A, c);
    print(A);
    cout << c << endl;
}


Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>

using ll = long long;

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

    std::sort(a.begin(), a.end(), std::greater<ll>());
    std::priority_queue<ll> queue;
    queue.push(a[0]);
    ll ans = 0;
    for(int i = 1; i < n; i++){
        ll top = queue.top();
        queue.pop();
        ans += top;
        queue.push(a[i]);
        queue.push(a[i]);
    }

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


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

int main(){
    int a;  cin>>a;
    int ans=0;
    for(int i=1;i<=a;i+=2){
        int count=0;

        for(int j=1;j<=i;j++){
            if(i%j==0)count++;
        }

        if(count==8)ans++;
    }

    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, M = in_nn()
    X = sorted(in_nl())

    X_diff = [0] * (M - 1)
    for i in range(M - 1):
        X_diff[i] = X[i + 1] - X[i]

    X_diff.sort(reverse=True)
    # print(X_diff)
    # print(X)
    N = min(N, M)
    ans = X[-1] - X[0] - sum(X_diff[:N - 1])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    ll fx = 0;
    ll t = n;
    while(t > 0) {
        fx += t % 10;
        t /= 10;
    }
    if (n % fx == 0)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 0;
    REP (i, 0, s.size()) {
        if (s[i] == 'o')  {
            cnt++;
        }
    }
    cout << (15 - s.size() + cnt >= 8 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
/*					                                
                                     *                             *
                                      *             * * * * * * * *
                                      *             *
                                      *             *
                                      *             *
                                      *             *
                                      *             *
                                      *             *
                                      * * * * * * * * * * * * * * *
                                                    *             *
                                                    *             *
                                                    *             *
                                                    *             *
                                                    *             *
                                                    *             *
                                      * * * * * * * *             *
                                     *                             *                             
*/
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
	public static int dp[][]=new int[100002][3];
	public static int happiness(int arr[][],int n,int m) {
		/*if(n==0) {
			if(m==0) 
				return Main.dp[0][0];
			else if(m==1)
				return Main.dp[0][1];
			else
				return Main.dp[0][2];
		}*/
		if(dp[n][m]!=-1) {
			return Main.dp[n][m];
		}
		else if(m==0) {
			Main.dp[n][m]=arr[n][0]+Math.max(Main.happiness(arr, n-1, 1),Main.happiness(arr, n-1, 2));
			return dp[n][m];
		}
		else if(m==1) {
			Main.dp[n][m]=arr[n][1]+Math.max(Main.happiness(arr, n-1, 0),Main.happiness(arr, n-1, 2));
			return dp[n][m];
		}
		else {
			dp[n][m]=arr[n][2]+Math.max(Main.happiness(arr, n-1, 0),Main.happiness(arr, n-1, 1));
			return dp[n][m];
		}
	}
	public static void main(String []args) {
		for(int i=0;i<100002;i++) {
			for(int j=0;j<3;j++) {
				Main.dp[i][j]=-1;
			}
		}
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int arr[][]=new int[N][3];
		for(int i=0;i<N;i++) {
			arr[i][0]=sc.nextInt();
			arr[i][1]=sc.nextInt();
			arr[i][2]=sc.nextInt();
		}
		Main.dp[0][0]=arr[0][0];
		Main.dp[0][1]=arr[0][1];
		Main.dp[0][2]=arr[0][2];
	    int x=Main.happiness(arr,N-1,0);
	    int y=Main.happiness(arr,N-1,1);
	    int z=Main.happiness(arr,N-1,2);
		System.out.println(Math.max(x,Math.max(y, z)));
		sc.close();
	}
}


Measured memory_bytes: 84028
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    string A,B;
    cin>>A>>B;
    cout<<B<<A<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  for(int i=0;i<4;i++){
    cin >> a >> b;
    if(a == 1) cout << 6000*b << endl;
    if(a == 2) cout << 4000*b << endl;
    if(a == 3) cout << 3000*b << endl;
    if(a == 4) cout << 2000*b << endl;
  }
  return (0);
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
  pair<int,int> a[100000];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int s1,s2;
    cin>>s1>>s2;
    a[i]=make_pair(s1,s2);
  }
  sort(a,a+n);
  for (int i=0;i<n;i++){
    cout<<a[i].first<<" "<<a[i].second<<endl;;
  }
  
  return 0;
}


Measured memory_bytes: 3836
using System;
class Program{
	static void Main(){
		int[] b=new int[100001];
		int[] h=new int[100001];
		for(int i=2;i<100001;i++){
			if(b[i]==0){
				for(int j=i*2;j<100001;j+=i){b[j]=-1;}
			}
			b[i]++;
			h[i]=(b[i]&b[(i+1)/2])+h[i-1];
		}

		int n=int.Parse(Console.ReadLine());
		for(int i=0;i<n;i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			Console.WriteLine("{0}",h[q[1]]-h[q[0]-1]);
		}
	}

}

Measured memory_bytes: 18244
use std::io;
use std::io::prelude::*;
use std::io::BufReader;

fn main() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let hwk: Vec<usize> = x
        .trim_end()
        .split(' ')
        .map(|s| s.parse().unwrap())
        .collect();
    let h = hwk[0];
    let w = hwk[1];
    let k = hwk[2];
    let mut b: [[usize; 6]; 6] = Default::default();
    let lines = BufReader::new(io::stdin()).split(b'\n').into_iter();
    for (row, line) in b.iter_mut().zip(lines) {
        for (cell, x) in row.iter_mut().zip(line.unwrap()) {
            if x == b'#' {
                *cell = 1;
            }
        }
    }
    let mut ans = 0;
    for i in 0..1 << h {
        for j in 0..1 << w {
            let mut cnt = 0;
            for r in 0..h {
                if (i >> r) & 1 == 0 {
                    for c in 0..w {
                        if (j >> c) & 1 == 0 {
                            cnt += b[r][c];
                        }
                    }
                }
            }
            if cnt == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2148
#include<stdio.h>
int main()
{
    int A, B, C, X, Y, min, max, money=0, min_money=0, i;
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
    if(X>Y)
        max=X;
    else
        max=Y;
    for(i=0; i<max+1; i++)
    {
        money=0;
        money=money+i*2*C;
        if((X-i)>0)

            money=money+A*(X-i);

        if((Y-i)>0)

            money=money+B*(Y-i);

        if(i==0)

            min_money=money;

        if(money<min_money)

            min_money=money;

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


Measured memory_bytes: 128
import Control.Applicative

main :: IO ()
main = do
  [k, _] <- f
  solve k <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> [Int] -> Int
solve k as = k - maximum ((k - sum ds) : ds)
  where
    ds = (tail >>= zipWith (-)) as


Measured memory_bytes: 66940
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define ep emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  int ans = 0;

  rep(i, n) {
    int x; cin >> x;
    ans += min(x, k - x) * 2;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K, X = 0;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {cin >> p.at(i);}
  sort(p.begin(), p.end());
  for (int i = 0; i < K; i++) {X += p.at(i);}
  cout << X << endl;
}

Measured memory_bytes: 3616