akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#define MAX_NUM 100001
#define INF 2147483647
using namespace std;

typedef struct node {
    int id;
    int dist;
    node* next;

    node(int inpId, long long int inpDist, node* inpNext = NULL): id(inpId), dist(inpDist), next(inpNext) {}
}* nodeptr;

class chain {
public:
    nodeptr head;
    nodeptr tail;

    chain(): head(NULL), tail(NULL) {}

    void push(int id, long long int dist) {
        nodeptr tmp = new node(id, dist);
        if (this->tail != NULL) {
            this->tail->next = tmp;
            this->tail = tmp;
        } else {
            this->head = this->tail = tmp;
        }
    }
};

typedef pair<long long int, int> pii;

int V, E, r;
int si, ti;
long long int di;
int S[MAX_NUM];
long long int d[MAX_NUM];
chain* adjacencyList[MAX_NUM];
priority_queue<pii, vector<pii>, greater<pii> > q;

void dijkstra() {
    nodeptr tmp;

    while (!q.empty()) {
        pii u = q.top(); q.pop();
        int x = u.second;
        if (S[x]) {continue;}
        S[x] = 1;

        tmp = adjacencyList[x]->head;
        while (1) {
            if (tmp != NULL) {
                if (tmp->dist + d[x] < d[tmp->id]) {
                    d[tmp->id] = tmp->dist + d[x];
                    q.push(make_pair(d[tmp->id], tmp->id));
                }
                tmp = tmp->next;
            } else {
                break;
            }
        }
    }
}

