akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI  3.1415926535
#define rep(i, k, n) for(ll i = k; i < n; i++)

int main(){
	string s; cin >> s;
    ll rs, rf, ls, lf;
    vll a(s.size(),0);
    if(s[0] == 'L'){
    	ll i = 0;
        while(s[i] == 'L'){
        	a[0]++;
            i++;
    	}
        rs = a[0];
     }
     else{rs = 0;}
     
    rep(i, rs+1, s.size()){
 		if(s[i] == 'R' && s[i-1] == 'L'){
        	lf = i-1;
            ll total = lf - rs + 1;
            if(total % 2 == 0){a[rf] = total/2; a[ls] = total/2;}
            else{
            	a[rf] = total/2 + (rf - rs + 1) % 2;
                a[ls] = total/2 + (ls - rs + 1) % 2;
            }
            rs = i;            
        }
        else if(s[i] == 'L' && s[i-1] == 'R'){
        	rf = i-1;
            ls = i;
        }
      if(i == s.size()-1 && s[i] == 'R'){a[i] = i - rs + 1;}
      else if(i == s.size()-1 && s[i] == 'L'){
        lf = i;
            ll total = lf - rs + 1;
            if(total % 2 == 0){a[rf] = total/2; a[ls] = total/2;}
            else{
            	a[rf] = total/2 + (rf - rs + 1) % 2;
                a[ls] = total/2 + (ls - rs + 1) % 2;
            }
      }
    }
    rep(i, 0, a.size()){
    	cout << a[i] << " ";
        }
}



Measured memory_bytes: 4312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    string s;

    cin >> s;

    umap<char, int> counts;
    for (char c : s) {
        counts[c] += 1;
    }
    if (counts.size() != 2) {
        cout << "No" << endl;
        return 0;
    }

    for (const auto &it : counts) {
        if (it.second == 2) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=250;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
int head[N],nn[N][2],dis[N],st[N],fa[N],w[N],cnt,k,vis[N];
ll ans=1e18,sum;
#define link(u,v) (nn[++cnt][1]=v,nn[cnt][0]=head[u],head[u]=cnt)
void bfs(int s){
    memset(dis,0,sizeof(dis));
    dis[s]=1;
    int l=0,r=1,a,b; st[1]=s;
    while(l<r){
	a=st[++l];
	for (int i=head[a]; i; i=nn[i][0])
	    if (!dis[b=nn[i][1]])
		fa[b]=a,dis[b]=dis[a]+1,st[++r]=b;
    }
    return;
}
void dfs(int x){
    vis[x]=1;
    int child=0;
    for (int i=head[x],y; i; i=nn[i][0])
	if (!vis[y=nn[i][1]]){
	    dis[y]=dis[x]+1,++child;
	    dfs(y);
	}
    w[dis[x]]=max(w[dis[x]],child);
    return;
}
void solve(int x,int y){
    memset(w,0,sizeof(w));
    memset(vis,0,sizeof(vis));
    memset(dis,0,sizeof(dis));
    dis[x]=dis[y]=1;
    if (x==y) dfs(x);
    else vis[x]=vis[y]=1,dfs(x),dfs(y);
    sum=1;
    for (int i=1; i<k; ++i)
	sum=sum*w[i];
    if (x!=y) sum*=2;
    ans=min(ans,sum);
    return;
}
int main(){
    int n=gi(),a,b;
    for (int i=1; i<n; ++i)
	a=gi(),b=gi(),link(a,b),link(b,a);
    bfs(1);
    int mx=0,id;
    for (int i=1; i<=n; ++i)
	if (dis[i]>mx)
	    mx=dis[i],id=i;
    bfs(id),mx=0;
    for (int i=1; i<=n; ++i)
	if (dis[i]>mx)
	    mx=dis[i],id=i;
    cout<<(k=(mx+mx%2)/2)<<" ";
    if (mx&1){
	while(dis[id]!=(mx+1)/2) id=fa[id];
	for (int i=head[id]; i; i=nn[i][0])
	    solve(id,nn[i][1]);
	solve(id,id);
    }
    else{
	while(dis[id]!=mx/2+1) id=fa[id];
	solve(id,fa[id]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		int[] Hmax = new int[N];
		
		for(int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
			if(i >= 1) {
				Hmax[i] = Math.max(H[i], Hmax[i - 1]);
			} else {
				Hmax[i] = H[i];
			}
		}
		
		int sum = 0;
		
		for(int i = 0; i < N; i++) {
			if(H[i] >= Hmax[i]) {
				sum++;
			}
		}
			
		System.out.println(sum);
		
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void) {
	int asumikana = 0;
	int N;
	int K;
	int i;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		int h;
		if (scanf("%d", &h) != 1) return 1;
		if (h >= K) asumikana++;
	}
	printf("%d\n", asumikana);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll a[300010] = {};
    cin >> N;
    rep(i,0,N*3){
        cin >> a[i];
    }
    ll sum_1[300010] = {};
    ll sum_2[300010] = {};
    priority_queue< ll, vector<ll>, greater<ll> > q1;
    priority_queue<ll, vector<ll>, less<ll> > q2;
    ll sum_now = 0;
    rep(i,0,N){
        q1.push(a[i]);
        sum_now += a[i];
    }
    sum_1[N-1] = sum_now;
    rep(i,N,2*N){
        q1.push(a[i]);
        ll val = q1.top();
        q1.pop();
        if(val != a[i]){
            sum_now += a[i] - val;
        }
        sum_1[i] = sum_now;
    }
    sum_now = 0;
    rep(i,2*N,3*N){
        q2.push(a[i]);
        sum_now += a[i];
    }
    sum_2[2*N - 1] = sum_now;
    rep(j,N+1,2*N+1){
        int i = 3*N - 1 - j;
        q2.push(a[i+1]);
        ll val = q2.top();
        q2.pop();
        if(val != a[i+1]){
            sum_now += a[i+1] - val;
        }
        sum_2[i] = sum_now;

    }
    ll ans = -1e18;
    rep(i,N-1, 2*N){
        ans = max(ans, sum_1[i] - sum_2[i]);
    }
    print(ans);
    //rep(i,0,N*3){
    //    if(i < N-1 || i >= 2 * N) continue;

    //    rep(j,0,N*3){
    //        a_tmp[j] = a[j];
    //    }
    //    sort(a_tmp, a_tmp + i + 1);
    //    sort(a_tmp + i + 1, a_tmp + 3 * N);

    //    rep(j,1,3*N + 1){
    //        sum[j] = sum[j-1] + a_tmp[j-1];
    //    }
    //    ll ans_tmp = sum[i+1] - sum[i-N+1] - (sum[i+1+N] - sum[i+1]);
    //    ans = max(ans, ans_tmp);
    //}
    //print(ans);

}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << "," << a.second << ")";return os;}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    int ans = 1e9;
    for (int i = 0;i < 101;++i) {
        int sum = 0;
        for (int j = 0;j < n;++j) sum += (a[j]-i)*(a[j]-i);
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	ll N;
	int i,j;
	int tmp;
	int counter=0;
	ll answer=0;
	vector<int> given;

	cin >> N;

	
	answer=N + N*N + N*N*N ;
	cout << answer << endl;

	return 0;
}



Measured memory_bytes: 3632
package main

import "fmt"

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

	if a >= k {
		fmt.Println(1 * k)
	} else if b >= k-a {
		fmt.Println(1 * a)
	} else {
		fmt.Println(1*a - (1 * (k - a - b)))
	}
}


