akhauriyash/Code-Regression huggingface dataset:
// std::set を用いた解
#include <iostream>
#include <map>
using namespace std;

int main() {
  int N,M,way1,way2;
  cin >> N >> M;
  map<int,int> cities;
  for(int i=1;i<N+1;i++) cities[i]=0;
  for(int i=0;i<M;i++){
    cin >> way1 >> way2;
    cities[way1]++;
    cities[way2]++;
  }
  for(int i=1;i<N+1;i++){
    cout << cities[i] << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
  int n = F / (100*A);
  int m = F / (100*B);
  double per = 0;
  int ansAC = 100*A;
  int ansC = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      int p = (i*A + j*B) * E / C;
      int q = (i*A + j*B) * E / D;
      for (int k = 0; k <= p; k++) {
        for (int l = 0; l <= q; l++) {
          if (100*A*i + 100*B*j + C*k + D*l > F) continue;
          if ((i*A + j*B) * E < C*k + D*l) continue;
          if (double((k*C+l*D)*100) / double(100*(i*A+j*B)+(k*C+l*D)) > per) {
            per = double((k*C+l*D)*100) / double(100*(i*A+j*B)+(k*C+l*D));
            ansAC = 100*(i*A+j*B)+(k*C+l*D);
            ansC = (k*C+l*D);
          }
        }
      }
    }
  }
  
  cout << ansAC << " " << ansC << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