int main() {
//    freopen("in.txt", "r", stdin);

    cin >> V >> E >> r;
    for (int i = 0; i < MAX_NUM; ++i) {
        adjacencyList[i] = new chain();
        S[i] = 0;
        d[i] = i == r ? 0 : INF;
    }


    for (int i = 0; i < E; ++i) {
        cin >> si >> ti >> di;
        adjacencyList[si]->push(ti, di);
    }
    q.push(make_pair(d[r], r));

    dijkstra();

    for (int i = 0; i < V; ++i) {
        if (d[i] < INF) {
            cout << d[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
}

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

int main() {
  int a, b, x, ret;
  
  cin >> a >> b;
  x = a + b;
  ret = x / 2;
  
  if (x % 2 == 1) {
  	ret += 1;
  }
  
  cout << ret << endl;
}


Measured memory_bytes: 3596
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return sorted(divisors, reverse=True)
def gcd(a, b):
    if b==0:
        return a
    while b>0:
        a, b = b, a%b
    return a

A, B, K = map(int, input().split())
divs = make_divisors(gcd(A, B))
print(divs[K-1])

Measured memory_bytes: 3064
# ABC117C - Streamline
def main():
    n, m = list(map(int, input().rstrip().split()))
    lst = sorted(list(map(int, input().rstrip().split())))
    dis = []
    for i, j in zip(lst, lst[1:]):
        dis += [j - i]
    print(sum(sorted(dis, reverse=True)[n - 1 :]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 13960
#include<iostream>

using namespace std;

typedef long long ll;

const int MAX = 31;
ll dp[MAX];

ll pow(ll A, ll e){
  ll res = 1;
  while(e--) res*=A;
  return res;
}

ll rec(ll depth, ll used, ll chain){
  if(chain < 0) return 0;
  if(chain == 0) return used;
  return max(rec(depth+1, used+3, chain-1), rec(depth+1,used+pow(3,depth), chain-2));
}

int main(){
  ll d = 2;
  dp[4] = 8;

  for(int i = 4; i < MAX; i+=2){
    ll add = pow(3,d++);
    dp[i+1] = dp[i]+add;
    dp[i+2] = dp[i+1]+add;
  }

  ll n;
  while(cin >> n && n) {
    if(n == 0) cout << "0" << endl;
    else if(n == 1) cout << "1" << endl;
    else if(n == 2) cout << "2" << endl;
    else if(n == 3) cout << "5" << endl;
    else cout << dp[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections;
using System.IO;
using System.Linq;

namespace CompetitiveProgramming
{

  class Solve
  {
    const int INF = (int)(1e9) + 10;

    private void Main()
    {
      ulong[] ABC = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
      ulong A = ABC[0], B = ABC[1], C = ABC[2];
      if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
      {
        Console.WriteLine(0);
        return;
      }
      ulong ans = A * B;
      ans = Math.Min(ans, B * C);
      ans = Math.Min(ans, C * A);
      Console.WriteLine(ans);
    }

    public Solve()
    {
      Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
      Main();
      Console.Out.Flush();
    }
  }

  class Program
  {
    static void Main(string[] args)
    {
      new Solve();
    }
  }
}

Measured memory_bytes: 3032
n, x = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
SUM = 0
for i in range(n):
    SUM += A[i]
    if SUM > x:
        print(i)
        break
    elif SUM == x:
        print(i + 1)
        break
else:
    print(n - 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
bool f(double a, double b, double theta, double x){
	if(x > a * b * .5){
		double side = a / tan(theta);
		return (side * a * .5) + (a * (b - side)) > x;
	} else {
		double side = b * tan(theta);
		return (side * b * .5) > x;
	}
}
int main(){
	double a, b, x; cin >> a >> b >> x;
	x /= a;
	double lo = 0, hi = pi / 2;
	for(int i = 0; i < 200; i++){
		double mid = (lo + hi) * .5;
		if(!f(a, b, mid, x)) lo = mid;
		else hi = mid;
	}
	lo = (lo + hi) * .5;
	lo = pi / 2 - lo;
	cout << fixed << setprecision(12) << lo * 180 / pi << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <math.h>
#include <limits>
#include <stdio.h>

template <typename T>
void vc(T t) {
    std::cout << t << " ";
}

template<typename T, typename... Args>
void vc(T t, Args... args) {
// recursive variadic function
    std::cout << t << " ";
    vc(args...) ;
}

const int N = 100000;

std::vector<int> dp(100005, -1);
bool dpx(const std::vector<int> vi, int cur) {
  // vc("-", cur, dp[cur], "\n");
  if (dp[cur] != -1) {
    return dp[cur];
  }
  dp[cur] = false;
  for (auto& i: vi) {
    // vc("x", cur, i, cur - i, "\n");
    if (cur - i >= 0 && !dpx(vi, cur - i)) {
      dp[cur] = true;
      break;
    }
  }
  // vc("+", cur, dp[cur], "\n");
  return dp[cur];
}

void once() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> vi(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> vi[i];
  }
  for (int i = 0; i < vi[0]; ++i) {
    dp[i] = false;
  }

  if (dpx(vi, k)) {
    std::cout << "First" << std::endl;
  } else {
    std::cout << "Second" << std::endl;
  }
  // for (int i = 0; i <= k; ++i) {
  //   vc(i, dp[i], "\n");
  // }
}

int
main() {
  int n = 1;
  std::ios::sync_with_stdio(false);
  // std::cin >> n;
  while (n--) {
    once();
  }
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A;
    ll ans = 1000;
    ll have = 0;
    rep(i, N){
        ll a; cin >> a;
        if(i == 0) A.push_back(a);
        else if(A.back() != a) A.push_back(a); 
    }
    int sz = A.size();
    rep(i, sz-1){
        if(A[i] < A[i+1]){
            ll buy = ans/A[i];
            have += buy;
            ans -= A[i]*buy;
        }
        else{
            ans += A[i]*have;
            have = 0;
        }
    }
    ans += A.back()*have;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.io.*;
import java.util.*;
import java.util.ArrayList;
 
class Main
{
  public static void main (String[] arg)
  {
    Scanner scan = new Scanner(System.in);
    
    long N = scan.nextLong(); //整数    
    long A = scan.nextLong(); //整数    蒼
    long B = scan.nextLong(); //整数　　赤
    
    long ans = 0;
    
    if(A == 0){
      System.out.println(0);
    }
    
    else{
      
      ans = (N / (A + B)) * A;
      
      if((N % (A + B)) >= A){
        ans = ans + A;
      }
      else{
        
        ans = ans + N % (A + B);
      }
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int n,d;
	cin >> n >> d;

	int ans = 0;

	loop(i,0,n)
	{
		int x , y;
		cin >> x >> y;

		if(x*x + y*y <= d*d)ans++;
	}

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3612
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MAX_N = 100100;
const double PI = 3.14159265358979323846;

int N;
int x[10], y[10];

double dist(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
	cin >> N;
	for (int i = 1; i <= N; i++)cin >> x[i] >> y[i];
	double sum = 0.0;
	vector<int> v(N);
	for (int i = 0; i < N; i++)v[i] = i + 1;
	do {
		for (int i = 0; i < N - 1; i++)sum += dist(v[i], v[i + 1]);
	} while (next_permutation(v.begin(), v.end()));
	int Factorial = 1;
	for (int i = 2; i <= N; i++)Factorial *= i;
	cout << fixed << setprecision(10) << sum / Factorial << endl;
	return;
 }


int main(int argc, char *args[]) {
	solve();
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int H, W; cin >> H >> W;
    string A[H];
    rep(i, H) cin >> A[i];
    queue<Pint>Q;
    Q.push(mp(0, 0));
    vector<vector<bool>> visited(H, vector<bool>(W, false));
    int cnt = 0;
    rep(i, H)
        rep(j, W)
            if(A[i][j] == '#') ++cnt;
    visited[0][0] = true;
    while(!Q.empty()) {
        Pint q = Q.front(); Q.pop();
        if(q.first + 1 < H) if(A[q.first + 1][q.second] != '.' && !visited[q.first + 1][q.second]) Q.push(mp(q.first + 1, q.second)), visited[q.first + 1][q.second] = true;
        if(q.second + 1 < W) if(A[q.first][q.second + 1] != '.' && !visited[q.first][q.second + 1]) Q.push(mp(q.first, q.second + 1)), visited[q.first][q.second + 1] = true;
    }
    cout << ((visited[H - 1][W - 1] && H + W - 1 == cnt) ? "Possible" : "Impossible") << endl;
}


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

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

	int n,m,x;
	cin>>n>>m>>x;

	int data[n][m+1];
	for(int i=0; i<n; ++i){
		for(int j=0; j<=m; ++j){
			cin>>data[i][j];
		}
	}

	int ans = 1e9;

	for(int mask=0; mask<(1<<n); ++mask){
		vector<int> cnt(m,0);
		int tot = 0;
		for(int j=0; j<n; ++j){
			if( (mask>>j) & 1 ){
				tot += data[j][0];
				for(int k=1; k<=m; ++k){
					cnt[k-1] += data[j][k];
				}
			}
		}
		bool ok = true;
		for(int i=0; i<m; ++i){
			if( cnt[i] < x ){ ok = false; break; }
		}
		if(ok){
			ans = min(ans, tot);
		}
	}
	if( ans == 1e9 ){
		cout<<-1<<'\n';
	}else{
		cout<<ans<<'\n';
	}


	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m ;
    cin >> n >> m;
    bool a[n];
    vector<ll> num(n, 1);
    memset(a, 0, sizeof(a));
    a[0] = 1;
    ll x, y;
    for(int i =0 ;i<m;i++){
        cin >> x >> y;
        x--, y--;
        if(a[x]){
            num[x]--;
            num[y]++;
            if(num[x] >= 1){
                a[y] = true;
            }else{
                a[x] = false;
                a[y] = true;
            }
        }else{
            num[x]--;
            num[y]++;
        }
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(a[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3924
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int s, n, ans = 0, i = 0;
	cin >> s;
	bool h = false;
	vector<int> a(1, s);
	while(1) {
		if (a.at(i) % 2 == 0) {
			n = a.at(i) / 2;
		}
		else {
			n = a.at(i) * 3 + 1;
		}
		a.push_back(n);
		for (int j = 0; j < i; j++) {
			if (a.at(i) == a.at(j)) {
				ans = i + 1;
				h = true;
			}
		}
		if (h) {
			break;
		}
		i++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
gyo,retu = map(int,input().split())
ans = [0]*gyo
check = [0]*retu
flag1 = "ng"
for i in range(gyo):
    dum = input()
    for j in range(retu):
        if dum[j] == "#":
            flag1 = "ok"
            check[j] = 1
    if flag1 == "ok":
        ans[i] = dum
        flag1 = "ng"

for l in range(gyo-1,-1,-1):
    if ans[l] == 0:
        ans.pop(l)
ans_len = len(ans)
#print(ans_len)
for k in range(retu-1,-1,-1):
    #print(k,check[k])
    #print(ans)
    if check[k] == 0:
        for m in range(ans_len):
            dum3 = list(ans[m])
            dum3.pop(k)
            ans[m] = dum3
            #dum2 = ans[m]
            #dum2 = dum2.pop(k)
            #ans[m] = dum2

for n in ans:
  print("".join(n))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int n, a, b, c;
	scanf("%d%d%d", &n, &a, &b);
	c = n * a;
	if (c <= b) {
		printf("%d", c);
	}
	else {
		printf("%d", b);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
const int N=1e5+10;
int n,k,tmp[N];
struct Poly
{
	int a[N];
	Poly inv()
		{
			Poly C;
			for(int i=1;i<=n;i++) tmp[a[i]]=i;
			for(int i=1;i<=n;i++) C.a[i]=tmp[i];
			return C;
		}
	Poly operator * (Poly A)
		{
			Poly C;
			for(int i=1;i<=n;i++) C.a[i]=a[A.a[i]];
			return C;
		}
}A,P,Q,bs[9];
Poly ksm(Poly A,int k)
{
	Poly s=bs[0];for(;k;k>>=1,A=A*A)
					 if(k&1) s=s*A;return s;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>P.a[i];
	for(int i=1;i<=n;i++) cin>>Q.a[i];
	A=Q*P.inv()*Q.inv()*P;
	for(int i=1;i<=n;i++) bs[0].a[i]=i;
	bs[1]=P;bs[2]=Q;
	for(int i=3;i<=6;i++) bs[i]=bs[i-1]*bs[i-2].inv();

	int u=k/6,p=k%6;if(!p) u--,p=6;
	Poly Ans1=ksm(A,u),Ans2=ksm(A.inv(),u);
	Poly Ans=Ans1*bs[p]*Ans2;
	for(int i=1;i<=n;i++) cout<<Ans.a[i]<<" ";
}


Measured memory_bytes: 14080
n,m=map(int,input().split())
h=list(map(int,input().split()))
good=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]==h[b-1]:
        good[a-1]+=1
        good[b-1]+=1
    elif h[a-1]>h[b-1]:
        good[b-1]+=1
    else:
        good[a-1]+=1
print(good.count(0))

Measured memory_bytes: 20076
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
#include<functional>
using namespace std;
#define rep(i,a,n) for(llint i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
const ll mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const ll INF = 1000000000;

class UnionFind {
public:
	//親の番号を格納する
	vector<int> par;

	//最初は全てが根であるとして初期化
	UnionFind(int N) {
		par.resize(N);
		for (int i = 0; i < N; i++)par[i] = i;
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (par[A] == A) return A;
		return par[A] = root(par[A]);
	}


	//AとBをくっ付ける
	bool unite(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//Bの親をAに変更する
		par[B] = A;

		return true;
	}
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

template<class T>
class SegTree {
public:
	int size;
	vector<T> seg; //配列
	T e; //単位元
	function <T(T, T)> f; //演算
	SegTree(T n,T _e,function<T(T,T)> _f){ //コンストラクタ(初期化)
		f = _f;
		e = _e;
		size = 1;
		while (size < n)size *= 2;
		seg.resize(size * 2 - 1, e);
	}

	void updata(int n, int k) { //一点更新
		n += size - 1;
		seg[n] = k;
		while (n > 0) {
			n = (n - 1) / 2;
			seg[n] = f(seg[n * 2 + 1], seg[n * 2 + 2]);
		}
	}
	T query(int a, int b, int l, int r, int k) {
		if (b <= l || r <= a)return e;
		if (a <= l && r <= b)return seg[k];
		T v1 = query(a, b, l, (l + r) / 2, k * 2 + 1);
		T v2 = query(a, b, (l + r) / 2, r, k * 2 + 2);
		return f(v1, v2);
	}
};


int main() {
	int n, k;
	cin >> n >> k;
	SegTree<int> tree(300001, 0, [](int a, int b) {return max(a,b);});
	hei(int) a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, 0, n) {
		int l = max(0, a[i] - k);
		int r = min(a[i] + k, tree.size);
		int sum = tree.query(l, r+1, 0, tree.size, 0) + 1;
		ans = max(ans, sum);
		tree.updata(a[i], sum);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8524
import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int H = sc.nextInt();
		int W = sc.nextInt();
		int space = sc.nextInt();
		char[][] map = new char[H][W];
		for (int i=0; i<H; i++) {
			map[i] = sc.next().toCharArray();
		}

		int total = 0;
		
		for (int i=0; i<H; i++) {
			for (int j=0; j<W; j++) {
				if (map[i][j]=='.') {
					boolean Ver = true;
					for (int k=1; k<space; k++) {
						if (i+k >= H) {Ver = false; break;}
						if (map[i+k][j]=='#') {Ver = false;}
					}
					if (Ver) {total++;}

					boolean Hor = true;
					for (int k=1; k<space; k++) {
						if (j+k >= W) {Hor = false; break;}
						if (map[i][j+k]=='#') {Hor = false;} 
					}
					if (Hor) {total++;}
				}
			}
		}
		
		out.println(total);
	}
}


Measured memory_bytes: 28196
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator >> (istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

bool query(LL n) {
	cout << "? " << n << endl;
	string s;
	cin >> s;
	return s[0] == 'Y';
}
void determine(LL n) {
	cout << "! " << n << endl;
}

bool query_less(LL n) {
	while (n <= 10000000000) {
		n *= 10;
		n += 9;
	}
	return query(n);
}

LL search_rec(LL str, bool f = false) {
	int l = f, r = 10;
	REP(k, 0, 4) {
		if (l + 1 == r) break;
		int m = (l + r) / 2;
		if (query_less(str * 10 + m - 1)) {
			r = m;
		} else {
			l = m;
		}
	}
	return str * 10 + l;
}

LL search() {
	LL str = 0;
	REP(i, 0, 11) {
		str = search_rec(str, i == 0);
	}
	
	if (str == 10000000000) {
		LL q = 5;
		REP(i, 0, 10) {
			if (query(q)) break;
			q *= 10;
		}
		while (str > q) str /= 10;
	} else {
		LL q = 1;
		REP(i, 0, 10) {
			if (!query(q)) break;
			q *= 10;
		}
		while (str > q) str /= 10;
	}
	return str;
}

int main() {
	determine(search());
	return 0;
}

Measured memory_bytes: 596
#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 var auto
using namespace std;
using ll = long long;

int main() {
  ll n;
  int k;
  cin >> n >> k;

  vector<int> a;
  while (n >= k) {
    int s = n % k; // 11 % 2 = 1
    a.push_back(s);
    n = n / k; // 11 / 2 = 5
  }

  cout << a.size() + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>

using namespace std;

string s1,s2;

int main() {
    cin >> s1 >> s2;

    int c = 0;
    for(int i = 0; i < s1.length(); i++){
        if (s1 == s2){
            cout << "Yes" << endl;
            return 0;
        }

        s1 = s1[s1.length() - 1] + s1.substr(0,s1.length() - 1);
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int u=sc.nextInt()-1;
    int v=sc.nextInt()-1;
    Node[] ns=new Node[n];
    for(int i=0;i<n;i++){
      ns[i]=new Node();
    }
    for(int i=0;i<n-1;i++){
      int a=sc.nextInt()-1;
      int b=sc.nextInt()-1;
      ns[a].add(b);
      ns[b].add(a);
    }
    Deque<Node> dq=new ArrayDeque<>();
    ListIterator<Integer> lit;
    dq.add(ns[v]);
    ns[v].vis();
    while(!dq.isEmpty()){
      Node cur=dq.pollFirst();
      lit=cur.el.listIterator();
      while(lit.hasNext()){
        int idx=lit.next();
        if(!ns[idx].v){
          dq.add(ns[idx]);
          ns[idx].vis();
          ns[idx].al=cur.al+1;
        }
      }
    }
    dq.add(ns[u]);
    ns[u].vis(false);
    while(!dq.isEmpty()){
      Node cur=dq.pollFirst();
      lit=cur.el.listIterator();
      while(lit.hasNext()){
        int idx=lit.next();
        if(ns[idx].v){
          dq.add(ns[idx]);
          ns[idx].vis(false);
          ns[idx].tl=cur.tl+1;
        }
      }
    }
    int max=0;
    for(int i=0;i<n;i++){
      if(ns[i].al>ns[i].tl){
        max=Math.max(ns[i].al-1,max);
      }
    }
    System.out.println(max);
  }
  static class Node{
    int al;
    int tl;
    boolean v;
    List<Integer> el;
    Node(){
      el=new ArrayList<>();
    }
    void add(int e){
      el.add(e);
    }
    void vis(){
      vis(true);
    }
    void vis(boolean vv){
      v=vv;
    }
    public String toString(){
      return al+":"+tl+":"+el.toString();
    }
  }
  static class Edge{
    int f;
    int t;
    Edge(int from,int to){
      f=from;
      t=to;
    }
  }
}


Measured memory_bytes: 110716
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

char stage[1010][1010];
char crest[8][8];
int dp[1001][1001];
int W,H;

int match(int x,int y){
  int count = 0;
  if(x < 0 || y < 0 || x + 1 >= W || y + 1 >= H) return 0;
  for(int stage_y = y,crest_y = 0; stage_y <= y + 1; stage_y++,crest_y++){
    for(int stage_x = x,crest_x = 0; stage_x <= x + 1; stage_x++,crest_x++){
      if(stage[stage_y][stage_x] == crest[crest_y][crest_x]){
        count++;
      }
    }
  }
  return (count == 4 ? 1 : 0);
}

int main(){
  while(~scanf("%d %d",&H,&W)){
    memset(dp,0,sizeof(dp));
    int res = 0;
    for(int y = 0; y < H; y++){
      string line;
      cin >> line;
      for(int x = 0; x < W; x++){
        stage[y][x] = line[x];
      }
    }
    for(int y = 0; y < 2; y++){
      string line;
      cin >> line;
      for(int x = 0; x < 2; x++){
        crest[y][x] = line[x];
      }
    }

    for(int y = 0; y < H; y++){
      for(int x = 0; x < W; x++){
        res += match(x,y);
      }
    }
    int base = res;
    const char JOI[] = {'J','O','I'};
    for(int y = 0; y < H; y++){
      for(int x = 0; x < W; x++){
        for(int char_i = 0; char_i < 3; char_i++){
          int tmp = base - (match(x,y) + match(x-1,y) + match(x,y-1) + match(x-1,y-1));
          char prev = stage[y][x];
          stage[y][x] = JOI[char_i];
          res = max(res,tmp + (match(x,y) + match(x-1,y) + match(x,y-1) + match(x-1,y-1)));
          stage[y][x] = prev;
        }
      }
    }
    
    printf("%d\n",res);
  }
}

Measured memory_bytes: 6136
#include<iostream>
using namespace std;	
int main(){
	int a,g=0;
	for(int i=0;i<3;i++) cin >> a,g+=a;
		if(g>=22) cout << "bust" << endl;
		else if(g<=21)cout << "win" << endl;
	
	return 0;
	
}	

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

int main() {
  ll n;
  cin >> n;
  vector<ll> f(n+1);
  ll ans=0;
  for(int i = 1; i<=n; i++){
    for(int j=i; j<=n; j += i) f[j]++;
  }
  rep(i,n+1) ans += i*f[i] ;
  cout << ans << endl;
}


Measured memory_bytes: 81396
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int x;
    cin >> x;
    
    for (ll a = -1000; a <= 1000; a++) {
        for (ll b = -1000; b <= 1000; b++) {
            ll d = a * a * a * a * a - b * b * b * b * b;
            if (d == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }        
    }
    
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using  namespace std;
int main(){
    int n, ans = -1, maxCheck;
    cin >> n;
    int A[2][n];
    for(int i=0;i<n;i++){
        cin >> A[0][i];
    }
    for(int i=0;i<n;i++){
        cin >> A[1][i];
    }
    for(int i=0;i<n;i++){
        maxCheck = 0;
        for(int j=0;j<n;j++){
            if(j==i){
                maxCheck += A[0][j] + A[1][j];
            }else if(j<i){
                maxCheck += A[0][j];
            }else{
                maxCheck += A[1][j];
            }
        }
        ans = max(ans, maxCheck);   
    }
    cout << ans << endl;
    return 0;
}


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


int main(){
	int n;
	scanf("%d",&n);
	if(n==1){
		printf("Hello World\n");
	}
	else if(n==2){
		int a,b;
		scanf("%d",&a);
		scanf("%d",&b);
		printf("%d\n",a+b);
	}
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    set<pair<int,int>> st;
    for(int i = 0; i < n; i++){
        if(i == a[a[i]]){
            st.insert(make_pair(i < a[i] ? i : a[i], i < a[i] ? a[i] : i));
        }
    }

    cout << st.size() << endl;
}


Measured memory_bytes: 2944
import numpy as np
n,m,x=map(int,input().split())
P = [list( map( int, input().split() ) ) for i in range(n)]
ca=np.array(P).reshape((n,m+1))
value= 10000000
for i in range(2**n):
  sum=np.zeros(m+1)
  for y in range(n):
    if list(bin(i >> y))[-1] == '1':
      sum += ca[-y-1,:]
    else:
      pass
  summ=sum[1:]
  if all(elm >= x for elm in summ) == True:
    if value==int(sum[0]):
      value=int(sum[0])
    else:
      value= min(int(sum[0]), value)
if value==10000000:
  print('-1')
else:
  print(value)

Measured memory_bytes: 27004
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;


inline void solve(){
    int a,b; cin>>a>>b; 
    vector <int> v; 
    while (b){
        v.pb(b%10);
        b/=10;
    }
    while (a){
        v.pb(a%10);
        a/=10;
    }
    int n=0,i=1;
    for (auto it: v){
        n += i*it;
        i *= 10;
    }
    int h=sqrt(n);
    if (h*h==n) cout << "Yes" << endl; 
    else cout << "No" << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3692
function main(input) {
  let [A, B, C, K] = input.split(' ').map(Number)
  let v = 0
  K = K - A
  if (K <= 0) {
    v += (K + A)
    console.log(v)
    return
  } else {
    v += A
  }
  // console.log(v, K)
  K = K - B
  if (K <= 0) {
    console.log(v)
    return
  }
  // console.log(v, K)
  K = K - C
  if (K <= 0) {
    v -= (K + C)
    console.log(v)
  } else {
    v -= C
    console.log(v)
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29700
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// A, Bの入力
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		// 結果の出力
		if (A < 10 && B < 10) {
			System.out.println(A * B);
		}
		else {
			System.out.println(-1);
		}
		
		sc.close();
	}

}


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

int main() {
	int n;
	cin>>n;
	int a[n],c[100001];
	int ans=n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<=100000){
			c[a[i]]++;
			if(c[a[i]]==a[i]){
				ans-=a[i];
			}
		}
	}
	cout<<ans<<endl;
//	cout<<c[2]<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
const int mod=1e9+7;
int n,m,a[205],f[205][100005],ans;
bool cmp(int i,int j){return i>j;}
int main(){
	n=gi();m=gi();
	for(int i=1;i<=n;++i)a[i]=gi();
	sort(a+1,a+n+1,cmp);f[0][m]=1;
	for(int i=1;i<n;++i)
		for(int j=0;j<=m;++j){
			f[i][j%a[i]]=(f[i][j%a[i]]+f[i-1][j])%mod;
			f[i][j]=(f[i][j]+1ll*(n-i)*f[i-1][j])%mod;
		}
	for(int j=0;j<=m;++j)f[n][j%a[n]]=(f[n][j%a[n]]+f[n-1][j])%mod;
	for(int j=0;j<=m;++j)ans=(ans+1ll*f[n][j]*j)%mod;
	printf("%d\n",ans);return 0;
}


Measured memory_bytes: 79616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 20;
int x[N], y[N];

double dist[10010][N][N];

vector<int> G[N][N];
double D[N][N];
int ok[N][N][N];

const double PI = 4 * atan(1);
const double EPS = 1e-9;

int main(){
	int n;
	double r, theta;
	cin >> n >> r >> theta;
	theta = theta / 180 * PI;
	rep(i, n) cin >> x[i] >> y[i];

	rep(i, n) rep(j, n){
		D[i][j] = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]));
	}

	rep(i, n) rep(j, n) rep(k, n){
		if (i == j || j == k) continue;
		double x1 = x[j] - x[i], y1 = y[j] - y[i];
		double x2 = x[k] - x[j], y2 = y[k] - y[j];

		double ct = (x1*x2 + y1*y2) / (D[i][j]*D[j][k]);
		double t = acos(ct);

		if (abs(t) < theta + EPS) G[i][j].push_back(k), ok[i][j][k] = 1;
	}

	MEMSET(dist, 0x7f);

	priority_queue<tuple<double, int, int, int>> pq;

	rep(i, n) rep(j, n){
		if (i) continue;
		if (i == j) continue;
		if (D[i][j] > r - EPS) continue;
		pq.emplace(-D[i][j], 1, i, j);
		dist[1][i][j] = D[i][j];
	}

	int ans = 0;
	//while (!pq.empty()){
	//	auto t = pq.top();
	//	pq.pop();
	//	double d;
	//	int c, prv, cur;
	//	tie(d, c, prv, cur) = t;
	//	d = -d;

	//	if (dist[c][prv][cur] + EPS < d) continue;

	//	ans = max(ans, c);

	//	for (auto v : G[prv][cur]){
	//		double nd = d + D[cur][v];
	//		if (r < nd + EPS) continue;
	//		if (dist[c + 1][cur][v] < nd + EPS) continue;
	//		dist[c + 1][cur][v] = nd;
	//		pq.emplace(-nd, c + 1, cur, v);
	//	}
	//}

	rep(i, 10010) rep(j, n) rep(k, n){
		if (dist[i][j][k] > r - EPS) continue;
		ans = i;
		rep(l, n) if (ok[j][k][l]) dist[i + 1][k][l] = min(dist[i + 1][k][l], dist[i][j][k] + D[k][l]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 32720
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
//#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repm(i, a, n) for (int i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

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

    map<char, int> mp;
    mp['R'] = mp['G'] = mp['B'] = 0;
    rep(i, 0, n) mp[s[i]]++;
    ll ans = (ll)mp['R'] * (ll)mp['G'] * (ll)mp['B'];

    rep(i, 0, n)
    {
        rep(j, i + 1, n)
        {
            int k = j + (j - i);
            if (k >= n)
                break;
            if (s[i] != s[j] && s[k] != s[j] && s[i] != s[k])
                ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<int ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, ans=0;
    priority_queue<ll> que;
    cin >> n;
    vector<ll> cnt(n);
    vector<vector<ll> > c(n);
    REP(i,n) cnt[i] = i+1;
    REP(i,n){
        ll m;
        cin >> m;
        c[i].resize(m);
        REP(j,m){
            cin >> c[i][j];
        }
    }
    for(int i=n-1;i>=0;i--){
        for(auto x : c[i]){
            que.push(x);
        }
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 21520
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	string buffer;

	getline( cin, buffer );

	for ( unsigned int i = 0; i < buffer.length(); i++ )
	{
		if ( buffer[i] == '.' || buffer[i] == ',' )
		{
			buffer[i] = ' ';
		}
	}

	istringstream iss( buffer );

	string word;
	bool first = true;
	while ( iss >> word )
	{
		unsigned l = word.length();

		if ( 3 <= l && l <= 6 )
		{
			if ( !first )
			{
				cout << ' ';
			}
			else
			{
				first = false;
			}

			cout << word;
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main() {
	int S, h, m,s;	// ??????S

	std::cin >> S;
	
	h = S / 3600;
	m = (S-h * 3600)/60;
	s = S % 60;
	std::cout << h << ":" << m << ":" << s << std::endl;
	
	return 0;
}

Measured memory_bytes: 3112
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
unsigned ll a[MAX],b[MAX],x[MAX],y[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
    int n,m,k,cnt;
    cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=1;i<n;i++)
	a[i]+=a[i-1];
	for(int i=0;i<m;i++)
	cin>>b[i];
	for(int i=1;i<m;i++)
	b[i]+=b[i-1];
	unsigned ll ans1=0,ans2=0,sum=0;
	for(ll i=0;i<n;i++)
	{
		sum=a[i];
		unsigned ll temp=k-sum;
		if(temp>k)break;
		unsigned ll pos=upper_bound(b,b+m,temp)-b;
		ans1=max(pos+i+1,ans1);
	}
	sum=0;
	for(ll i=0;i<m;i++)
	{
		sum=b[i];
		unsigned ll temp=k-sum;
		if(temp>k)break;
		unsigned ll pos=upper_bound(a,a+n,temp)-a;
		ans2=max(pos+i+1,ans2);
	}
	cout<<max(ans1,ans2);
    return 0;
}


Measured memory_bytes: 6812
import java.util.Scanner;

public class Main{
     public static void main(String[] args){
Scanner scan= new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
int count=0;

if(a==b && b==c){
 if(a%2==0 && b%2==0 && c%2==0) count=-1;
}else{
while(a%2==0 && b%2==0 && c%2==0){
int a1=a;
int b1=b;
int c1=c;

a = c1/2 + b1/2;
b = a1/2 + c1/2;
c = a1/2 + b1/2;

count++;
}
}
System.out.println(count);

     }
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

map<char, char> m;

int main() {
    COME_LET_THE_GAMES_BEGIN();
    double A, B;
    cin >> A >> B;
    cout << A * B / (A + B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
//floor((A*i + B) / M) (0 <= i <= N-1)の総和
long long floor_sum(long long n, long long m, long long a, long long b) {
    long long ans = 0;
    if (a >= m) {
        ans += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if (b >= m) {
        ans += n * (b / m);
        b %= m;
    }

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floor_sum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll T, N, M, A, B;
  cin >> T;
  rep(i, T){
    cin >> N >> M >> A >> B;
    cout << floor_sum(N, M, A, B) << endl;
  }
}


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

int main(){
  long n,m;
  cin >> n >> m;
  
  long a, b;
  bool one[n]={false}, two[n]={false};
  for(int i=0; i<m;i++){
    cin >> a >> b;
    if(a == 1) one[b-1] = true;
    if(a == n) two[b-1] = true;
    if(b == 1) one[a-1] = true;
    if(b == n) two[a-1] = true;
  }
  
  for(int i=0; i<n;i++){
    if(one[i] && two[i]){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
      
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int a[n],b[m];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];
  int c[n];
  memset(c,0,sizeof(c));
  for(int j=0;j<m;j++){
    for(int i=0;i<n;i++){
      if(b[j]<a[i]) continue;
      c[i]++;
      break;
    }
  }
  cout<<max_element(c,c+n)-c+1<<endl;
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int N, M;
  vector<string> s, t;
  string tmp;

  cin >> N;
  for(int i=0; i<N; i++) {
    cin >> tmp;
    s.push_back(tmp);
  }

  cin >> M;
  for(int i=0; i<M; i++) {
    cin >> tmp;
    t.push_back(tmp);
  }
  
  vector<string> words;
  vector<int> counts;
  
  bool include;
  int i, j;
  for(i=0; i<N; i++) {
    include = false;
    for(j=0; j<words.size(); j++) {
      if( s[i] == words[j] ) {
        include = true;
        break;
      }
    }
    if (include) {
      counts[j]++;
    } else {
      words.push_back(s[i]);
      counts.push_back(1);
    }
  }
  //
  // for(int _=0; _<words.size(); _++){
  //   cout << words[_] << ": " << counts[_] << endl;
  // }
  
  int max_point=0, point;
  for (int i=0; i<words.size(); i++) {
    point = counts[i];
    for (int j=0; j<M; j++) {
      if (t[j] == words[i])
        point--;
    }
    if (point > max_point) {
      max_point = point;
    }
  }

  cout << max_point << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader in = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(in);
		
		while (true) {
			String[] buf = (br.readLine()).split(" ");
			int mid_exam = Integer.parseInt(buf[0]);
			int final_exam = Integer.parseInt(buf[1]);
			int retest = Integer.parseInt(buf[2]);
			char result;
			
			if (mid_exam == -1 && final_exam == -1 && retest == -1) {
				break;
			}
			
			if (mid_exam == -1 || final_exam == -1) {
				result = 'F';
			} else {
			
				if (mid_exam == -1) { mid_exam = 0; }
				if (final_exam == -1 ) { final_exam = 0; }
				int sum = mid_exam + final_exam;
				
				if (sum >= 80) { result = 'A'; }
				else if (sum >= 65) { result = 'B'; }
				else if (sum >= 50) { result = 'C'; }
				else if (sum >= 30) {
					if (retest >= 50) { result = 'C'; }
					else { result = 'D'; } }
				else { result = 'F'; }
			}
			
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 24268
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: i32,
    }

    for i in 1..=10 {
        let a = i * 1000;
        if a >= n {
            println!("{}", a - n);
            return;
        }
    }
}


Measured memory_bytes: 2172
n, k = map(int, raw_input().split())
counter = {}
for i in range(n):
    a, b = map(int, raw_input().split())
    if counter.has_key(a):
        counter[a] += b
    else:
        counter[a] = b

num = 0
for ele in sorted(counter.items()):
    num += ele[1]
    if k <= num:
        print ele[0]
        break

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

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n;
	string s;
	cin >> n >> s;
	vector<int> a[3];
	map<char, int> mp = {{'R', 0}, {'G', 1}, {'B', 2}};
	for (int i = 0; i < n; ++i){
		a[mp[s[i]]].push_back(i);
	}
	long long ans = 0;
	for (int i = 0; i < a[0].size(); ++i){
		for (int j = 0; j < a[1].size(); ++j){
			ans += (a[2].size());
			int x = max(a[0][i], a[1][j]);
			int y = min(a[0][i], a[1][j]);
			int diff = x - y;
			if (x + diff < n && s[x + diff] == 'B') ans--;
			if (y - diff >= 0 && s[y - diff] == 'B') ans--;
			if ((x + y) % 2 == 0 && s[(x + y) / 2] == 'B') ans--;
		}
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 3660