Measured memory_bytes: 1756
#include <stdio.h>
#include <string.h>

int main()
{
  int a[100000];
  int b[100001];
  int i, n, k, q;
  scanf("%d %d %d", &n, &k, &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    b[i] = 0;
  }
  for (i = 0; i < q; i++) {
    b[a[i]]++;
  }
  for (i = 1; i <= n; i++) {
    if ((k - q + b[i]) > 0)
      puts("Yes");
    else
      puts("No");
  }
  return 0;
}

Measured memory_bytes: 1280
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

int main() {
  int n,m; cin>>n>>m;
  if(n==m){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

signed main()
{
    showoff;
    int n;
    cin >> n;
    vector<int>v(n+5),a(n+5);
    map<int,int>mp;
    FOR(i,1,n+1)cin >> v[i],mp[v[i]]++;
    int xo = 0;
    FOR(i,1,n+1)xo ^= v[i];
    if(xo){
        cout << "No\n";
        return 0;
    }
    a[1] = v[1];
    bool fo = 0;
    FOR(i,2,n+1){
        mp[a[1]]--;
        mp[v[i]]--;
        if(mp[a[1]^v[i]]){
            mp[a[1]^v[i]]--;
            a[2] = v[i];
            a[n] = (a[1]^v[i]);
            fo = 1;
            break;
        }
        else {
            mp[a[1]]++;
            mp[v[i]]++;
        }
    }
    if(fo){
        FOR(i,2,n-1){
            if(mp[a[i]^a[i-1]]){
                mp[a[i]^a[i-1]]--;
                a[i+1] = (a[i]^a[i-1]);
            }
            else {cout << "No";return 0;}
        }
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 6272
import collections

n,m = map(int,input().split())
a = list(map(int,input().split()))

cum = [0 for i in range(n+1)]
for i in range(n):
    cum[i+1] = (cum[i]+a[i])%m


f = collections.Counter(cum)
ans = 0
for i in f:
    ans += f[i]*(f[i]-1)//2
print(ans)

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

using namespace std;
typedef long long ll;
ll tot,n,x,sum;
int main(){
	cin>>tot>>n;
	for(int i=1;i<=n;i++)
	cin>>x,sum+=x;
	if(sum>tot) cout<<-1;
	else cout<<tot-sum; 
	return 0;
} 

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;int main(){long long n,x;cin>>n>>x;for(int i = 0; n > i; i++){int a;cin>>a;if(a%2==1){cout << (long long)pow(2,n)/2 << endl;return 0;}}cout << (x==0?(long long)pow(2,n):0) << endl;}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = []
N.times do
  A << gets.chomp.to_i
end
# D = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

sorted = A.sort_by { |i| -i }
max = sorted[0]
nex = sorted[1]

r = []
A.each do |i|
  if i == max
    r << nex
  else
    r << max
  end
end

print r.join("\n")+"\n"

Measured memory_bytes: 10940
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define y0 yy
#define y1 Yy
#define yn YY
#include <assert.h>
#include <algorithm>
#include <vector>
using namespace std;

int h, w, n, a[10005], res[105][105];

int main() {
	scanf("%d %d %d", &h, &w, &n);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	bool f = true;
	int curr = 0;
	for (int r = 0; r < h; r++) {
		for (int c = (f ? 0 : w - 1); (f ? c < w : c >= 0); (f ? c++ : c--)) {
			res[r][c] = curr + 1;
			a[curr]--;
			if (a[curr] == 0) curr++;
		}
		f = !f;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) printf("%d ", res[i][j]);
		printf("\n");
	}
#ifdef LOCAL_MSVC_DEBUG
	system("pause");
#endif
	return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(void)
{
	int x[4],y[4];
	for(int i=1;i<=2;i++)
		cin >> x[i-1] >> y[i-1];
	
	int dx = x[1]-x[0];
	int dy = y[1]-y[0];

	x[2]=x[1]-dy;
	y[2]=y[1]+dx;
	x[3]=x[0]-dy;
	y[3]=y[0]+dx;

	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
}

Measured memory_bytes: 256
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    int mx = 0;
    ll ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        if(mx <= a) {
            mx = a;
        } else {
            ans += mx-a;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(auto &a : v) cin>>a;
    vector<double> p(n+1);
    for(int i=0;i<n;++i){
        p[i] = (v[i] + 1 )/2.;
    }
    vector<double > c(n+1,0);
    for(int i=0;i<n;++i)c[i+1] += c[i] + p[i];
    double ret = 0.0;
    for(int i=0;i<n;++i){
        if(i+k >= n+1)break;
        ret = max(c[i+k] - c[i],ret);
    }
    cout << fixed;
    cout << setprecision(15);
    cout << ret << endl;
    return 0;
}


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

ll digit(ll n){
    ll ret = 0;
    while(n>0){
        n/=10;
        ret++;
    }
    return ret;
}

int main(){
    ll n; cin >> n;
    ll ans = digit(n);
    for(ll i = 1; i*i <= n; ++i){
        if(n%i == 0){
            ans = min(ans, max(digit(i), digit(n/i)));
        }
    }
    cout << ans << endl;
}

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

const double PI = (acos(-1));

int main()
{
  double a; cin >> a;
  double b; cin >> b;
  double x; cin >> x;

  double c = x/a;

  double r = 0.0;
  if (c < a*b/2.0) {
    r = PI / 2 - atan(2*c/(b*b));
  } else {
    r = atan(2*(a*b-c)/(a*a));
  }
  printf("%.10lf\n", r*180.0/PI);

  return 0;
}


Measured memory_bytes: 512
import math
a,b,C = map(float,input().split())
S = 1/2*a*b*math.sin(math.radians(C))
c = (a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5
L = a+b+c
h = S * 2 /a
print(S)
print(L)
print(h)


Measured memory_bytes: 5696
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x, y, box = 0;
		while (true) {
			x = stdIn.nextInt();
			y = stdIn.nextInt();
			if(x == 0 && y == 0)break;
			if (x > y) {
				box = x;
				x = y;
				y = box;
			}
			System.out.println(x + " " + y);
		}

	}
}

Measured memory_bytes: 27128
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
c = Counter(S)
print(c["1"])
# print(c)

Measured memory_bytes: 5784
#include<stdio.h>



int h ,w ;

int mx[] = { 1 ,1 ,1 ,-1 ,-1 ,-1 ,0 ,0 } ;
int my[] = { 1 ,-1 ,0 ,1 ,-1 ,0 ,1 ,-1 } ;


char castle[ 1000 ][ 1000 ] ;
char castles[ 1000 ][ 1000 ] ;

char sand[ 1000 ][ 1000 ] ;


int del[ 999 * 999 ][ 2 ] ;
int DEL ;

#define x j + mx[ k ]
#define y i + my[ k ]

#define dy [ 0 ]
#define dx [ 1 ]


void make9( int i ,int j )
{
	int k ;
	for( k = 0 ; k < 8 ; ++k )
	{
		int kale = castle[ y ][ x ] ;

		if( kale < 9 && kale > -1 )
		{
			++castle[ y ][ x ] ;


			if( castle[ y ][ x ] == 9 )
			{
				make9( y ,x ) ;
			}
		}
	}
}

void look9( int H ,int W )
{
	int i ,j ;
	for( i = 1 ; i < H ; ++i )
	{
		for( j = 1 ; j < W ; ++j )
		{
			if( castle[ i ][ j ] == 9 )
			{
				make9( i ,j ) ;
			}
		}
	}
}


void input_del( int i ,int j )
{
	int minus = 0 ;

	int k ;
	for( k = 0 ; k < 8 ; ++k )
	{
		minus += castles[ y ][ x ] ;
	}

	if( castle[ i ][ j ] <= -minus )
	{
		castle[ i ][ j ] = -1 ;

		del[ DEL ] dy = i ;
		del[ DEL ] dx = j ;

		++DEL ;
	}
}

void undo( int H ,int W )
{
	int i ,j ;
	for( i = 1 ; i < H ; ++i )
	{
		for( j = 1 ; j < W ; ++j )
		{
			if( castle[ i ][ j ] < 9 )
			{
				castle[ i ][ j ] = castles[ i ][ j ] ;
			}
			
			if( castle[ i ][ j ] > -1 )
			{
				castles[ i ][ j ] = 0 ;
			}
		}
	}
}

void update( int i ,int j )
{
	castles[ i ][ j ] = -1 ;

	int k ;
	for( k = 0 ; k < 8 ; ++k )
	{
		if( castle[ y ][ x ] < 9 && castle[ y ][ x ] > -1 )
		{
			input_del( y ,x ) ;
		}
	}
}


//	castle checker
/*
void check( int i = 0 ,int j = 0 )
{
	puts( "" ) ;

	while( i < h )
	{
		while( j < w )
		{
			printf( "%2d" ,castle[ i ][ j++ ] ) ;
		}

		++i ; j = 0 ;

		puts( "" ) ;
	}

	puts( "" ) ;
}
*/

//	castles checker
/*
void checks( int i = 0 ,int j = 0 )
{
	puts( "" ) ;

	while( i < h )
	{
		while( j < w )
		{
			printf( "%2d" ,castles[ i ][ j++ ] ) ;
		}

		++i ; j = 0 ;

		puts( "" ) ;
	}

	puts( "" ) ;
}
*/

int main()
{
	scanf( "%d %d" ,&h ,&w ) ;
	
	int i ,j ;
	for( i = 0 ; i < h ; ++i )
	{
		getchar() ;

		for( j = 0 ; j < w ; ++j )
		{
			char c = getchar() ;

			if( c == '.' )
			{
				castles[ i ][ j ] = castle[ i ][ j ] = -1 ;
			}

			else
			{
				castles[ i ][ j ] = castle[ i ][ j ] = c - '0' ;
			}
		}
	}
	
	look9( h - 1 ,w - 1 ) ;

	undo( h - 1 ,w - 1 ) ;

	for( i = 1 ; i < h - 1 ; ++i )
	{
		for( j = 1 ; j < w - 1 ; ++j )
		{
			if( castle[ i ][ j ] > -1 && castle[ i ][ j ] < 9 )
			{
				input_del( i ,j ) ;
			}
		}
	}

	int limit = 0 ;

	int ans = 0 ;

	int next_del = 0 ;

	while( limit != DEL )
	{

		++ans ;

		limit = DEL ;
		for( i = next_del ,next_del = limit ; i < limit ; ++i )
		{
			if( del[ i ] dy > 0 )
			{
				update( del[ i ] dy ,del[ i ] dx ) ;
			}
		}
	}

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

	return 0 ;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef tuple<int,int,int> ti3;

int main(void){
  
  ll x, y, a, b, c;
  scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
  
  vector<ll> r(a), g(b), m(c);
  for(ll i=0; i<a; i++) cin >> r.at(i);
  for(ll i=0; i<b; i++) cin >> g.at(i);
  for(ll i=0; i<c; i++) cin >> m.at(i);
  sort(r.begin(), r.end());
  reverse(r.begin(), r.end());
  sort(g.begin(), g.end());
  reverse(g.begin(), g.end());
  sort(m.begin(), m.end());
  reverse(m.begin(), m.end());
  
  std::priority_queue<ll, vector<ll>,greater<ll> > pr,pg;
  for(ll i=0; i<x; i++) pr.push(r.at(i));
  for(ll i=0; i<y; i++) pg.push(g.at(i));
  
  ll k = c;
  if (k >x + y){k = x+y; };
  
  // for(ll i=0; i<x; i++){cout << r.at(i) << " "; }cout <<endl;
  // for(ll i=0; i<k; i++){cout << m.at(i) << " "; }cout <<endl;
  // cout << pr.top() << endl;
  ll cr,cg;
  cr = cg = 0;
  for(ll i=0; i<k; i++){
    
    if(cr<x&&cg<y){
      // cout << pr.top() << " " << pg.top() << endl;
      if (pr.top() <= pg.top()){
        // cout << pr.top() << " " << pg.top() << endl;
        if(pr.top()<m.at(i)){
          pr.pop();
          pr.push(m.at(i));
          cr++;
        }else{
          break;
        }
      }else{
        // cout << "ok" << endl;
        if(pg.top()<=m.at(i)){
          pg.pop();
          pg.push(m.at(i));
          cg++;
        }else{
          break;
        }
      }
    } else if(cr<x){
      if(pr.top()<m.at(i)){
          pr.pop();
          pr.push(m.at(i));
          cr++;
        }else{
          break;
        }
    }else if(cg<y){
      if(pg.top()<m.at(i)){
          pg.pop();
          pg.push(m.at(i));
          cg++;
        }else{
          break;
        }
    }else{
      break;
    }
  }
  ll ans = 0;

while (!pr.empty()) {
    ans += pr.top();
    pr.pop();
  }
  // cout << ans << endl;
while (!pg.empty()) {
    ans += pg.top();
    pg.pop();
  }

cout << ans << endl;
  
}






Measured memory_bytes: 4852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Sample401
{
    class Program
    {
        static void Main(string[] args)
        {
          int N = int.Parse(Console.ReadLine());
          int A = int.Parse(Console.ReadLine());
          
          N = N % 500;
          if( A>= N ){
            Console.WriteLine("Yes");
          }
          else{
            Console.WriteLine("No");
          }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;
int n, m;
Graph G(100100);
vector<int> flag(100100, -1);


int main(){
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<P> que;
    que.emplace(1, 1);

    while(!que.empty()){
        int v = que.front().first, par = que.front().second;
        que.pop();
        //flag[v] = par;

        for(int nv : G[v]){
            if(flag[nv] >= 0)continue;
            flag[nv] = v;
            que.emplace(nv, v);
        }
    }
    bool f = true;
    rep(i, n)if(flag[i + 1] == -1)f = false;
    if(!f)cout << "No";
    else {
        cout << "Yes" << endl;
        REP(i, 2, n)cout << flag[i] << endl;
    }
}

Measured memory_bytes: 10864
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 100010;
const int INF = 1<<29;

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

int dp[MAX_N];

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

    REP(i, MAX_N) dp[i] = INF;
    dp[0] = 0;

    REP(i, n + 1){
        for (int k = 1; i + k <= n; k *= 6){
            dp[i + k] = min(dp[i + k], dp[i] + 1);
        }

        for (int k = 1; i + k <= n; k *= 9){
            dp[i + k] = min(dp[i + k], dp[i] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <cmath>
#include <fstream>

int main(void) {

	//test??¨
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	std::string str;
	std::string temp;
	while (std::cin >> temp) {
		str += temp;
	}

	std::vector<int> ans(26);
	char a = 'a';
	for (int i = 0; i < 26; i++) {

		ans[i] += std::count(str.begin(), str.end(), 'A' + i);
		ans[i] += std::count(str.begin(), str.end(), 'a' + i);

		std::cout << a << " : " << ans[i] << std::endl;
		a++;
	}

}

Measured memory_bytes: 1196
def resolve():
    N = int(input())
    S = input()
    ans = []
    abc = "abcdefghijklmnopqrstuvwxyz"
    for i in range(N-1):
        X = S[:i+1]
        Y = S[i+1:]
        count = 0
        for j in abc:
            if j in X and j in Y:
                count += 1
        ans.append(count)
    print(max(ans))
resolve()

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define pb push_back
#define mp make_pair

int intToAscii(int number) {
	return '0' + number;
}

void solve()
{
	ll n;
	cin >> n;
	char d;
	string ans = "";
	while (n > 26)
	{
		int t = n / 26;
		int z = n % 26;
		if (z == 0)
			z = 26;
		d = 'a' - 1 + z;
		ans += d;
		n = (n - z) / 26;
	}
	d = 'a' - 1 + n;
	ans += d;
	reverse(ans.begin(), ans.end());
	cout << ans;
}

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

Measured memory_bytes: 3620
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

static ul A, B;

void solve(void) {
  if (A <= 9 && B <= 9) {
    cout << (A * B) << endl;
  } else {
    cout << -1 << endl;
  }
}

int main(void) {
  cin >> A >> B;
  solve();
  return 0;
}

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

#define      ll      long long int

const int N = 100005;
vector<ll> pos, neg;
ll ara1[N];
ll ara2[N];

int main( )
{
    ll n, i, j, k;
    pos.push_back(0);
    neg.push_back(0);
    cin >> n >> k;
    ll c = 0;
    for (i = 1; i <= n; i++) {
        cin >> j;
        if (j == 0) {
            c++;
        }
        else if (j > 0) {
            pos.push_back(j);
        }
        else {
            neg.push_back(j);
        }
    }
    ll lpos, lneg;
    lpos = (int) pos.size();
    lneg = (int) neg.size();
    reverse(neg.begin() + 1, neg.end());
    for (i = 1; i < lpos; i++) {
        ara1[i] = ara1[i - 1] + (pos[i] - pos[i - 1]);
        //cout << ara1[i] << ' ';
    }
    //cout << '\n';
    for (i = 1; i < lneg; i++) {
        ara2[i] = ara2[i - 1] + (neg[i - 1] - neg[i]);
        //cout << ara2[i] << ' ';
    }
    //cout << '\n';
    ll mn = 1e18, taken, need;
    if (c >= k) {
        cout << "0\n";
        return 0;
    }
     for (i = 1; i < lneg; i++) {
        taken = i + c;
        need  = k - taken;
        if (need < 0) {
            break;
        }
        if (need <= (lpos - 1)) {
            if (need == 0) {
                mn = min(ara2[i], mn);
            }
            else {
                mn = min(2 * ara2[i] + ara1[need], mn);
            }
        }
    }
    for (i = 1; i < lpos; i++) {
        taken = i + c;
        need  = k - taken;
        if (need < 0) {
            break;
        }
        if (need <= (lneg - 1)) {
            if (need == 0) {
                mn = min(ara1[i], mn);
            }
            else {
                mn = min(2 * ara1[i] + ara2[need], mn);
            }
        }
    }
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 2292
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> P;
const ll INF = 1e10;
const ll MOD = 1e9 + 7;

const int MAXN = 100005;
vector<vector<P>> G(MAXN);
vector<int> color(MAXN,-1);

void dfs(int v,int before = -1) {
    for (P e:G[v]) {
        if (e.first == before) continue;
        if ((color[v] + e.second)%2 == 0) {
            color[e.first] = 0;
        }
        else color[e.first] = 1;
        dfs(e.first,v);
    }
}

int main() {
    int n; cin >> n;
    rep(i,n - 1) {
        int a,b,c; cin >> a >> b >> c;
        a --; b --;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }

    color[0] = 0;
    dfs(0);
    rep(i,n) cout << color[i] << endl;
}



Measured memory_bytes: 8448
n = int(input())
ao = [input() for _ in range(n)]
m = int(input())
aka = [input() for _ in range(m)]
str = set(ao + aka)
ans = 0
for i in str:
    temp = ao.count(i) - aka.count(i)
    ans = max(temp, ans, 0)
print(ans)
    

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
long long int a[10000];
long long int cache[5000][5000][2]={0};
long long int optimalResult(int i,int j,int k)
{
	if(i>j)
	return 0;
	if(cache[i][j][k]!=0)
	return cache[i][j][k];
	if(k==0)
	{
		long long int x=a[i]+optimalResult(i+1,j,1);
		long long int y=a[j]+optimalResult(i,j-1,1);
		return cache[i][j][k]=x>y?x:y;
	}
		if(k==1)
	{
		long long int x=-a[i]+optimalResult(i+1,j,0);
		long long int y=-a[j]+optimalResult(i,j-1,0);
		return cache[i][j][k]=x>y?y:x;
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	long long int x=optimalResult(0,n-1,0);
	cout<<x;
}

Measured memory_bytes: 235264
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
	string str1, str2;
	cin >> str1;
	cin >> str2;

	if (str1[0] == str2[2] && str1[2] == str2[0] && str1[1] == str2[1]) {
		cout << "YES" << endl;
	}
	else  cout << "NO" << endl;



    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
int N;
double W;
double wi[100001];
double vi[100001];
double xi[100001];

typedef pair<double,int> pdi;

void solve(){
    cin>>N>>W;
    for(int i=0;i<N;i++)cin>>wi[i]>>vi[i];
    for(int i=0;i<N;i++)xi[i]=1;
    priority_queue<pdi> grt;
    priority_queue<pdi> dec;
    double maxVal=0;
    for(int i=0;i<N;i++){
        if((wi[i]<0||EQ(wi[i],0))&&(vi[i]>0||EQ(vi[i],0))){
            xi[i]=0;
            maxVal+=vi[i];
            W+=(-wi[i]);
        }
        else if((wi[i]>0||EQ(wi[i],0))&&(vi[i]<0||EQ(vi[i],0)))xi[i]=0;
        else{
            if(wi[i]<0&&vi[i]<0){
                wi[i]*=-1;
                vi[i]*=-1;
                dec.push(pdi(wi[i]/vi[i],i));
            }
            else if(wi[i]>0&&vi[i]>0)grt.push(pdi(vi[i]/wi[i],i));
        }
    }
    while(grt.size()){
        pdi p=grt.top();grt.pop();
        if(wi[p.second]*xi[p.second]<W||EQ(wi[p.second]*xi[p.second],W)){
            W-=wi[p.second]*xi[p.second];
            maxVal+=vi[p.second]*xi[p.second];
            xi[p.second]=0;
        }
        else{
            double quan=W/(wi[p.second]);
            if(!EQ(quan,0)){
                maxVal+=vi[p.second]*quan;
                xi[p.second]-=quan;;
                grt.push(p);
                W=0;
            }
            else{
                double needW=xi[p.second]*wi[p.second];
                double curFullVal=xi[p.second]*vi[p.second];
                double curGetW=0;
                double curGetVal=0;
                while(dec.size()){
                    pdi pp=dec.top();dec.pop();
                    if(!EQ(p.first,(1.0/pp.first))&&(p.first<1.0/pp.first))break;
                    if(EQ(curGetW+wi[pp.second]*xi[pp.second],needW)||curGetW+wi[pp.second]*xi[pp.second]>needW){
                        double curQuan=(needW-curGetW)/wi[pp.second];
                        curGetW+=curQuan*wi[pp.second];
                        curGetVal+=curQuan*vi[pp.second];
                        xi[pp.second]-=curQuan;
                        if(!EQ(1,xi[pp.second]))dec.push(pp);
                        break;
                    }
                    else{
                        curGetW+=wi[pp.second]*xi[pp.second];
                        curGetVal+=vi[pp.second]*xi[pp.second];
                    }
                }
                if(EQ(curGetW,needW)){
                    if(EQ(curGetVal,curFullVal)||curGetVal<curFullVal)maxVal+=curFullVal-curGetVal;
                    else break;
                }
                else{
                    if(curGetVal<curFullVal*(curGetW/needW)||EQ(curGetVal,curFullVal*(curGetW/needW)))
                        maxVal+=(-curGetVal+curFullVal*(curGetW/needW));
                    break;
                }
            }
        }
    }
    printf("%.10f\n",maxVal);
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){
    int n,k; cin >> n >> k;
    int ans = 0;
    int h[n];
    for (int i=0; i<n; i++){
        cin >> h[i];
        if (h[i] >= k){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    int ans = A - 2 * B;
    if(ans <= 0){
        cout << 0 << endl;
    }
    else{
        cout << A - 2 * B << endl;
    }
    return 0;
}

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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  
  int plan1,plan2;
  plan1=N*A;
  plan2=B;
  
  if(plan1>plan2)
    cout<<plan2<<endl;
  else
    cout<<plan1<<endl;
}

Measured memory_bytes: 256
n = int(input())
ans = n * (n + 1) * (n + 2) // 6
for i in range(n - 1):
    l, r = [int(i) for i in input().split()]
    if l > r:
        l, r = r, l
    ans -= l * (n - r + 1)
print(ans)


Measured memory_bytes: 9048
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    n = input().rstrip()
    k = int(input())
    ln = len(n)
    # dp[i][j]:左からi桁まで見たとき0でない桁がj個ある場合の数
    dp1 = [[0]*(k+1) for _ in range(ln+1)]
    dp2 = [[0]*(k+1) for _ in range(ln+1)]

    dp2[0][0] = 1
    cnt = 0
    for i in range(ln):
        if n[i] != '0':
            if cnt < k:
                cnt += 1
            dp2[i+1][cnt] = 1
        else:
            dp2[i+1][cnt] = dp2[i][cnt]

    for i in range(ln):
        dp1[i+1][0] = 1
        for j in range(1, k+1):
            dp1[i+1][j] += dp1[i][j] + dp1[i][j-1] * 9
            if n[i] != '0':
                dp1[i+1][j] += dp2[i][j-1] * (int(n[i])-1)
                if j < k:
                    dp1[i+1][j] += dp2[i][j]
    print(dp1[-1][k] + dp2[-1][k])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int INF = INT_MAX;


int ans[300000];
bool used[300000];
int main(){
    int N, X;
    cin >> N >> X;
    if(X == 1 || X == 2*N-1){
        cout << "No" << endl;
        return 0;
    }
    else if(N == 2){
        cout << "Yes" << endl;
        REP(i,3){
            cout << i+1 << endl;
        }
        return 0;
    }
    cout << "Yes" << endl;

    fill(ans, ans+2*N-1, INF);
    ans[N-2] = 2*N-1;
    ans[N-1] = X;
    ans[N] = 1;
    used[1] = true;
    used[X] = true;
    used[2*N-1] = true;
    for(int i = X+1; i <= 2*N-1; i++){
        if(!used[i]){
            ans[N+1] = i;
            used[i] = true;
            break;
        }
    }
    for(int i = 1; i <= X-1; i++){
        if(!used[i]){
            ans[N-3] = i;
            used[i] = true;
            break;
        }
    }

    int index = 1;
    REP(i,2*N-1){
        if(ans[i] == INF){
            while(used[index]){
                index++;
            }
            ans[i] = index;
            used[index] = true;
        }
    }

    REP(i,2*N-1){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

double th = M_PI * 60.0 / 180.0; //度からラジアン

struct Point {
    double x;
    double y;
};

void printP(Point p){
    cout << fixed << setprecision(8) << p.x << " ";
    cout << fixed << setprecision(8) << p.y << endl;
}

void koch(int n, Point p1, Point p2){
    /*第一引数：再帰の深さ
      第二引数：線分の始点
      第三引数：線分の終点*/

    if(n == 0) return;

    Point s, t, u;

    //線分p1p2を三等分するような点s,tの座標と正三角形のもう一つの頂点uの座標を求める
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, p1, s);
    printP(s);
    koch(n - 1, s, u);
    printP(u);
    koch(n - 1, u, t);
    printP(t);
    koch(n - 1, t, p2);
}

int main(){
    int n; //再帰の深さ
    cin >> n;
    
    Point p1, p2;
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;

    printP(p1);
    koch(n, p1, p2);
    printP(p2);

    return 0;
}



Measured memory_bytes: 3448
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String ans = "";
        String temp = sc.next();
        for(int i = 0 ; i < temp.length() ; i++){
            ans += "x";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38588
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<char>> c(H, vector<char>(W));
    for(int h=0; h<H; ++h){
        for(int w=0; w<W; ++w){
            cin >> c[h][w];
        }
    }


    int ans = 0;
    for(int hbit=0; hbit<(1 << (H)); ++hbit){
        for(int wbit=0; wbit<(1 << (W)); ++wbit ){
            int cnt = 0;

            for(int h=0; h<H; ++h){
                for(int w=0; w<W; ++w){
                    if( (hbit >> h & 1) || (wbit >> w &1) ){
                        continue;
                    }
                    if(c[h][w] == '#'){
                        cnt++;
                    }
                }
            }
            if(cnt == K){
                ans++;
            }

        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace past10.Abc
{
    public class Question4
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            long A = long.Parse(Console.ReadLine());
            long B = long.Parse(Console.ReadLine());
            long C = long.Parse(Console.ReadLine());
            long X = long.Parse(Console.ReadLine());
            long ans = 0;
            for(long i=0;i<=A;++i){
                for(long j=0;j<=B;++j){
                    for(long k=0;k<=C;++k){
                        if(500*i+100*j+50*k == X){
                            ++ans;
                        }
                    }
                }
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 27448
n, x=map(int, input().split())
a=list(map(int, input().split()))
a.sort()
b=0
for i in range(n):
  b+=a[i]
  if b>x:
    print(i)
    break
if b<x:
  print(n-1)
elif b==x:
  print(n)

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

typedef long long ll;

vector<ll> prime;

int main(){
  prime.push_back(2);
  for(ll i=3; i<1300000; i+=2){
    bool flag=true;
    for(ll j=0; j<prime.size() && i>=prime[j]*prime[j]; j++){
      if(i%prime[j]==0){flag=false; break;}
    }
    if(flag)prime.push_back(i);
  }
  while(true){
    int n;
    cin>>n;
    if(n==0)break;
    ll to;
    for(to=0; n>prime[to]; to++);
    if(n==prime[to])cout<<"0"<<endl;
    else cout<<prime[to]-prime[to-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1980
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K = int(input())
s=0
q=0
w=0
e=0
for i in range(K):
    q+=gcd(i+1,i+1,i+1)
    
for a in range(K):
    for b in range(K):
        if not a==b:
            w+=3*gcd(a+1,a+1,b+1)
for a in range(1,K-1):
    #print(a)
    for b in range(a+1,K):
     #   print(b)
        for c in range(b+1,K+1):
      #      print(c)
            e+=6*gcd(a,b,c)
#print(q,w,e)     
print(q+w+e)

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

struct Point{ double x, y; };

void koch(int n, Point a, Point b) {
  Point s, u, t;

  if ( n == 0 ) return;
  s.x = ( 2.0 * a.x + 1.0 * b.x ) / 3;
  s.y = ( 2.0 * a.y + 1.0 * b.y ) / 3;
  u.x = ( 1.0 * a.x + 1.0 * b.x ) / 2 + ( a.y - b.y ) / ( 2 * sqrt(3) );
  u.y = ( 1.0 * a.y + 1.0 * b.y ) / 2 + ( b.x - a.x ) / ( 2 * sqrt(3) );
  t.x = ( 1.0 * a.x + 2.0 * b.x ) / 3;
  t.y = ( 1.0 * a.y + 2.0 * b.y ) / 3;


  // new segments (p1, s), (s, u), (u, t), (t, p2)
  koch( n - 1, a, s);
  // cout << s.x << " " << s.y << endl;
  printf("%.8f %.8f\n", s.x, s.y);
  koch( n - 1, s, u);
  // cout << u.x << " " << u.y << endl;
  printf("%.8f %.8f\n", u.x, u.y);
  koch( n - 1, u, t);
  // cout << t.x << " " << t.y << endl;
  printf("%.8f %.8f\n", t.x, t.y);
  koch( n - 1, t, b);

  return;
}

int main() {
  // input
  int n;
  // cin >> n;
  scanf("%d", &n);

  Point p1, p2;
  p1.x = 0.0;
  p1.y = 0.0;
  p2.x = 100.0;
  p2.y = 0.0;
  // cout << p1.x << " " << p1.y << endl;
  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  // cout << p2.x << " " << p2.y << endl;
  printf("%.8f %.8f\n", p2.x, p2.y);

  return 0;
}



Measured memory_bytes: 3212
#include "bits/stdc++.h"
using namespace std;

void makeCombiUtil(vector<vector<int> >& ans, vector<int>& tmp, int n, int left, int k) {
    if (k == 0) {
        ans.push_back(tmp);
        return;
    }
    for (int i = left; i <= n; ++i) {
        tmp.push_back(i);
        makeCombiUtil(ans, tmp, n, i, k - 1);
        tmp.pop_back();
    }
}

vector<vector<int> > makeCombi(int n, int k) {
    vector<vector<int> > ans;
    vector<int> tmp;
    makeCombiUtil(ans, tmp, n, 1, k);
    return ans;
}

int main(void) {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q), d(Q);
    for (int i = 0; i < Q; i++)
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    vector<vector<int> > ans = makeCombi(M, N);
    int max = 0;
    for (int i = 0; i < ans.size(); i++) {
        // for (int j = 0; j < ans[i].size(); j++) {
        //     cout << ans.at(i).at(j) << " ";
        // }
        int sum = 0;
        for (int j = 0; j < Q; j++) {
            if (ans.at(i).at(b.at(j)-1) - ans.at(i).at(a.at(j)-1) == c.at(j))
                sum += d.at(j);
        }
        if (max < sum)
            max = sum;
        // cout << sum;
        // cout << endl;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 9876
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        BigInteger answer = BigInteger.ZERO;
        long temp = (long) Math.sqrt(N);
        temp += 10;
        BigInteger x = new BigInteger(Long.toString(temp));
        BigInteger y = BigInteger.ZERO;
        do {
            x = x.subtract(BigInteger.ONE);
            y = (x.add(BigInteger.ONE)).multiply(x);
        }
        while ((new BigInteger(Long.toString(N)).compareTo(y)) < 1);
        for (int i = 1; i < x.longValue()+1; i++) {
            if (N % i != 0) {
                continue;
            }
            answer = answer.add(new BigInteger(Long.toString(N / i - 1)));
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() { cerr << "--------------" << endl; }
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

   int n;
   cin >> n;
   vector<P> task;
   rep(i, 0, n) {
      int a, b;
      cin >> a >> b;
      task.emplace_back(b, a);
   }
   sort(all(task));
   ll tm = 0;
   rep(i, 0, n) {
      tm += task[i].second;
      int lim = task[i].first;
      if (tm > lim) {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 2420
#include <iostream>

int main()
{
	int n; std::cin >> n;
	int* A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];

	std::cout << A[0];
	int pre = A[0];
	for (int i=1; i<n; i++) {
		if (pre != A[i]) {
			std::cout << " " << A[i];
			pre = A[i];
		}
	}
	std::cout << std::endl;
	
	delete[] A;
	
	return 0;
}



Measured memory_bytes: 3108