int gcd(int x, int y) {
	if (y == 0)return x;
	else return gcd(y, x%y);
}
using namespace std;
ll a[35]; ll b[35][35]; ll c[35];
signed main() {
	ll n, m, ans = 0;
	cin >> n >> m;
	rep(i, n){
      cin >> a[i];
		for (int k = 0; k < a[i]; k++) {
			cin >> b[i][k];
        }
    }
	rep(i, m)c[i] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < a[i]; j++) {
			c[b[i][j] - 1]++;
		}
	}
	rep(i, m) {
		if (c[i] == n)ans++;
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
 
vector<ll> divisor(ll a){
    vector<ll> res;
    for(ll i=2; i<=sqrt(a); i++){
        if(a%i==0){
            res.push_back(i);
            if(i!=a/i) res.push_back(a/i);
        }
    }
    res.push_back(a);
    sort(all(res));
    return res;
}


int main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    int sum=0;
    rep(i,n){
        cin >> a[i];
        sum+=a[i];
    }

    vector<ll> p=divisor(sum);
    reverse(all(p));

    rep(i,p.size()){
        vector<ll> moda;
        rep(j,n){
            if(a[j]%p[i]) moda.push_back(a[j]%p[i]);
        }
        int ms=moda.size();
        if(!ms){
            cout << p[i] << endl;
            return 0;
        }
        sort(all(moda));
        vector<ll> rmoda(ms+1);
        rmoda[0]=0;
        rep(j,ms) rmoda[j+1]=p[i]-moda[j]+rmoda[j];
        ll now=0;
        rep(j,ms){
            now+=moda[j];
            if(now==rmoda[ms]-rmoda[j+1]){
                if(now<=k){
                    cout << p[i] << endl;
                    return 0;
                }
                break;
            }
            else if(now>rmoda[ms]-rmoda[j+1]) break;
        }
    }
    cout << 1 << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) 
{
    ll h, w;
    cin >> h >> w;
    
    vs stg(h+2);
    rep(i, w+2) {
        stg[0] += ".";
        stg[h+1] += ".";
    }
    string s;
    rrep(i, h) {
        cin >> s;
        stg[i] = "." + s + ".";
    }
    
    ll cnt = 0;
    rrep(i, h) {
        rrep(j, w) {
            if (stg[i][j] != '#') {
                if (stg[i-1][j-1] == '#') cnt++;
                if (stg[i-1][j] == '#') cnt++;
                if (stg[i-1][j+1] == '#') cnt++;
                
                if (stg[i][j-1] == '#') cnt++;
                if (stg[i][j+1] == '#') cnt++;
                
                
                if (stg[i+1][j-1] == '#') cnt++;
                if (stg[i+1][j] == '#') cnt++;
                if (stg[i+1][j+1] == '#') cnt++;
                cout << cnt;
            } else {
                cout << "#";
            }
            
            cnt = 0;
            
        }
        cout << endl;
    }
    
    
   
    
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int calc(int n){
    if(n % 4 == 0) return n;
    else if(n % 4 == 1) return 1;
    else if(n % 4 == 2) return n + 1;
    return 0;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = calc(a - 1);
    ans ^= calc(b);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>



int main(void){
    int a,b;
    char op;
    
    while(1){
    
        scanf("%d %c %d",&a,&op,&b);
    
        if(op=='+'){
            printf("%d\n",a+b);
        }else if(op=='-'){
            printf("%d\n",a-b);
        }else if(op=='*'){
            printf("%d\n",a*b);
        }else if(op=='/'){
            printf("%d\n",a/b);
        }else{
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-9;

// 内積 |a||b|cosθ
double dot(Point a, Point b){
	// return a.real() * b.real() + a.imag() * b.imag();
	return (conj(a) * b).real();
}
// 射影　直線に点pを投影　点pから直線に下ろした垂線の足
Point projection(Line l, Point p){
    Point a = l.first, b = l.second, c = p;
    double t = dot(p - a, b - a) / norm(b - a); 
    return a + t * (b - a);
}

int main(){
    double x, y;
    Point p1, p2;
    cin >> x >> y;
    p1 = {x, y};
    cin >> x >> y;
    p2 = {x, y};
    Line l = {p1, p2};
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> x >> y;
        Point c = {x, y};
        Point res = projection(l, c);
        printf("%.10f %.10f\n", res.real(), res.imag());
    }
}


Measured memory_bytes: 3344
#include<stdio.h>
int main(void)
{
	int m,f,b,w,x;
	scanf("%d %d %d",&m,&f,&b);
	w=b-m;
	if(w<=0){
		printf("0\n");
	}
	else{
		if(w<=f){
			printf("%d\n",w);
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

struct unionfind{
	int par[200000],sz[200000];
	void init(int N){rep(i,N) par[i]=i,sz[i]=1;}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		par[y]=x;
		sz[x]+=sz[y];
	}
}u1,u2;

typedef pair<int,int> P;
map<P,int> mp;
P rs[200000];
int main(){
	int N,A,B;
	cin>>N>>A>>B;
	u1.init(N);u2.init(N);
	rep(i,A){
		int a,b;
		cin>>a>>b;
		a--,b--;
		u1.unite(a,b);
	}
	rep(i,B){
		int a,b;
		cin>>a>>b;
		a--,b--;
		u2.unite(a,b);
	}
	rep(i,N) rs[i]=P(u1.find(i),u2.find(i));
	rep(i,N) mp[rs[i]]++;
	rep(i,N) cout<<mp[rs[i]]<<" ";
	puts("");
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int len = s.size();
  if(len <= n)
  {
    cout << s << endl;
  }else{
    cout << s.substr(0, n) << "..." << endl;
  }
}


Measured memory_bytes: 3576
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include<sstream>
#include <vector>
#include <set>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
const int N = 2e5 + 5;

 
  
 
int32_t  main() {

	IOS;
  
	int n;

	cin >> n; 

	vector<int> v(1000001);
	vector<int> cnt(n);
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;

		v[tmp]++;
		cnt[i] = tmp;
	} 
	vector<int> vis(1000001);
	int ans = 0;
	for (int i = 0; i <n; i++) {

		if (vis[cnt[i]] !=0 ) {
			vis[cnt[i]] = 2;
			continue;
		}

		for (int j = cnt[i]; j <= 1000000; j += cnt[i]) {
			vis[j]++;
		}

	}

	for (int x : cnt) {

		if (vis[x] == 1) {
			ans++;
		}

	}
	cout << ans << endl;
}

Measured memory_bytes: 20044
#include <stdio.h>

int
main(void)
{
        int amount;
        int coin_25 = 0;
        int coin_10 = 0;
        int coin_5 = 0;
        int coin_1 = 0;

        scanf("%d", &amount);

        coin_25 = amount / 25;
        amount = amount % 25;
        coin_10 = amount / 10;
        amount = amount % 10;
        coin_5 = amount / 5;
        amount = amount % 5;
        coin_1 = amount;

        printf("%d\n", coin_25 + coin_10 + coin_5 + coin_1);

        return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
 
bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV]; // max length of path from v
int dfs(int v) {
  if (visited[v]) {
    if (!calculated[v]) return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  for (int u : to[v]) {
    int res = dfs(u);
    if (res == -1) return -1;
    dp[v] = max(dp[v], res+1);
  }
  calculated[v] = true;
  return dp[v];
}
 
int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n-1));
  
  int V = 0;
  rep(i,n)rep(j,n) {
    if (i < j) {
      id[i][j] = V++;
    }else if(i > j){
      id[i][j] = id[j][i];
    }
  }
  rep(i,n) {
    rep(j,n-1) {
      cin >> a[i][j];
      a[i][j]--;
      a[i][j] = id[i][a[i][j]];
    }
  }
  
  rep(i,n) {
    
    rep(j,n-2) {
      to[a[i][j+1]].push_back(a[i][j]);
    }
  }
  int ans = 0;
  rep(i,V) {
    int res = dfs(i);
    if (res == -1) {
      puts("-1");
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 38528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n ;
    ll sum = 0;

    cin >> n;

    ll a[n];
    ll x[n];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }

    ll temp = sum;
    for(ll i = 1; i < n; i+=2){
        temp = temp - 2 * a[i];
    }

    x[0] = temp;

    cout << x[0] << " ";

    for(ll i = 0; i < n - 1; i++){
        x[i+1] = 2*a[i] - x[i];
        cout << x[i+1] << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll N, K;
ll a[1111];
vector<ll> cand;

// 渡されたbitを含む部分列の個数をカウントする
ll countMask(ll a) {
	ll ret = 0;
	for (ll x : cand) {
		if ((x & a) == a) { // これ頭良い
			ret++;
		}
	}
	return ret;
}

int main() {
	// 入力
	cin >> N >> K;
	for (ll i = 0; i < N; i++) {
		cin >> a[i];
	}

	// 部分列全列挙
	for (ll i = 0; i < N; i++) {
		ll sum = 0;
		for (ll j = i; j < N; j++) {
			sum += a[j];
			cand.push_back(sum);
		}
	}

	sort(cand.begin(), cand.end());
	reverse(cand.begin(), cand.end());

	ll mask = 0; // これが答えになる。条件を満たすbitをここに付け加えてく
	for (ll i = 40; i >= 0; i--) {
		if (countMask(mask | (1LL << i)) >= K) {
			mask |= (1LL << i);
		}
	}

	cout << mask << endl;

	return 0;
}


Measured memory_bytes: 6384
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


from collections import deque

def main():
    print(Yes if ii()>=30 else No)


main()



Measured memory_bytes: 9972
#include<algorithm>//sort,二分探索,など
//#include<bitset>//固定長bit集合
#include<climits>
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#define CO(a, b, c) ((a)?(b):(c))
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;
typedef long long ll;

int main(void)
{
	
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> book(n, vector<int>(m));
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++)
		{
			cin >> book[i][j];
		}
	}
	int ans = INT_MAX;
	bool flg = false;
	for (int bit = 0; bit < (1<<n); ++bit)
	{
		vector<int> und(m, 0), buy;
		int tmp = 0;

		for (int i = 0; i < n; ++i)
		{
			if (bit & (1<<i))
			{
				tmp += c[i];
				for (int j = 0; j < m; j++)
				{
					und[j] += book[i][j];
				}
			}
		}
		if (*min_element(und.begin(), und.end()) >= x)
		{
			flg = true;
			ans = min(ans, tmp);
			int sum = 0;
			for (auto &&i : buy)
			{
				sum += c[i];
			}
		}
	}
	
	cout << (flg?ans:-1) << endl;
	

	return 0;
	
}

Measured memory_bytes: 3604
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class Edge
{
public:
    int to, index;
    Edge(int to, int index){
        this->to = to;
        this->index = index;
    }
};

int solve(const vector<vector<Edge> >& edges, int curr, vector<int>& color, int prevColor)
{
    int ans = 0;
    int cnt = 0;
    for(const Edge& e : edges[curr]){
        ++ cnt;
        if(cnt == prevColor)
            ++ cnt;
        color[e.index] = cnt;
        ans = max(ans, solve(edges, e.to, color, cnt));
    }
    ans = max(ans, cnt);
    return ans;
}

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

    vector<int> color(n-1);
    cout << solve(edges, 0, color, 0) << endl;
    for(int i=0; i<n-1; ++i)
        cout << color[i] << endl;

    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <cmath>
#include<iomanip>
struct Point
{
    double x ;
    double y ;


    Point( double x = 0 , double y = 0 )
        : x(x) , y(y) 
    {
    }

    void print()
    {
        std::cout << std::fixed << std::setprecision(10) << x << " " << y << std::endl ;
    }

} ;

void makeKoch( Point firstp , Point lastp, int n )
{
    if( n == 0 )
    {
        return  ;
    }

    Point s, u, t ;
    //ごちゃごちゃした計算
    s.x = ( 2*firstp.x + lastp.x ) / 3 ;
    s.y = ( 2*firstp.y + lastp.y ) / 3 ;
    t.x = ( firstp.x + 2*lastp.x ) / 3 ;
    t.y = ( firstp.y + 2*lastp.y ) / 3 ;

    u.x = ( t.x - s.x ) * std::cos( M_PI / 3 ) - ( t.y - s.y ) * std::sin( M_PI / 3 ) + s.x ;
    u.y = ( t.x - s.x ) * std::sin( M_PI / 3 ) + ( t.y - s.y ) * std::cos( M_PI / 3 ) + s.y ;

    makeKoch( firstp , s, n-1 ) ;
    s.print() ;
    makeKoch( s, u, n-1 ) ;
    u.print() ;
    makeKoch( u, t, n-1 ) ;
    t.print() ;
    makeKoch( t, lastp, n-1 ) ;
}

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

    Point firstp( 0, 0 ) ;
    Point lastp( 100, 0 ) ;

    firstp.print() ;
    makeKoch( firstp , lastp , n ) ;
    lastp.print() ;

}



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

int main() {
  int h, w;
  std::cin >> h >> w;

  int c[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      std::cin >> c[i][j];
    }
  }
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        for (int k = 0; k < 10; k++) {
          if (c[i][k] + c[k][j] < c[i][j]) {
            flag = true;
            c[i][j] = c[i][k] + c[k][j];
          }
        }
      }
    }
  }

  int64_t count = 0;

  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      int t;
      std::cin >> t;
      if (t != -1) {
        count += c[t][1];
      }
    }
  }

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

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

using namespace std;

int main() {
    string A, B; cin >> A >> B;
    int len = max(A.size(), B.size());
    while (A.size() < len) A = "0" + A;
    while (B.size() < len) B = "0" + B;
    if (A < B) cout << "LESS" << endl;
    else if (A > B) cout << "GREATER" << endl;
    else cout << "EQUAL" << endl;
}


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

res = 1
exceeded = False
thresh = 10 ** 18
for a in [int(v) for v in input().split()]:
    if not exceeded:
        res *= a
        if res > thresh:
            exceeded = True
    elif a == 0:
        res = 0
        exceeded = False

if exceeded:
    print(-1)
else:
    print(res)


Measured memory_bytes: 85000
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            tmp = A[i]
            A[i] = A[j]
            A[j] = tmp
    tmp = A[i+1]
    A[i+1] = A[r]
    A[r] = tmp
    return i+1
    
n = int(input())
A = list(map(int, input().split()))

p = partition(A, 0, n-1)
A = ["[" + str(A[i]) + "]" if i == p else str(A[i]) for i in range(n)]
print(*A)


Measured memory_bytes: 16392
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head

int x,t,q,m,n,c,res;
int a[200010] = {};
int b[200010] = {};
vector<PII> g[500010];
queue<int> que2;
ll dp[2020][2020]={};
//string s;

signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
	std::cin >>n;
	rep(i,0,n){
		std::cin >> a[i];
		b[a[i]] = i+1;
	}
	set<int> s;
	set<int>sr;
  s.insert(0);
  s.insert(n+1);
	sr.insert(0);
  sr.insert(-n-1);
	int ans=0;
	rep(i,1,n+1){
		int l=*sr.lower_bound(-b[i]);
		int r=*s.lower_bound(b[i]);
		ans+=i*(r-b[i])*(l+b[i]);
		s.insert(b[i]);
		sr.insert(-b[i]);
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 35072
#! /usr/bin/env python
# -*- coding: utf-8 -*-
def main():
    unko = raw_input()
    unko_ans = 0
    for i in range(3):
        if unko[i] == '1':
            unko_ans = unko_ans + 1
    print(unko_ans)
if __name__ == "__main__":
    main()

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

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

using namespace std;

struct Data {
  int x,y;
  bool operator < ( const Data &data ) const {
    return y < data.y;
  }
};

int n,m,a[100],b[100],correct[100],buf[100],mini;
vector<Data> kuji;

bool check1(){
  rep(i,m) rep(j,m) if( i != j ) {
    if( kuji[i].x == kuji[j].x && kuji[i].y == kuji[j].y ) return false;
    if( abs(kuji[i].x-kuji[j].x) == 1 && kuji[i].y == kuji[j].y ) return false;
  }
  return true;
}

void dfs(int cur,int hight){
  if( hight >= mini ) return;


  if( cur >= m ) {
    if( !check1() ) return;
    vector<Data> vec;
    rep(i,m) vec.push_back(kuji[i]);
    sort(vec.begin(),vec.end());
    rep(i,n) buf[i] = i;
    rep(i,m) swap(buf[vec[i].x],buf[vec[i].x+1]);
    bool success = true;
    rep(i,n) if( buf[i] != correct[i] ) { success = false; break; }
    if( success ) mini = hight;
    return;
  }
  rep(y,m){
    Data temp = kuji[cur];
    kuji[cur].y = y;
    dfs(cur+1,max(hight,y+1));
    kuji[cur] = temp;
  }
}

int main(){
  cin >> n >> m;
  int perm[n];
  int cnt[n];
  rep(i,n) cnt[i] = 0;
  rep(i,n) correct[i] = perm[i] = i;
  rep(i,m) { cin >> a[i]; --a[i]; swap(correct[a[i]],correct[a[i]+1]); ++cnt[a[i]]; }
  mini = m;
  rep(i,n) {
    int y = 0;
    rep(j,cnt[i]) kuji.push_back((Data){i,y++});
  }
  dfs(0,0);
  cout << mini << endl;
  return 0;
}

Measured memory_bytes: 1220
N, S = open(0).read().split()
#print(N, S)
S = list(S)
cnt=0
for i in range(len(S)):
    for j in range(i+1, len(S)):
        if S[i] == S[i+1]:
            S.pop(i+1)
        else:
            cnt += 1
            #print(cnt,S)
            break
print(len(S))

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

using namespace std;

#define ll long long 

int const N = 1e5 + 5;
ll const INF = 1e18L + 5;

ll W, t, memo[N], w[N], v[N], sum;

int main(){
	
	cin>>t>>W;
	
	memset(memo, INF, sizeof(memo));
	
	memo[0] = 0;
	
	for(int i = 0; i < t; ++i){
		cin>>w[i]>>v[i];
		sum += v[i]; 
	}
	
	for(ll i = 0; i < t; ++i){
		for(ll j = sum - v[i]; j >= 0; --j){
			memo[j + v[i]] = min(memo[j + v[i]], memo[j] + w[i]);
		}
	}
	
	ll ans = 0;
	
	for(ll i = 0; i <= sum; ++i)
		if(memo[i] <= W)
			ans = max(ans, i);
		
	cout<<ans;	
	
	return 0;
}


Measured memory_bytes: 4404
from collections import Counter
s = input()

def f(s, c):
    n = len(s)
    if not c in s:
        return n-1
    else:
        longest = 0
        last = -1
        i = 0
        while i < n:
            l = 0
            while i < n and s[i]!=c:
                l+=1 
                i+=1
            if i < n and s[i]==c:
                last = i
                longest = max(longest, l)
            i+=1
        return max(n-last-1, longest)

ans = float('inf')
for i in range(26):
    c = chr(ord('a')+i)
    ans = min(ans, f(s, c))
print(ans)

Measured memory_bytes: 3316
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
hash = Hash.new(0)
a.each do |i|
    hash[i] += 1
end
hash_2 = Hash.new(0)
arr = Array.new(n+1,0)
count = 0
hash.each do |i|
    ans =  (i[1] * (i[1] - 1)) / 2
    hash_2[i[0]] = ans
    count += ans
end
a.each do |j|
    point = hash_2[j]
    sa_1 = (hash[j] * (hash[j] - 1)) / 2
    sa_2 = ((hash[j]-1) * (hash[j] - 2)) / 2
    count = count - sa_1 + sa_2
    puts count
    count = count + (sa_1 - sa_2)
end

Measured memory_bytes: 43832
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
// typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int N;

struct P {
    double x,y;
};

vector<P> p;

double dist(P a,P b) {
    double dx = a.x - b.x;
    double dy = a.y - b.y;
    return sqrt(dx*dx+dy*dy);
}

double f(double x, double y) {
    double res = 0;
    rep(i,N) {
        res = max(res,dist((P){x,y},p[i]));
    }
    return res;
}

double g(double x) {
    double l = 0, r = 1000;
    rep(i,80) {
        double c1 = (2*l+r)/3;
        double c2 = (l+2*r)/3;
        if(f(x,c1) > f(x,c2)) l = c1;
        else r = c2;
    }
    return f(x,l);
}

int main() {
    cin>>N;
    p = vector<P>(N); 
    rep(i,N) cin>>p[i].x>>p[i].y;

    double l = 0, r = 1000;
    rep(i,80) {
        double c1 = (l*2+r)/3;
        double c2 = (l+2*r)/3;
        if(g(c1) > g(c2)) l = c1;
        else r = c2;
    }
    cout << fixed << setprecision(10) << g(l) << endl;
}

Measured memory_bytes: 3844
import sys
readline=sys.stdin.readline

X=int(readline())
if X < 600:
  print(8)
elif X < 800:
  print(7)
elif X < 1000:
  print(6)  
elif X < 1200:
  print(5)  
elif X < 1400:
  print(4)  
elif X < 1600:
  print(3)  
elif X < 1800:
  print(2)  
elif X < 2000:
  print(1)  

Measured memory_bytes: 9184
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n,k; cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(all(p));

    int ans = 0;

    rep(i,k){
        ans += p[i];
    }
    dunk(ans);
    return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
int main(void){
  int flag = 0;
  int count = 0;
  int nonber = 0;
  
  scanf("%d",&nonber);
  
  int a[nonber];
  
  for(int i=0;i<nonber;i++)
    scanf("%d",&a[i]);
  while(flag == 0){
    for(int i=0; i<nonber; i++){
      if(a[i]%2!=0) flag = 1;
      a[i]=a[i]/2;
    }
    if(flag == 1) break;
    count++;
  }
      
  printf("%d\n",count);
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  bool ans = false;
  rep(i,n){
    if(a[i]%2 == 0){
      if(a[i]%3 != 0){
        if(a[i]%5 != 0) ans = true;
      }
    }
  }
  if(ans == true) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#include <atcoder/all>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

int main() {
	int N, K;
	cin >> N >> K;
	segtree<int, op, e> seg(300001);
	int ans = 0;
	rep(i, N) {
		int a;
		cin >> a;
		int L = a - K;
		int R = a + K + 1;
		L = max(0, L);
		R = min(300001, R);
		int val = seg.prod(L, R) + 1;
		seg.set(a, val);
		ans = max(ans, val);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8580
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n, k = map(int, readline().split())
    p = list(map(int, readline().split()))
    p.sort()
    print(sum(p[:k]))


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int main() {
    int a, b; cin >> a >> b;
    cout << max(0, a - 2*b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    ll N;
    cin>>N;
    vector<ll> A(N, 0);
    vector<ll> B(N, 0);
    rep(i, N-1){
        cin>>A[i+1];
        A[i+1]--;
        B[A[i+1]]++;
    }
    rep(i, N){
        cout<<B[i]<<endl;
    }
}

Measured memory_bytes: 6428
using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    int N, K;
    int[] X, Y;
    char[] C;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        K = sc.NextInt();
        X = new int[N];
        Y = new int[N];
        C = new char[N];
        for (int i = 0; i < N; i++)
        {
            X[i] = sc.NextInt();
            Y[i] = sc.NextInt();
            C[i] = sc.NextChar();
        }
        int[,] imos = new int[3 * K + 1, 2 * K + 1];
        for (int i = 0; i < N; i++)
        {
            int my = K - Y[i] % K;
            int mx = K - X[i] % K;
            int dx = X[i] / K;
            int dy = Y[i] / K;
            var f = (dx % 2 == 1) ^ (dy % 2 == 1) ^ (C[i] == 'B');
            if (f) my += K;
            imos[my, mx]++;
            imos[my + K, mx]--;
            imos[my, mx + K]--;
            imos[my + K, mx + K]++;
        }

        for (int i = 0; i <= 3 * K; i++)
        {
            for (int j = 0; j < 2 * K; j++)
            {
                imos[i, j + 1] += imos[i, j];
            }
        }

        for (int i = 0; i < 3 * K; i++)
        {
            for (int j = 0; j <= 2 * K; j++)
            {
                imos[i + 1, j] += imos[i, j];
            }
        }
        int ans = 0;
        for (int i = 0; i < K; i++)
        {
            for (int j = 0; j < K; j++)
            {
                int a = imos[i, j] + imos[i + K, j + K] + imos[i + 2 * K, j];
                int b = imos[i, j + K] + imos[i + K, j] + imos[i + 2 * K, j + K];
                ans = Math.Max(ans, Math.Max(a, b));
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 39492
package main

import (
    //b "bufio"
    fm "fmt"
    //o "os"
    //s "strconv"
)

type OfficialHouse [4][3][10]int

func (of *OfficialHouse) UpdateInfo () {
	var b, f, r, v int
	fm.Scan(&b, &f, &r, &v)
	of[b-1][f-1][r-1] += v
}

func main() {
	var n int
	var ofh OfficialHouse
	fm.Scan(&n)

		for i := 0; i < n; i++ {
			ofh.UpdateInfo()
		}

		for i := 0; i < 4; i++ {
			for j := 0; j < 3; j++ {
				for k := 0; k < 10; k++ {
					fm.Printf(" %d",ofh[i][j][k])
				}
				fm.Println()
			}

			if i < 3 {
				fm.Println("####################")
			}
		}
}


Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+4);
	printf("%d\n",a[3]*10+a[2]+a[1]);
	return 0;
}

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

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

  if(S.size() != 26){
    map<char,int> m;
    for(char &c:S){
      m[c]++;
    }
    for(int i = 0; i <= S.size(); i++){
      if(m['a' + i] == 0){
        S += ('a' + i);
        break;
      }
    }
  }
  else{
    char maxc = 'a' - 1;

    for(int i = S.size() - 1; i >= 0; i--){
      if(maxc >= S.at(i)){
        string b = S.substr(i + 1);
        char minc = 'z'+1;
        for(char &c : b){
          if(S.at(i) < c)
            minc = min(c,minc);
        }
        S = S.substr(0,i) + minc;
        break;
      }
      maxc = S.at(i);
    }
    if(S.size() == 26)
      S = "-1";
  }

  cout << S << endl;
}

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, c, k;
  cin >> n >> c >> k;

  vector<int> t(n);
  rep(i, n) cin >> t.at(i);
  sort(t.begin(), t.end());

  int cnt = 1;
  int min_time = t.at(0);
  int canPassenger = c;
  for (int i = 0; i < n; i++) {
    if (canPassenger <= 0 || t.at(i) - min_time > k) {
      cnt++;
      min_time = t.at(i);
      canPassenger = c - 1;
    } else {
      canPassenger--;
    }
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 640
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split();
        var n = long.Parse(nm[0]);
        var m = long.Parse(nm[1]);

        var pairs = new Tuple<long, long>[n];
        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split();
            pairs[i] = Tuple.Create(
                long.Parse(ab[0]),
                long.Parse(ab[1]));
        }

        Array.Sort(pairs);

        var ans = 0L;
        for (int i = 0; i < n; i++)
        {
            var x = Math.Min(m, pairs[i].Item2);
            ans += pairs[i].Item1 * x;
            m -= x;
        }

        Console.WriteLine(ans);
    }
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool ispossible = false;

    for (int i = 1; i < B; i++) {
        if ((A*i - C)%B == 0) {
            ispossible = true;
            break;
        }
    }

    if (ispossible) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

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

    int h[n+1];
    rep(i, n)
        cin >> h[i];
    h[n] = 0;

    int count = 0, mi = 0;
    rep(i, n){
        if(i == 0){
            if(h[i] >= h[i+1]){
                count += h[i];
                mi = h[i];
            }
        }else if(h[i-1] <= h[i] && h[i] >= h[i+1]){
            count += h[i] - mi;
            mi = h[i];
        }else{
            mi = min(mi, h[i]);
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using data=pair<ll,ll>;
int main(){
ll i,n,m,a,b;
cin>>n>>m;
vector<data> l(n);
for(i=0;i<n;i++){
cin>>a>>b;
l[i]=data(a,b);
}
sort(l.begin(),l.end());
a=0;b=m;
for(i=0;i<n;i++){
a+=l[i].first*min(b,l[i].second);
b-=l[i].second;
if(b<=0)break;
}
cout<<a;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
const int MAXN=101;
int N;
long long L[MAXN];
int main(){
	cin>>N;
	L[1]=2;
	L[2]=1;
	for(int i=3;i<=N+1;i++) L[i]=L[i-1]+L[i-2];
	cout<<L[N+1]<<endl;
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    for(ll i = n - 1; i >= 0; --i){
        cout << a.at(i);
        if(i > 0){
            cout << ' ';
        }else{
            cout << endl;
        }
    }
}



Measured memory_bytes: 3116
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

constexpr int MOD = 998244353;

intmax_t power(intmax_t x, intmax_t n, const intmax_t M) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        intmax_t t = power(x, n / 2, M);
        return t * t % M;
    }
    return x * power(x, n - 1, M) % M;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<intmax_t> cnt(N + 5);
    for (size_t i = 0; i < N; ++i) {
        int d; cin >> d;
        if (i == 0 && d != 0) {
            cout << 0 << "\n";
            return 0;
        }
        cnt[d]++;
    }

    if (cnt[0] != 1) {
        cout << 0 << "\n";
        return 0;
    }

    intmax_t res = 1;
    for (size_t d = 1; d < N - 1; ++d) {
        if (cnt[d]) {
            res *= power(cnt[d], cnt[d + 1], MOD);
            res %= MOD;
        } else {
            if (cnt[d + 1]) {
                cout << 0 << "\n";
                return 0;
            }
        }
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 1024
N, M, X = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

cost = [0 for _ in range(N+1)]
for a in A:
    cost[a] = 1

cost_1 = 0
cost_2 = 0
for i in range(N+1):
    if i < X:
        cost_1 += cost[i]
    elif i > X:
        cost_2 += cost[i]

print(min(cost_1,cost_2))

Measured memory_bytes: 9104
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
int main(){
  int h1, m1, s1, h2, m2, s2;
  while(cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2){
    int tim = h2 * 3600 + m2 * 60 + s2 - h1 * 3600 - m1 * 60 - s1;
    cout << tim / 3600 << " " << tim % 3600 / 60 << " " << tim % 60 << endl;
  }
}
 

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w;
    cin>>n>>w;
    int val[n],wt[n];
    for(int i=0;i<n;i++){
    	cin>>wt[i]>>val[i];
    }
    ll int dp[n+1][w+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
    	for(int j=1;j<=w;j++){
    		if(wt[i-1]<=j){
    			dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
    		}
    		else{
    			dp[i][j]=dp[i-1][j];
    		}
    	}
    }
    cout<<dp[n][w];
    return 0;
}

Measured memory_bytes: 82452
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

	int a, b, c = 1;

	cin >> a >> b;

	cout << a - b + 1 << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define TASKNAME somethinghere

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

	//freopen("input.txt", "r", stdin);
	//freopen(TASKNAME".inp", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);

    ll n;
    cin >> n;
    map<ll, ll> m;
    for(ll i = 1; i <= n; i++) {
		ll x;
		cin >> x;
        m.insert({x, i});
    }
    for(pair<ll, ll> it: m) cout << it.second << ' ';
}

/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names
*/


Measured memory_bytes: 7040
#include<stdio.h>
char mark(int num);
int main(){
	int h, w;
	int i, j;
	while(1){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0)break;
		for(i = 0;i < h;i++){
			for(j = 0;j < w;j++){
				printf("%c", mark(i + j));
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

char mark(int num){
	if(num%2==0){
		return '#';
	}
	else{
		return '.';
	}
}


Measured memory_bytes: 2040
from math import *
PI = 3.1415926535898
ans = 0
while True:
    try:
        s = raw_input()
        t = ""
        for x in s:
            if x.isdigit():
                t += x
            elif len(t) > 0 and t[len(t)-1].isdigit():
                t += " "
        if len(t) > 0:
            arr = map(int, t.strip().split(' '))
            for x in arr:
                ans += x
    except EOFError:
        break
print ans

Measured memory_bytes: 6432